wt.calendar
Class StandardCalendarService

java.lang.Object
  extended bywt.services.StandardManager
      extended bywt.calendar.StandardCalendarService
All Implemented Interfaces:
CalendarService, Manager, NetFactor, Serializable

public class StandardCalendarService
extends StandardManager
implements CalendarService, Serializable

This is a Lightweight service. It will implement the methods as specified in its interface to expose, or not as the case may be, portions of the underlaying WTCalendar. It will implement the Calendar Access Protocol (CAP) interface to talk to our local calendar store. The calculateDeadline methods are called by the Workflow package; and will use the base corporate calendar for activities with multiple participants. The user's calendar, if present, will be used for single participant activities - the corp. calendar will be used otherwise. Note that the user calendars are based upon the corp. calendar.

Use the newStandardCalendarService static factory method(s), not the StandardCalendarService constructor, to construct instances of this class. Instances must be constructed using the static factory(s), in order to ensure proper initialization of the instance.



Supported API: false

Extendable: false

See Also:
Serialized Form

Nested Class Summary
(package private)  class StandardCalendarService.AllManagersStartedEventListener
           
(package private) static class StandardCalendarService.CacheModFlusher
          Top level inner class which signals cache modifications - creates and deletes
 
Field Summary
private  StandardCalendarService.AllManagersStartedEventListener allManagersStartedListener
           
private static boolean CALC_DEFAULTS
           
private  CalendarAccessProtocol cap
           
private static String CLASSNAME
           
private static int[] days_in_month
           
private static int DEBUG
           
protected static TimeZone MSTZ
           
protected static int MSTZ_OFFSET
           
private static String NON_WORK_DAYS_OF_THE_WEEK
           
private  ResourceBundle rb
           
private static String RESOURCE
           
static WTCalendar system_calendar
           
static WTPrincipalReference systemCalendarOwner
           
private static boolean VERBOSE
           
 
Fields inherited from class wt.services.StandardManager
 
Fields inherited from interface wt.services.Manager
MANAGER_SERVICE, STARTUP_AUTOMATIC, STARTUP_MANUAL, STATUS_EMERGENCY_SHUTDOWN, STATUS_EMERGENCY_SHUTTING_DOWN, STATUS_SHUTDOWN, STATUS_SHUTDOWN_ERRORS, STATUS_SHUTDOWN_FAILURE, STATUS_SHUTTING_DOWN, STATUS_STARTED, STATUS_STARTED_ERRORS, STATUS_STARTING_UP, STATUS_STARTUP_FAILURE
 
