com.waveset.object
Class TaskSchedule

java.lang.Object
  extended bycom.waveset.object.PersistentObject
      extended bycom.waveset.object.TaskSchedule
All Implemented Interfaces:
java.lang.Comparable, javax.naming.Referenceable, XmlObject

public class TaskSchedule
extends PersistentObject

A class used to maintain a "crontab" of background tasks waiting to be executed.

I thought about just having all of these in one object, but that may result in too much contention.


Nested Class Summary
static class TaskSchedule.RepetitionUnit
          An enumeration class used for values of the _repetitionUnit field, also used as an argument to the scheduling interface.
static class TaskSchedule.ResultOption
          An enumeration class used for values of the _resultOption field, used to specify how the results of prior executions of repetative tasks are handled.
 
Nested classes inherited from class com.waveset.object.PersistentObject
PersistentObject.Comparator, PersistentObject.InitialInstance
 
Field Summary
static java.util.List ANY_HOST
          A constant for the default value of Attribute.HOSTNAME.
static java.lang.String ATT_COUNT
           
static java.lang.String ATT_DAEMON
           
static java.lang.String ATT_DISABLED
           
static java.lang.String ATT_DISPLAYNAME
           
static java.lang.String ATT_MAX
           
static java.lang.String ATT_NAME
           
static java.lang.String ATT_REPC
           
static java.lang.String ATT_REPU
           
static java.lang.String ATT_RESULTOP
           
static java.lang.String ATT_SINGLETON
           
static java.lang.String ATT_SKIPMISSEDTIMES
           
static java.lang.String ATT_START
           
static java.lang.String ATT_TIME
           
static java.lang.String code_id
           
 
Fields inherited from class com.waveset.object.PersistentObject
_trace, trace
 
Constructor Summary
TaskSchedule()
          Construct a new empty configuration object.
TaskSchedule(org.w3c.dom.Element e)
          Deserialize a TaskSchedule object from XML.
 
Method Summary
 java.util.Date addOneRepetition(java.util.Date startDate)
          Add the repetition unit to a date.
 boolean doSkipMissedTimes()
          Return whether the schedule should wait until the next scheduled time when a scheduled time was missed.
protected  WSAttribute getAttributeValues(java.lang.String attrName)
           
 java.util.Date getDailyStartTime()
          Get the daily start date.
 TaskDefinition getDefinition()
          Get the task definition object.
 ObjectRef getDefinitionRef()
          Get the definition reference.
 java.lang.String getDescription()
          Get the optional task description.
 TaskDefinition getEffectiveDefinition()
          Return the associated TaskDefinition, passing through the TaskTemplate if necessary.
 int getExecutionCount()
          Get the execution count.
 ObjectGroup getGroup()
          Get the task group object.
 ObjectRef getGroupRef()
          Get the group reference.
 java.util.List getHosts()
           
static PersistentObject.InitialInstance[] getInitialInstances()
          Define an initial instance named Constants.LAST_MOD so that the repository will track modifications to objects of this type.
 int getMaxInstances()
           
 java.util.Date getNextRepetitionDate()
          Get the next date on which this task should be executed.
 Rule getNextRepetitionRule()
           
 ObjectRef getNextRepetitionRuleRef()
           
 java.util.ArrayList getReferences()
          Return the list of references within this object.
 int getRepetitionCount()
          Get the task repetition count.
 TaskSchedule.RepetitionUnit getRepetitionUnit()
          Get the task repetition unit.
 WavesetResult getResult()
          Deprecated. As of IdM 6.0 SP2 / 7.0
 TaskSchedule.ResultOption getResultOption()
          Get the result option.
 java.util.Date getStartDate()
          Get the task start date.
 Subject getSubject()
          Get the serialized authorization subject.
 java.lang.String getTaskDisplayName()
          Get the optional task display name.
 java.lang.String getTaskName()
          Get the desired task name.
 TaskTemplate getTemplate()
          Get the task template object.
 java.lang.String getTrackingId()
          Get the optional tracking id.
 Type getType()
          Return the Type object associated with this class.
 java.lang.Object getVariable(java.lang.String name)
          Get the value of one runtime variable.
 GenericObject getVariables()
          Get the runtime variables.
 boolean isDaemon()
           
 boolean isDisabled()
          Test the disabled flag.
 boolean isSingleton()
          Test the singleton flag.
 java.util.List listQueryableAttributes()
           
 java.util.List listSummaryAttributes()
          Returns the complete list of defined attributes that this type of persistent object exposes as summary attributes (regardless of whether this particular object has a value for each).
