com.waveset.object
Class TaskTemplate

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

public class TaskTemplate
extends PersistentObject
implements XmlObject

A class used to maintain a collection of task launch parameters. These can be stored in the repository to capture complex task inputs for repeated execution. They may also be constructed on the fly as a mechanism to pass task launch arguments through the various layers of the system.

Complex tasks may require the user to specify many input variables before they can be launched. Often, a task needs to be launched repeatedly with a certain set of inputs. Rather that requiring the user to enter those inputs every time the task is launched, the inputs can be encapsulated in a TaskTemplate object and stored. Later, the template can be used to launch the task, elimininating some or all of the user interaction.

This is a generalization of the concept first implemented by the UsageReport object, which was used to encapsulate inputs passed to report generation tasks. Since the concept can be useful for any task, it made sense to generalize it so we don't have to invent new storage Types for each task's input collection.

The class overlaps a bit with the TaskSchedule class which is used to represent "crontab" entries for tasks scheduled to run in the furture. It would be good if TaskSchedule were retooled to contain a TaskTemplate to avoid duplication.

I made it this a real Type rather than a Configuration extension so we can associate authorization with it more easily, and if necessary define template subtypes for more granular control. It is also an XmlObject so that it may be embedded inside other things more easily. It would be good if PersistentObject could evolve to extended AbstractXmlObject.


Nested Class Summary
 
Nested classes inherited from class com.waveset.object.PersistentObject
PersistentObject.Comparator, PersistentObject.InitialInstance
 
Field Summary
static java.lang.String code_id
           
 
Fields inherited from class com.waveset.object.PersistentObject
_trace, trace
 
Constructor Summary
TaskTemplate()
          Construct a new empty template object.
TaskTemplate(org.w3c.dom.Element e)
          Deserialize a TaskSchedule object from XML.
TaskTemplate(TaskDefinition def)
          Create a TaskTemplate based on a TaskDefinition.
TaskTemplate(TaskSchedule sched)
          Until TaskSchedule embeds a TaskTemplate, we've got to perform this little value dance to build a template from a schedule entry.
 
Method Summary
protected  void addSubclassAttributes(java.lang.StringBuffer b)
          Each concrete subclass may append to the buffer an XML representation of any fields it adds to PersistentObject (if those field values must persist).
protected  void addSubclassElements(java.lang.StringBuffer b)
          Each concrete subclass may append to the buffer an XML representation of any fields it adds to PersistentObject (if those field values must persist).
 void assimilateVariables(GenericObject vars, boolean override)
          Assimilates a set of variables into this templates set of variables.
protected  WSAttribute getAttributeValues(java.lang.String attrName)
           
 TaskDefinition getDefinition()
          Resolve the task definition.
 java.lang.String getDefinitionName()
           
 ObjectRef getDefinitionRef()
           
 java.lang.String getDescription()
           
 TaskDefinition.ExecMode getExecMode()
           
 Form getForm()
           
 ObjectRef getFormRef()
           
 ObjectGroup getGroup()
          Resolve the group reference.
 ObjectRef getGroupRef()
           
 java.util.List getHosts()
           
 TaskDefinition.ExecMode getMode()
          Deprecated. use getExecMode instead
 java.lang.String getOwner()
           
 java.util.ArrayList getReferences()
          Return the list of references within this object.
 WavesetResult getResult()
           
 Subject getSubject()
           
 java.lang.String getTaskDisplayName()
           
 java.lang.String getTaskName()
           
 java.lang.String getTaskType()
           
 java.lang.String getTaskTypeDisplayName()
           
 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 input variable.
 GenericObject getVariables()
           
 java.lang.String getVisibility()
           
 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 parseSubclassAttributes(org.w3c.dom.Element e)
          Each concrete subclass should parse from the XML buffer any persisted subclass-specific fields (generally, the same ones that it writes into the buffer).