Constructor Summary
StandardCalendarService()
           
 
Method Summary
 Timestamp calculateDeadline(WTPrincipal user, long start_date, int nbrWorkDays)
          Calculates the deadline from "start" that is "nbrWorkDays" hence for "user".
 Timestamp calculateDeadline(WTPrincipal user, long start_date, int nbrWorkDays, int zone_offset)
          Calculates the deadline from "start" that is "nbrWorkDays" hence for "user".
 Timestamp calculateDeadline(WTPrincipal user, long start_date, long duration)
          Calculate and return the due date, as a Timestamp, for the "user" based upon the "start" date and expected "duration".
 Timestamp calculateDeadline(WTPrincipal user, long start_date, long duration, int zone_offset)
          Calculate and return the due date, as a Timestamp, for the "user" based upon the "start" date and expected "duration".
 Timestamp calculateDeadline(WTPrincipalReference user, long start_date, int nbrWorkDays)
          Calculates the deadline from "start" that is "nbrWorkDays" hence for "user".
 Timestamp calculateDeadline(WTPrincipalReference user, long start_date, int nbrWorkDays, int zone_offset)
          Calculates the deadline from "start" that is "nbrWorkDays" hence for "user".
 Timestamp calculateDeadline(WTPrincipalReference user, long start_date, long duration)
          Calculate and return the due date, as a Timestamp, for the "user" based upon the "start" date and expected "duration".
 Timestamp calculateDeadline(WTPrincipalReference user, long start_date, long duration, int zone_offset)
          Calculate and return the due date, as a Timestamp, for the "user" based upon the "start" date and expected "duration".
 int calculateWorkingDays(WTPrincipal user, long start_date, long end_date)
          Calculate the number of working days for the user between start and end.
 int calculateWorkingDays(WTPrincipal user, long start_date, long end_date, int zone_offset)
          Calculate the number of working days for the user between start and end.
 int calculateWorkingDays(WTPrincipalReference user, long start_date, long end_date)
          Calculate the number of working days for the user between start and end.
 int calculateWorkingDays(WTPrincipalReference user, long start_date, long end_date, int zone_offset)
          Calculate the number of working days for the user between start and end.
 int calculateWorkingPeriods(WTPrincipal user, long start_date, long end_date)
          Calculate the number of workable 24-hour periods for the user between start and end dates, inclusive.
 int calculateWorkingPeriods(WTPrincipal user, long start_date, long end_date, int zone_offset)
          Calculate the number of workable 24-hour periods for the user between start and end dates, inclusive.
 int calculateWorkingPeriods(WTPrincipalReference user, long start_date, long end_date)
          Calculate the number of workable 24-hour periods for the user between start and end dates, inclusive.
 int calculateWorkingPeriods(WTPrincipalReference user, long start_date, long end_date, int zone_offset)
          Calculate the number of workable 24-hour periods for the user between start and end dates, inclusive.
 boolean checkCyclicDelegate(WTPrincipalReference user, WTPrincipalReference delegate, long start_date, long end_date)
           
 CalendarMonth clearDays(WTPrincipalReference user, long start_date, long end_date, boolean undelegate, int zone_offset)
          Resets the user's days specified between start and end back to that of the Windchill system calendar (note that delegation is also cleared).
 GregorianCalendar convert_long_ToCalendar(long l)
           
 Timestamp convert_longToTimestamp(long l)
           
 long convertCalendarTo_long(Calendar tmpCal)
           
 Timestamp convertCalendarToTimestamp(Calendar tmpCal)
           
 long convertTimestampTo_long(Timestamp t)
           
 GregorianCalendar convertTimestampToCalendar(Timestamp t)
           
 CalendarMonth getCalendarMonth(WTPrincipalReference user, int month, int year, int zone_offset)
          Note that to access the system calendar, the user parm would need to be the WTPrincipalReference for the WTGroup assigned in the wt.properties file to the property wt.admin.adminGroup.
 String getConceptualClassname()
          Deprecated.  
 WTPrincipalReference getDelegate(WTPrincipalReference user, long start_date, long end_date)
          Passed the reference to a WTPrincipal to check if delegation exists for the period of time from start-end.
 WTUser getDelegate(WTUser user, long start_date, long end_date)
          Passed the reference to a WTUser to check if delegation exists for the period of time from start-end.
static StandardCalendarService newStandardCalendarService()
          Default factory for the class.
protected  void performStartupProcess()
          Dummy method to be overridden by subclasses.
private  void removeFromCache(WTCalendar userCalendar)
           
private  void removeFromCache(WTPrincipalReference prinRef)
           
 CalendarMonth setDelegatedDays(WTPrincipalReference user, WTPrincipalReference delegate, long start_date, long end_date, int zone_offset)
          Sets the user's days specified between start and end as delegated to the "delegate" passed in.
 CalendarMonth setDelegateIndefinitely(WTPrincipalReference user, WTPrincipalReference delegate, long start_date, int zone_offset)
          Sets the delegation for this user to "delegate" and begin on "start".
 CalendarMonth setNonWorkDays(WTPrincipalReference user, long start_date, long end_date, int zone_offset)
          Sets the user's days specified between start and end as Non-Working Days.
 CalendarMonth setWorkDays(WTPrincipalReference user, long start_date, long end_date, int zone_offset)
          Sets the user's days specified between start and end as Working Days.
 