protected  void parseXml(org.w3c.dom.Element e)
          Deserialize the object from XML.
 void setDaemon(boolean b)
           
 void setDailyStartTime(java.util.Date d)
          Set the task start date.
 void setDefinition(TaskDefinition def)
          Set the task definition.
 void setDefinition(TaskTemplate tmp)
          Set the task template.
 void setDefinitionRef(ObjectRef ref)
          Set the definition reference.
 void setDescription(java.lang.String d)
          Set the optional task description.
 void setDisabled(boolean d)
          Set the disabled flag.
 void setExecutionCount(int c)
          Set the execution count.
 void setGroup(ObjectGroup group)
          Set the object group.
 void setGroupRef(ObjectRef ref)
          Set the group reference.
 void setHosts(java.util.List hosts)
          Get or set the list of hosts that this task can run on.
 void setMaxInstances(int i)
           
 void setNextRepetitionRule(Rule rule)
           
 void setNextRepetitionRuleRef(ObjectRef nextRepetitionRule)
           
 void setRepetitionCount(int c)
          Set the task repetition count.
 void setRepetitionUnit(TaskSchedule.RepetitionUnit r)
          Set the task repetition unit.
 void setResult(WavesetResult res)
          Deprecated. As of IdM 6.0 SP2 / 7.0
 void setResultOption(TaskSchedule.ResultOption o)
          Set the result option.
 void setSingleton(boolean b)
          Set the singleton flag.
 void setSkipMissedTimes(boolean b)
          Set whether the schedule should wait until the next scheduled time to run when a scheduled time was missed.
 void setStartDate(java.util.Date d)
          Set the task start date.
 void setSubject(Subject s)
          Set the authorization subject.
 void setTaskDisplayName(java.lang.String s)
          Set the optional task display name.
 void setTaskName(java.lang.String s)
          Set the desired task name.
protected  void setToStartTime(java.util.Date d)
          If there is a specified time of day to start scheduling, set the passed-in date to that time.
 void setTrackingId(java.lang.String id)
          Set an optional tracking ID.
 void setVariables(GenericObject vars)
          Set the collection of runtime variables.
 void toXml(java.lang.StringBuffer b)
          Serialize the object to XML within the given buffer.
 void visit(Visitor v)
          Visitor interface.
 
Methods inherited from class com.waveset.object.PersistentObject
addCommonElements, addEndTag, addMemberObjectGroup, addMemberObjectGroup, addPersistentAttributes, addStartTag, addSubclassAttributes, addSubclassElements, addSummaryAttributes, addXmlHeader, attributesMatch, attributesMatch, attributesMatch, checkReference, checkReferences, clearId, cloneAs, cloneObject, compareTo, create, create, create, create, createLastModItem, createLastModItem, createLastModItemList, directObjectGroupMember, dump, dumpFile, equals, fakeId, getAttribute, getAttributeValues, getAuthReferences, getAuthType, getBasicAttributes, getBasicAttributes, getBasicAttributes, getCache, getCounterValue, getCreateDate, getCreator, getDisplayableName, getDisplayName, getElementName, getEncryptedValues, getId, getIdOrName, getLastMod, getLastModDate, getLastModifier, getLastModItemId, getLockInfo, getMemberObjectGroupRefs, getMemberObjectGroupRefsUpTo, getMemberObjectGroups, getName, getNameOrId, getProperties, getProperty, getPropertyAsString, getPropertyList, getQueryableAttributes, getReference, getRuleDrivenMemberObjectGroupRefs, getRuleDrivenMemberObjectGroupRefsUpTo, getRuleDrivenMemberObjectGroups, getSubtype, getSummaryAttributes, getSummaryString, hasEncryptedData, hashCode, identityEquals, isAlias, isHidden, isId, isProtected, isProtectedFromDelete, isReferencedIn, listOperationalAttributes, listQueryableReferenceAttributes, objectGroupMember, objectGroupMemberRef, parseCommonElement, parseCommonElements, parsePersistentAttributes, parseSubclassAttributes, parseSubclassElements, parseXml, prepareForSerialization, prepareToSerialize, println, reEncrypt, reEncryptSubclassAttributes, removeMemberObjectGroup, removeProperty, resolve, resolve, resolve, resolveArray, resolveArrayByFetching, resolveObjectReference, resolveObjectReferences, resolveReference, resolveSummaryAttributes, resolveSummaryAttributes, ruleDrivenObjectGroupMemberRef, setAuthType, setAuthType, setCache, setCreateDate, setCreator, setDisplayName, setDisplayName, setHidden, setIsAlias, setLastMod, setLastMod, setLastModDate, setLastModifier, setMemberObjectGroupRef, setMemberObjectGroupRefs, setMemberObjectGroups, setName, setProperties, setProperty, setPropertyList, setProtected, setProtectedFromDelete, setRuleDrivenMembersCache, setSubtype, setTrace, toString, toXml, toXml, toXmlFile
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