protected  void parseSubclassElements(org.w3c.dom.Element e)
          Each concrete subclass should parse from the XML buffer any persisted subclass-specific elements (generally, the same ones that it writes into the buffer).
 void setDefinition(TaskDefinition def)
          Set the task definition.
 void setDefinitionRef(ObjectRef ref)
           
 void setDescription(java.lang.String s)
          Set the optional description.
 void setExecMode(java.lang.String s)
           
 void setExecMode(TaskDefinition.ExecMode mode)
           
 void setFormRef(ObjectRef ref)
           
 void setGroup(ObjectGroup g)
          Set the object group.
 void setGroup(java.lang.String name)
           
 void setGroupRef(ObjectRef ref)
           
 void setHosts(java.util.List l)
           
 void setMode(java.lang.String s)
          Deprecated. - use setExecMode().
 void setMode(TaskDefinition.ExecMode mode)
          Deprecated. - use setExecMode().
 void setOwner(java.lang.String owner)
          Set the task owner as an anonymous name.
 void setResult(WavesetResult res)
          Set the initial result.
 void setSubject(java.lang.String s)
          Set the subject from a serialized string.
 void setSubject(Subject subject)
          Set the task owner from a Subject.
 void setTaskDisplayName(java.lang.String s)
          Set the optional task name.
 void setTaskName(java.lang.String s)
          Set the desired task name.
 void setTaskType(java.lang.String s)
          Set the task type.
 void setTaskTypeDisplayName(java.lang.String s)
          Set the task type display name.
 void setTrackingId(java.lang.String id)
          Set an optional tracking ID.
 void setVariable(java.lang.String name, java.lang.Object value)
          Set the value of one input variable.
 void setVariables(GenericObject vars)
          Set the initial input variables.
 void setVisibility(java.lang.String s)
           
 void visit(Visitor v)
          Visitor interface.
 
Methods inherited from class com.waveset.object.PersistentObject
addCommonElements, addEndTag, addMemberObjectGroup, addMemberObjectGroup, addPersistentAttributes, addStartTag, 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, getInitialInstances, 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, parseXml, 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, toXml, toXmlFile
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.waveset.util.XmlObject
getElementName, toXml, toXml
 

Field Detail

code_id

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

TaskTemplate

public TaskTemplate()
Construct a new empty template object.


TaskTemplate

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


TaskTemplate

public TaskTemplate(TaskSchedule sched)
             throws WavesetException
Until TaskSchedule embeds a TaskTemplate, we've got to perform this little value dance to build a template from a schedule entry.


TaskTemplate

public TaskTemplate(TaskDefinition def)
             throws WavesetException
Create a TaskTemplate based on a TaskDefinition.

Method Detail

setDefinition

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


setDefinitionRef

public void setDefinitionRef(ObjectRef ref)

setTaskType

public void setTaskType(java.lang.String s)
Set the task type. This is ordinarilly the same as the definition task type, but there may be reasons to keep them different?


setTaskTypeDisplayName

public void setTaskTypeDisplayName(java.lang.String s)
Set the task type display name.


setGroup

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


setGroupRef

public void setGroupRef(ObjectRef ref)

setGroup

public void setGroup(java.lang.String 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. We might want to consider allowing name collision options in the template like we do for TaskSchedule.

The task name has to be truncated to a number of characters such that it will fit in a DB column of MAX_NAME_LENGTH bytes (on Oracle, characters elsewhere). By truncating it here we protect the database, but run the risk of setting the name to a value the caller is not expecting. There are two possible workaraounds if that is happenning, both on the callers back. 1) The caller can call getTaskname to find out what value actually got set 2) the caller can build a name using Util.truncateEncodedString() themselves to avoid the problem. Solution (1) is a little more efficient, but not always possible when the name is passed down a couple of layers before being set. In those cases solution (2) looks like your only option.


setTaskDisplayName

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


setVariables

public void setVariables(GenericObject vars)
Set the initial input variables.


assimilateVariables

public void assimilateVariables(GenericObject vars,
                                boolean override)
                         throws WavesetException
Assimilates a set of variables into this templates set of variables. The behavior of the assimilation is controlled via the override parameter.

Parameters:
vars - GenericObject containing variables to assimilate
override - when 'true' causes values from var to override those already contained in this template.
Throws:
WavesetException

setResult

public void setResult(WavesetResult res)
Set the initial result.


setSubject

public void setSubject(Subject subject)
Set the task owner from a Subject.


setSubject

public void setSubject(java.lang.String s)
                throws WavesetException
Set the subject from a serialized string.