Methods inherited from class wt.services.StandardManager
emergencyShutdown, emergencyShutdownComplete, emergencyShuttingDown, getClassInfo, getManagerService, getManagerStatus, getName, getStartupType, init, initialize, initialize, isStarted, newStandardManager, newStandardManager, performEmergencyShutdownProcess, performShutdownProcess, registerEvents, setManagerService, shutdown, shutdownFailure, shutdownSuccess, shuttingDown, started, startedErrors, startingUp, startup, startupFailure, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

CLASSNAME

private static final String CLASSNAME

system_calendar

public static WTCalendar system_calendar

systemCalendarOwner

public static WTPrincipalReference systemCalendarOwner

MSTZ

protected static TimeZone MSTZ

MSTZ_OFFSET

protected static int MSTZ_OFFSET

cap

private CalendarAccessProtocol cap

VERBOSE

private static boolean VERBOSE

CALC_DEFAULTS

private static boolean CALC_DEFAULTS

DEBUG

private static int DEBUG

NON_WORK_DAYS_OF_THE_WEEK

private static String NON_WORK_DAYS_OF_THE_WEEK

days_in_month

private static int[] days_in_month

rb

private ResourceBundle rb

allManagersStartedListener

private StandardCalendarService.AllManagersStartedEventListener allManagersStartedListener
Constructor Detail

StandardCalendarService

public StandardCalendarService()
Method Detail

getConceptualClassname

public String getConceptualClassname()
Deprecated.  

Returns the conceptual (modeled) name for the class.

Supported API: false

Specified by:
getConceptualClassname in interface NetFactor
Overrides:
getConceptualClassname in class StandardManager
Returns:
String

newStandardCalendarService

public static StandardCalendarService newStandardCalendarService()
                                                          throws WTException
Default factory for the class.

Supported API: false

Returns:
StandardCalendarService
Throws:
WTException

setWorkDays

public CalendarMonth setWorkDays(WTPrincipalReference user,
                                 long start_date,
                                 long end_date,
                                 int zone_offset)
                          throws WTException
Sets the user's days specified between start and end as Working Days. It returns a new copy of the user's CalendarMonth for the client to display. We use long values here so that Java doesn't attempt to translate time zones during deserialization. This is similar to what is done in other portions of Windchill for the same purpose.

Supported API: false

Specified by:
setWorkDays in interface CalendarService
Parameters:
user -
start_date -
end_date -
zone_offset -
Returns:
CalendarMonth
Throws:
WTException

setNonWorkDays

public CalendarMonth setNonWorkDays(WTPrincipalReference user,
                                    long start_date,
                                    long end_date,
                                    int zone_offset)
                             throws WTException
Sets the user's days specified between start and end as Non-Working Days. It returns a new copy of the user's CalendarMonth for the client to display. We use long values here so that Java doesn't attempt to translate time zones during deserialization. This is similar to what is done in other portions of Windchill for the same purpose.

Supported API: false

Specified by:
setNonWorkDays in interface CalendarService
Parameters:
user -
start_date -
end_date -
zone_offset -
Returns:
CalendarMonth
Throws:
WTException

setDelegatedDays

public CalendarMonth setDelegatedDays(WTPrincipalReference user,
                                      WTPrincipalReference delegate,
                                      long start_date,
                                      long end_date,
                                      int zone_offset)
                               throws WTException
Sets the user's days specified between start and end as delegated to the "delegate" passed in. It returns a new copy of the user's CalendarMonth for the client to display. If a NULL is passed in the delegate parm, it is interpreted to mean clear the date range of delegation. We use long values here so that Java doesn't attempt to translate time zones during deserialization. This is similar to what is done in other portions of Windchill for the same purpose.

Supported API: false

Specified by:
setDelegatedDays in interface CalendarService
Parameters:
user -
delegate -
start_date -
end_date -
zone_offset -
Returns:
CalendarMonth
Throws:
WTException

setDelegateIndefinitely