code_id

public static final java.lang.String code_id
See Also:
Constant Field Values

ANY_HOST

public static final java.util.List ANY_HOST
A constant for the default value of Attribute.HOSTNAME. This value indicates that any host may run the scheduled task.


ATT_NAME

public static final java.lang.String ATT_NAME
See Also:
Constant Field Values

ATT_DISPLAYNAME

public static final java.lang.String ATT_DISPLAYNAME
See Also:
Constant Field Values

ATT_START

public static final java.lang.String ATT_START
See Also:
Constant Field Values

ATT_TIME

public static final java.lang.String ATT_TIME
See Also:
Constant Field Values

ATT_REPC

public static final java.lang.String ATT_REPC
See Also:
Constant Field Values

ATT_REPU

public static final java.lang.String ATT_REPU
See Also:
Constant Field Values

ATT_SINGLETON

public static final java.lang.String ATT_SINGLETON
See Also:
Constant Field Values

ATT_DISABLED

public static final java.lang.String ATT_DISABLED
See Also:
Constant Field Values

ATT_RESULTOP

public static final java.lang.String ATT_RESULTOP
See Also:
Constant Field Values

ATT_COUNT

public static final java.lang.String ATT_COUNT
See Also:
Constant Field Values

ATT_DAEMON

public static final java.lang.String ATT_DAEMON
See Also:
Constant Field Values

ATT_MAX

public static final java.lang.String ATT_MAX
See Also:
Constant Field Values

ATT_SKIPMISSEDTIMES

public static final java.lang.String ATT_SKIPMISSEDTIMES
See Also:
Constant Field Values
Constructor Detail

TaskSchedule

public TaskSchedule()
Construct a new empty configuration object.


TaskSchedule

public TaskSchedule(org.w3c.dom.Element e)
             throws WavesetException
Deserialize a TaskSchedule object from XML.

Method Detail

getInitialInstances

public static PersistentObject.InitialInstance[] getInitialInstances()
Define an initial instance named Constants.LAST_MOD so that the repository will track modifications to objects of this type.


getType

public Type getType()
Return the Type object associated with this class.

Specified by:
getType in class PersistentObject

getReferences

public java.util.ArrayList getReferences()
Return the list of references within this object.

Overrides:
getReferences in class PersistentObject

visit

public void visit(Visitor v)
           throws WavesetException
Visitor interface.

Overrides:
visit in class PersistentObject
Throws:
WavesetException

getDefinitionRef

public ObjectRef getDefinitionRef()
Get the definition reference.


setDefinitionRef

public void setDefinitionRef(ObjectRef ref)
Set the definition reference.


getDefinition

public TaskDefinition getDefinition()
                             throws WavesetException
Get the task definition object. This will return null if we're referencing a TaskTemplate.

Throws:
WavesetException

setTrackingId

public void setTrackingId(java.lang.String id)
Set an optional tracking ID. This ID is one of the inline parameters and can be used in queries to find related TaskSchedule objects.