Throws:
WavesetException

setOwner

public void setOwner(java.lang.String owner)
Set the task owner as an anonymous name.


setDescription

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


setMode

public void setMode(TaskDefinition.ExecMode mode)
Deprecated. - use setExecMode().

Set the desired execution mode.

See Also:
setExecMode(TaskDefinition.ExecMode)

setExecMode

public void setExecMode(TaskDefinition.ExecMode mode)

setMode

public void setMode(java.lang.String s)
Deprecated. - use setExecMode().

Set the desired execution mode.

See Also:
setExecMode(String)

setExecMode

public void setExecMode(java.lang.String s)

setVisibility

public void setVisibility(java.lang.String s)

getDefinition

public TaskDefinition getDefinition()
                             throws WavesetException
Resolve the task definition.

Throws:
WavesetException

getDefinitionRef

public ObjectRef getDefinitionRef()

getDefinitionName

public java.lang.String getDefinitionName()

getTaskType

public java.lang.String getTaskType()

getTaskTypeDisplayName

public java.lang.String getTaskTypeDisplayName()

getGroup

public ObjectGroup getGroup()
                     throws WavesetException
Resolve the group reference.

Throws:
WavesetException

getGroupRef

public ObjectRef getGroupRef()

getVariables

public GenericObject getVariables()

getResult

public WavesetResult getResult()

getSubject

public Subject getSubject()

getOwner

public java.lang.String getOwner()

getTaskName

public java.lang.String getTaskName()

getTaskDisplayName

public java.lang.String getTaskDisplayName()

getDescription

public java.lang.String getDescription()

getMode

public TaskDefinition.ExecMode getMode()
Deprecated. use getExecMode instead


getExecMode

public TaskDefinition.ExecMode getExecMode()

getVariable

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


setVariable

public void setVariable(java.lang.String name,
                        java.lang.Object value)
Set the value of one input variable.


getVisibility

public java.lang.String getVisibility()

getFormRef

public ObjectRef getFormRef()

setFormRef

public void setFormRef(ObjectRef ref)

getForm

public Form getForm()
             throws WavesetException
Throws:
WavesetException

getHosts

public java.util.List getHosts()

setHosts

public void setHosts(java.util.List l)

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 TaskTemplateobjects.


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 TaskTemplate objects..


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

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 suclass includes queryable attributes that are common to all PersistentObjects.


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()

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.


addSubclassAttributes

protected void addSubclassAttributes(java.lang.StringBuffer b)
Description copied from class: PersistentObject
Each concrete subclass may append to the buffer an XML representation of any fields it adds to PersistentObject (if those field values must persist). PersistentObject's default implementation is a no-op.

NOTE: Any subclass that overrides this method must similarly override parseSubclassAttributes() so that the subclass attributes are restored.

Overrides:
addSubclassAttributes in class PersistentObject
See Also:


addSubclassElements

protected void addSubclassElements(java.lang.StringBuffer b)
Description copied from class: PersistentObject
Each concrete subclass may append to the buffer an XML representation of any fields it adds to PersistentObject (if those field values must persist). PersistentObject's default implementation is a no-op.

NOTE: Any subclass that overrides this method must similarly override parseSubclassElements() so that the subclass elements are restored.

Overrides:
addSubclassElements in class PersistentObject
See Also:


parseSubclassAttributes

protected void parseSubclassAttributes(org.w3c.dom.Element e)
                                throws WavesetException
Description copied from class: PersistentObject
Each concrete subclass should parse from the XML buffer any persisted subclass-specific fields (generally, the same ones that it writes into the buffer).

Overrides:
parseSubclassAttributes in class PersistentObject
Throws:
WavesetException
See Also:

PersistentObject's default implementation is a no-op.

, PersistentObject.parseXml(Element)

parseSubclassElements

protected void parseSubclassElements(org.w3c.dom.Element e)
                              throws WavesetException
Description copied from class: PersistentObject
Each concrete subclass should parse from the XML buffer any persisted subclass-specific elements (generally, the same ones that it writes into the buffer).

Overrides:
parseSubclassElements in class PersistentObject
Throws:
WavesetException
See Also:

PersistentObject's default implementation is a no-op.

, PersistentObject.parseXml(Element)