public CalendarMonth setDelegateIndefinitely(WTPrincipalReference user,
                                             WTPrincipalReference delegate,
                                             long start_date,
                                             int zone_offset)
                                      throws WTException
Sets the delegation for this user to "delegate" and begin on "start". The delegation will continue indefinitely, or until the delegation is removed. It returns a new copy of the user's CalendarMonth for the client to display. If a NULL is passed in the delegate parm, it is interpreted to mean clear the delegation. We use long values here so that Java doesn't attempt to translate time zones during deserialization. This is similar to what is done in other portions of Windchill for the same purpose.

Supported API: false

Specified by:
setDelegateIndefinitely in interface CalendarService
Parameters:
user -
delegate -
start_date -
zone_offset -
Returns:
CalendarMonth
Throws:
WTException

clearDays

public CalendarMonth clearDays(WTPrincipalReference user,
                               long start_date,
                               long end_date,
                               boolean undelegate,
                               int zone_offset)
                        throws WTException
Resets the user's days specified between start and end back to that of the Windchill system calendar (note that delegation is also cleared). It returns a new copy of the user's CalendarMonth for the client to display. We use long values here so that Java doesn't attempt to translate time zones during deserialization. This is similar to what is done in other portions of Windchill for the same purpose.

Supported API: false

Specified by:
clearDays in interface CalendarService
Parameters:
user -
start_date -
end_date -
undelegate -
zone_offset -
Returns:
CalendarMonth
Throws:
WTException

getCalendarMonth

public CalendarMonth getCalendarMonth(WTPrincipalReference user,
                                      int month,
                                      int year,
                                      int zone_offset)
                               throws WTException
Note that to access the system calendar, the user parm would need to be the WTPrincipalReference for the WTGroup assigned in the wt.properties file to the property wt.admin.adminGroup.

Supported API: false

Specified by:
getCalendarMonth in interface CalendarService
Parameters:
user -
month -
year -
zone_offset -
Returns:
CalendarMonth
Throws:
WTException

calculateDeadline

public Timestamp calculateDeadline(WTPrincipal user,
                                   long start_date,
                                   long duration)
                            throws WTException
Calculate and return the due date, as a Timestamp, for the "user" based upon the "start" date and expected "duration".

Supported API: false

Specified by:
calculateDeadline in interface CalendarService
Parameters:
user -
start_date -
duration -
Returns:
Timestamp
Throws:
WTException

calculateDeadline

public Timestamp calculateDeadline(WTPrincipalReference user,
                                   long start_date,
                                   long duration)
                            throws WTException
Calculate and return the due date, as a Timestamp, for the "user" based upon the "start" date and expected "duration".

Supported API: false

Specified by:
calculateDeadline in interface CalendarService
Parameters:
user -
start_date -
duration -
Returns:
Timestamp
Throws:
WTException

calculateDeadline

public Timestamp calculateDeadline(WTPrincipal user,
                                   long start_date,
                                   int nbrWorkDays)
                            throws WTException
Calculates the deadline from "start" that is "nbrWorkDays" hence for "user". Returns the date as a Timestamp.

Supported API: false

Specified by:
calculateDeadline in interface CalendarService
Parameters:
user -
start_date -
nbrWorkDays -
Returns:
Timestamp
Throws:
WTException

calculateDeadline

public Timestamp calculateDeadline(WTPrincipalReference user,
                                   long start_date,
                                   int nbrWorkDays)
                            throws WTException
Calculates the deadline from "start" that is "nbrWorkDays" hence for "user". Returns the date as a Timestamp.

Supported API: false

Specified by:
calculateDeadline in interface CalendarService
Parameters:
user -
start_date -
nbrWorkDays -
Returns:
Timestamp
Throws:
WTException

calculateWorkingDays

public int calculateWorkingDays(WTPrincipal user,
                                long start_date,
                                long end_date)
                         throws WTException
Calculate the number of working days for the user between start and end. Return number of days as integer. If the administrators group is passed in, calculation is based on system calendar.

Supported API: false