getTrackingId

public java.lang.String getTrackingId()
Get the optional tracking id. This ID is one of the inline parameters and can be used in queries to find related TaskSchedule objects..


getTemplate

public TaskTemplate getTemplate()
                         throws WavesetException
Get the task template object. This will return null if we're referencing a TaskDefinition.

Throws:
WavesetException

getEffectiveDefinition

public TaskDefinition getEffectiveDefinition()
                                      throws WavesetException
Return the associated TaskDefinition, passing through the TaskTemplate if necessary.

Throws:
WavesetException

setDefinition

public void setDefinition(TaskDefinition def)
Set the task definition.


setDefinition

public void setDefinition(TaskTemplate tmp)
Set the task template.


getGroupRef

public ObjectRef getGroupRef()
Get the group reference. This is the ObjectGroup that the TaskInstance will be placed in, it is NOT the group if this object.


setGroupRef

public void setGroupRef(ObjectRef ref)
Set the group reference. This is the ObjectGroup that the TaskInstance will be placed in, it is NOT the group if this object.


getGroup

public ObjectGroup getGroup()
                     throws WavesetException
Get the task group object.

Throws:
WavesetException

setGroup

public void setGroup(ObjectGroup group)
Set the object group.


getTaskName

public java.lang.String getTaskName()
Get the desired task name.


setTaskName

public void setTaskName(java.lang.String s)
Set the desired task name.

NOTE WELL: We can't reserve the name at this point, and by the time the task gets executed, it is possible for the name to be in use. If that happens, we'll automatically add a qualifying extension, "-1", "-2", etc. but as this is expensive to calculate, you should try to pick good names, or don't use a name at all and let the system generate one.


getTaskDisplayName

public java.lang.String getTaskDisplayName()
Get the optional task display name.


setTaskDisplayName

public void setTaskDisplayName(java.lang.String s)
Set the optional task display name.


getDescription

public java.lang.String getDescription()
Get the optional task description.


setDescription

public void setDescription(java.lang.String d)
Set the optional task description.


getVariables

public GenericObject getVariables()
Get the runtime variables. Note that we retain a reference to the map, so if you modify it, the changes will be stored.


getVariable

public java.lang.Object getVariable(java.lang.String name)
Get the value of one runtime variable.


setVariables

public void setVariables(GenericObject vars)
Set the collection of runtime variables.


getStartDate

public java.util.Date getStartDate()
Get the task start date.


setStartDate

public void setStartDate(java.util.Date d)
Set the task start date.


getDailyStartTime

public java.util.Date getDailyStartTime()
Get the daily start date.


setDailyStartTime

public void setDailyStartTime(java.util.Date d)
Set the task start date.


getRepetitionUnit

public TaskSchedule.RepetitionUnit getRepetitionUnit()
Get the task repetition unit.


setRepetitionUnit

public void setRepetitionUnit(TaskSchedule.RepetitionUnit r)
Set the task repetition unit.


getRepetitionCount

public int getRepetitionCount()
Get the task repetition count.


setRepetitionCount

public void setRepetitionCount(int c)
Set the task repetition count. This is the multiple of the repetition unit that together define the interval between task executions.


doSkipMissedTimes

public boolean doSkipMissedTimes()
Return whether the schedule should wait until the next scheduled time when a scheduled time was missed.


setSkipMissedTimes

public void setSkipMissedTimes(boolean b)
Set whether the schedule should wait until the next scheduled time to run when a scheduled time was missed.


getSubject

public Subject getSubject()
Get the serialized authorization subject.


setSubject

public void setSubject(Subject s)
Set the authorization subject.


isSingleton

public boolean isSingleton()
Test the singleton flag.

This will be true if the task should not be launched if the repetition unit is short enough that the previous task doesn't compete before the next one is due to be launched.


setSingleton

public void setSingleton(boolean b)
Set the singleton flag.


isDisabled

public boolean isDisabled()
Test the disabled flag.


setDisabled

public void setDisabled(boolean d)
Set the disabled flag.


getResultOption

public TaskSchedule.ResultOption getResultOption()
Get the result option.


setResultOption

public void setResultOption(TaskSchedule.ResultOption o)
Set the result option.


getExecutionCount

public int getExecutionCount()
Get the execution count.


setExecutionCount

public void setExecutionCount(int c)
Set the execution count.


getResult

public WavesetResult getResult()
Deprecated. As of IdM 6.0 SP2 / 7.0

Get the result object. This may contain error messages if there were problems the last time we tried to launch this task.


setResult

public void setResult(WavesetResult res)
Deprecated. As of IdM 6.0 SP2 / 7.0

Set the result object. Should only be used to create the initial object.


setHosts

public void setHosts(java.util.List hosts)
Get or set the list of hosts that this task can run on. Null for any host (default)


getHosts

public java.util.List getHosts()

isDaemon

public boolean isDaemon()

setDaemon

public void setDaemon(boolean b)

getMaxInstances

public int getMaxInstances()

setMaxInstances

public void setMaxInstances(int i)

listSummaryAttributes

public java.util.List listSummaryAttributes()
Description copied from class: PersistentObject
Returns the complete list of defined attributes that this type of persistent object exposes as summary attributes (regardless of whether this particular object has a value for each).

Any subclass of PersistentObject that overrides this method should first invoke super.listSummaryAttributes() to ensure that the subclass includes summary attributes that are common to all PersistentObjects.

Any subclass that overrides this implementation must also consider the length of the summary string that will be generated from these attributes.

Overrides:
listSummaryAttributes in class PersistentObject
Returns:
the complete list of defined attributes that this type of PersistentObject exposes as summary attributes (regardless of whether this object has a value for each).

Any subclass of PersistentObject that overrides this method should first invoke super.listSummaryAttributes() to ensure that the subclass includes summary attributes that are common to all PersistentObjects.

See Also:
Constants.MAX_SUMMARY_STRING_LENGTH, PersistentObject.getSummaryString()

listQueryableAttributes

public java.util.List listQueryableAttributes()
Overrides:
listQueryableAttributes in class PersistentObject
Returns:
the complete list of defined attributes that this type of PersistentObject exposes as queryable attributes (regardless of whether this object has a value for each).

Any subclass of PersistentObject that overrides this method should first invoke super.listQueryableAttributes() to ensure that the subclass includes queryable attributes that are common to all PersistentObjects.


getAttributeValues

protected WSAttribute getAttributeValues(java.lang.String attrName)
Overrides:
getAttributeValues in class PersistentObject
Parameters:
attrName - - the name of the attribute for which to return values.
Returns:
a WSAttribute that represents the value (or values) that this object contains for the specified attribute.


addOneRepetition

public java.util.Date addOneRepetition(java.util.Date startDate)
Add the repetition unit to a date. If there is a specific time that tasks must run, bump the repition count up to daily.


setToStartTime

protected void setToStartTime(java.util.Date d)
If there is a specified time of day to start scheduling, set the passed-in date to that time. If not, do nothing.

Parameters:
d - date to set to scheduled time

getNextRepetitionDate

public java.util.Date getNextRepetitionDate()
Get the next date on which this task should be executed.

For some of the repetition units, this is simple date arithmetic, for others, e.g. WEEK & MONTH its harder since we probably shouldn't just add a number of days, they would want it to occur on the same day each week/month.

Punting for now and assuming Calendar does something reasonable.


getNextRepetitionRuleRef

public ObjectRef getNextRepetitionRuleRef()

setNextRepetitionRuleRef

public void setNextRepetitionRuleRef(ObjectRef nextRepetitionRule)

setNextRepetitionRule

public void setNextRepetitionRule(Rule rule)

getNextRepetitionRule

public Rule getNextRepetitionRule()
                           throws WavesetException
Throws:
WavesetException

toXml

public void toXml(java.lang.StringBuffer b)
Serialize the object to XML within the given buffer.

Overrides:
toXml in class PersistentObject

parseXml

protected final void parseXml(org.w3c.dom.Element e)
                       throws WavesetException
Deserialize the object from XML.

Overrides:
parseXml in class PersistentObject
Throws:
WavesetException
See Also:
PersistentObject.parseSubclassAttributes(org.w3c.dom.Element)