Specified by:
calculateWorkingDays in interface CalendarService
Parameters:
user -
start_date -
end_date -
Returns:
int
Throws:
WTException

calculateWorkingDays

public int calculateWorkingDays(WTPrincipalReference user,
                                long start_date,
                                long end_date)
                         throws WTException
Calculate the number of working days for the user between start and end. Return number of days as integer. If the administrators group is passed in, calculation is based on system calendar.

Supported API: false

Specified by:
calculateWorkingDays in interface CalendarService
Parameters:
user -
start_date -
end_date -
Returns:
int
Throws:
WTException

getDelegate

public WTUser getDelegate(WTUser user,
                          long start_date,
                          long end_date)
                   throws WTException
Passed the reference to a WTUser to check if delegation exists for the period of time from start-end. Returns the WTPrincipalReference of the delegate, or NULL of none is present.

Supported API: false

Specified by:
getDelegate in interface CalendarService
Parameters:
user -
start_date -
end_date -
Returns:
WTUser
Throws:
WTException

getDelegate

public WTPrincipalReference getDelegate(WTPrincipalReference user,
                                        long start_date,
                                        long end_date)
                                 throws WTException
Passed the reference to a WTPrincipal to check if delegation exists for the period of time from start-end. Returns the WTPrincipalReference of the delegate, or NULL of none is present.

Supported API: false

Specified by:
getDelegate in interface CalendarService
Parameters:
user -
start_date -
end_date -
Returns:
WTPrincipalReference
Throws:
WTException

calculateWorkingPeriods

public int calculateWorkingPeriods(WTPrincipal user,
                                   long start_date,
                                   long end_date)
                            throws WTException
Calculate the number of workable 24-hour periods for the user between start and end dates, inclusive. Return number of periods as integer. If the administrators group is passed in, the calculation is based on system calendar. The start and end dates will be truncated to full seconds - fractional seconds will be dropped.

Supported API: false

Specified by:
calculateWorkingPeriods in interface CalendarService
Parameters:
user -
start_date -
end_date -
Returns:
int
Throws:
WTException

calculateWorkingPeriods

public int calculateWorkingPeriods(WTPrincipalReference user,
                                   long start_date,
                                   long end_date)
                            throws WTException
Calculate the number of workable 24-hour periods for the user between start and end dates, inclusive. Return number of periods as integer. If the administrators group is passed in, the calculation is based on system calendar. The start and end dates will be truncated to full seconds - fractional seconds will be dropped.

Supported API: false

Specified by:
calculateWorkingPeriods in interface CalendarService
Parameters:
user -
start_date -
end_date -
Returns:
int
Throws:
WTException

calculateWorkingDays

public int calculateWorkingDays(WTPrincipal user,
                                long start_date,
                                long end_date,
                                int zone_offset)
                         throws WTException
Calculate the number of working days for the user between start and end. Return number of days as integer. If the administrators group is passed in, calculation is based on system calendar.

Supported API: false

Specified by:
calculateWorkingDays in interface CalendarService
Parameters:
user -
start_date -
end_date -
zone_offset -
Returns:
int
Throws:
WTException

calculateWorkingDays

public int calculateWorkingDays(WTPrincipalReference user,
                                long start_date,
                                long end_date,
                                int zone_offset)
                         throws WTException
Calculate the number of working days for the user between start and end. Return number of days as integer. If the administrators group is passed in, calculation is based on system calendar.

Supported API: false

Specified by:
calculateWorkingDays in interface CalendarService
Parameters:
user -
start_date -
end_date -
zone_offset -
Returns:
int
Throws:
WTException

calculateWorkingPeriods

public int calculateWorkingPeriods(WTPrincipal user,
                                   long start_date,
                                   long end_date,
                                   int zone_offset)
                            throws WTException
Calculate the number of workable 24-hour periods for the user between start and end dates, inclusive. Return number of periods as integer. If the administrators group is passed in, the calculation is based on system calendar. The start and end dates will be truncated to full seconds - fractional seconds will be dropped.

Supported API: false

Specified by:
calculateWorkingPeriods in interface CalendarService
Parameters:
user -
start_date -
end_date -
zone_offset -
Returns:
int
Throws:
WTException

calculateWorkingPeriods

public int calculateWorkingPeriods(WTPrincipalReference user,
                                   long start_date,
                                   long end_date,
                                   int zone_offset)
                            throws WTException
Calculate the number of workable 24-hour periods for the user between start and end dates, inclusive. Return number of periods as integer. If the administrators group is passed in, the calculation is based on system calendar. The start and end dates will be truncated to full seconds - fractional seconds will be dropped.

Supported API: false

Specified by:
calculateWorkingPeriods in interface CalendarService
Parameters:
user -
start_date -
end_date -
zone_offset -
Returns:
int
Throws:
WTException

calculateDeadline

public Timestamp calculateDeadline(WTPrincipal user,
                                   long start_date,
                                   long duration,
                                   int zone_offset)
                            throws WTException
Calculate and return the due date, as a Timestamp, for the "user" based upon the "start" date and expected "duration".

Supported API: false

Specified by:
calculateDeadline in interface CalendarService
Parameters:
user -
start_date -
duration -
zone_offset -
Returns:
Timestamp
Throws:
WTException

calculateDeadline

public Timestamp calculateDeadline(WTPrincipalReference user,
                                   long start_date,
                                   long duration,
                                   int zone_offset)
                            throws WTException
Calculate and return the due date, as a Timestamp, for the "user" based upon the "start" date and expected "duration".

Supported API: false

Specified by:
calculateDeadline in interface CalendarService
Parameters:
user -
start_date -
duration -
zone_offset -
Returns:
Timestamp
Throws:
WTException

calculateDeadline

public Timestamp calculateDeadline(WTPrincipal user,
                                   long start_date,
                                   int nbrWorkDays,
                                   int zone_offset)
                            throws WTException
Calculates the deadline from "start" that is "nbrWorkDays" hence for "user". Returns the date as a Timestamp.

Supported API: false

Specified by:
calculateDeadline in interface CalendarService
Parameters:
user -
start_date -
nbrWorkDays -
zone_offset -
Returns:
Timestamp
Throws:
WTException

calculateDeadline

public Timestamp calculateDeadline(WTPrincipalReference user,
                                   long start_date,
                                   int nbrWorkDays,
                                   int zone_offset)
                            throws WTException
Calculates the deadline from "start" that is "nbrWorkDays" hence for "user". Returns the date as a Timestamp.

Supported API: false

Specified by:
calculateDeadline in interface CalendarService
Parameters:
user -
start_date -
nbrWorkDays -
zone_offset -
Returns:
Timestamp
Throws:
WTException

performStartupProcess

protected void performStartupProcess()
                              throws ManagerException
Description copied from class: StandardManager
Dummy method to be overridden by subclasses. Subclasses should override this method and provide startup processing.

Supported API: false

Overrides:
performStartupProcess in class StandardManager
Throws:
ManagerException

convertTimestampToCalendar

public GregorianCalendar convertTimestampToCalendar(Timestamp t)

convertCalendarToTimestamp

public Timestamp convertCalendarToTimestamp(Calendar tmpCal)

convertTimestampTo_long

public long convertTimestampTo_long(Timestamp t)

convert_longToTimestamp

public Timestamp convert_longToTimestamp(long l)

convertCalendarTo_long

public long convertCalendarTo_long(Calendar tmpCal)

convert_long_ToCalendar

public GregorianCalendar convert_long_ToCalendar(long l)

checkCyclicDelegate

public boolean checkCyclicDelegate(WTPrincipalReference user,
                                   WTPrincipalReference delegate,
                                   long start_date,
                                   long end_date)

removeFromCache

private void removeFromCache(WTPrincipalReference prinRef)
                      throws WTException
Throws:
WTException

removeFromCache

private void removeFromCache(WTCalendar userCalendar)
                      throws WTException
Throws:
WTException