com.arsdigita.workflow.simple
Class Task

java.lang.Object
  extended bycom.arsdigita.domain.DomainObject
      extended bycom.arsdigita.domain.ObservableDomainObject
          extended bycom.arsdigita.kernel.ACSObject
              extended bycom.arsdigita.auditing.AuditedACSObject
                  extended bycom.arsdigita.workflow.simple.Task
All Implemented Interfaces:
Audited, Cloneable
Direct Known Subclasses:
UserTask, Workflow

public class Task
extends AuditedACSObject
implements Cloneable

This class represents the properties of a Task. Some programming guidelines to follow:

Author:
Karl Goldstein, Uday Mathur, Khy Huang, Stefan Deusch

Field Summary
static String BASE_DATA_OBJECT_TYPE
           
static int DELETED
           
static int DISABLED
           
static int ENABLED
           
static int FINISHED
           
static int INACTIVE
           
static String versionId
           
 
Fields inherited from class com.arsdigita.kernel.ACSObject
CONTAINER, DEFAULT_DOMAIN_CLASS, DISPLAY_NAME, ID, OBJECT_TYPE
 
Constructor Summary
  Task()
          Creates a new task.
  Task(BigDecimal id)
          Creates a new task for a given ID.
  Task(DataObject taskDataObject)
          Restores a task from a data object.
protected Task(ObjectType type)
          Creates a new task given the object type.
  Task(OID oid)
          Creates a new task for a given OID.
protected Task(String typeName)
          Creates a new task given the object type name.
  Task(String label, String description)
          Creates a new task.
 
Method Summary
 void addComment(String comment)
          Adds a comment specifying the description string (persistent after save).
 void addComment(TaskComment c)
          Adds a comment (persistent after save).
 void addComment(User user, String comment)
          Adds a comment specifying the user (persistent after save).
 boolean addDependency(Task task)
          Adds a dependency to this task.
 void addFinishedListener(Task task)
          Adds a task as a listener to this task.
 Object clone()
          Clones a task.
protected  void copyAttributes(Task task)
          Exports the attributes of this domain object.
 void delete()
          Deletes this object.
 void disable()
          Disables a task.
protected  void disableEvt()
          Called when a task is disabled.
 void enable()
          Enables a task and calls enableEvt, which is overwritten by subclasses to extend functionality.
protected  void enableEvt()
          Called when the task is enabled.
 boolean equals(Object object)
          An object is equal to this if the object is of type task and the IDs are the same.
 void finish()
          Marks the task as finished.
protected  void finishEvt()
          Called when a task is finished.
protected  String getBaseDataObjectType()
          Retrieves the type of the base data object.
 Iterator getComments()
          Returns an iterator over a set of task comments.
 int getCommentsSize()
          Gets the number of comments.
 Iterator getDependencies()
          Retrieves the task dependencies.
 int getDependencyCount()
          Retrieves the number of dependencies.
 String getDescription()
          Gets the task description.
 String getDisplayName()
          Returns a display name for this object.
 Iterator getFinishedListeners()
          Returns the list of finished listeners.
 int getFinishedListenersCount()
          Returns the number of finished listeners
protected  Collection getFinishedListenersInternal()
          Retrieves the finished listeners.
 String getLabel()
          Gets the label for this task.
protected  TaskComment getLastComment()
          Get the last comment that was added to this Task
protected  TaskComment getLastCommentInWorkflow()
          Get the last comment that was added to any task in this Workflow
 BigDecimal getParentID()
          The ID of the process that this task is in.
 TaskCollection getRequiredTasks()
           
 int getState()
          Get the state of a task.
static int getStateMapping(String taskState)
          Helper method to convert from persistent representation to object representation
 String getStateString()
          Gets the state in a string for the task.
static String getStateString(int state)
          Helper method to convert from object presentation to persistent presentation
 Workflow getWorkflow()
          Get the Workflow that this Task is in
protected  void initAttributes(String label, String description)
          Sets the label and dDescription for this task.
protected  void initialize()
          Initializes a task.
 boolean isActive()
          Checks whether the task part of the active process.
 boolean isDependency(Task task)
          Checks whether this task depends directly on another task.
 boolean isEnabled()
          Tests whether the task is enabled.
 boolean isFinished()
          Tests whether the task is finished.
 void notifyFinished(Task senderTask)
          Notifies finished listeners.
 void removeAllDependencies()
          Removes all dependencies from this task.
 void removeAllFinishedListeners()
          Removes all dependencies from this task.
 void removeComment(TaskComment taskComment)
          Removes comment (persistent after save).
 void removeDependency(Task task)
          Removes a dependency from this task.
 void removeFinishedListener(Task task)
          Removes a task from the list of listeners.
protected  void rollbackEvt()
          When the task is moved from enabled to disabled state.
 void setActive(boolean isActive)
          Marks this task as active, which indicates that it is fully configured and ready to become part of an active process.
 void setDescription(String description)
          Sets the task description.
 void setLabel(String label)
          Sets the label for this task.
 void setState(int state)
           DO NOT USE Should be private.
 String toString()
          Returns a string describing the task.
 
Methods inherited from class com.arsdigita.auditing.AuditedACSObject
getCreationDate, getCreationIP, getCreationUser, getLastModifiedDate, getLastModifiedIP, getLastModifiedUser
 
Methods inherited from class com.arsdigita.kernel.ACSObject
assertPrivilege, beforeSave, checkPrivilege, doCreateCheck, doWriteCheck, getContainer, getDefaultDomainClass, getID, getSpecificObjectType, getSpecificOID, gimmeContainer, isContainerModified, setID, setID
 
Methods inherited from class com.arsdigita.domain.ObservableDomainObject
addObserver, getObservers
 
Methods inherited from class com.arsdigita.domain.DomainObject
add, add, addToAssociation, afterDelete, afterSave, beforeDelete, clear, disconnect, get, getObjectType, getOID, getSession, hashCode, isDeleted, isDisconnected, isModified, isNew, isPropertyModified, isValid, remove, remove, remove, removeFromAssociation, save, set, setAssociation, setAssociation, specializeDataObject, specializeDataObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values

BASE_DATA_OBJECT_TYPE

public static final String BASE_DATA_OBJECT_TYPE
See Also:
Constant Field Values

DISABLED

public static final int DISABLED
See Also:
Constant Field Values

ENABLED

public static final int ENABLED
See Also:
Constant Field Values

FINISHED

public static final int FINISHED
See Also:
Constant Field Values

DELETED

public static final int DELETED
See Also:
Constant Field Values

INACTIVE

public static final int INACTIVE
See Also:
Constant Field Values
Constructor Detail

Task

public Task(String label,
            String description)
Creates a new task. Properties of this object are not made persistent until the save() method is called.

Parameters:
label - the task label
description - the task description

Task

public Task(DataObject taskDataObject)
Restores a task from a data object.

Parameters:
taskDataObject - the data object

Task

public Task()
Creates a new task. Properties of this object are not made persistent until the save() method is called. The properties label and description are set to null. If save() is called without setting these properties, an IllegalArgumentException will be thrown.


Task

public Task(OID oid)
     throws DataObjectNotFoundException
Creates a new task for a given OID.

Parameters:
oid - the Object ID

Task

public Task(BigDecimal id)
     throws DataObjectNotFoundException
Creates a new task for a given ID.


Task

protected Task(ObjectType type)
Creates a new task given the object type.

Parameters:
type - the object type

Task

protected Task(String typeName)
Creates a new task given the object type name.

Parameters:
typeName - the name of the type
Method Detail

initialize

protected void initialize()
Initializes a task.

Overrides:
initialize in class AuditedACSObject

initAttributes

protected void initAttributes(String label,
                              String description)
Sets the label and dDescription for this task.

Parameters:
label - the task label
description - the task description

getBaseDataObjectType

protected String getBaseDataObjectType()
Retrieves the type of the base data object.

Overrides:
getBaseDataObjectType in class ACSObject
Returns:
the basic data object type.

setLabel

public void setLabel(String label)
Sets the label for this task.

Parameters:
label - the new label for this task

getLabel

public String getLabel()
Gets the label for this task.

Returns:
the task label.

getStateString

public String getStateString()
Gets the state in a string for the task.

Returns:
the state string.

setDescription

public void setDescription(String description)
Sets the task description.

Parameters:
description - the task description

getDescription

public String getDescription()
Gets the task description.

Returns:
the task description.

setActive

public void setActive(boolean isActive)
Marks this task as active, which indicates that it is fully configured and ready to become part of an active process. (Until then, the task is still under editing.) Calls the updateState method for finished listeners to let them know that is either part of the model or not. (persistent operation)

Parameters:
isActive - true to active this task as part of an active task.

isActive

public boolean isActive()
Checks whether the task part of the active process.

Returns:
true if the task part of the active process; false otherwise.

getParentID

public BigDecimal getParentID()
The ID of the process that this task is in.

Returns:
the process ID.

getWorkflow

public Workflow getWorkflow()
Get the Workflow that this Task is in


getDependencies

public Iterator getDependencies()
Retrieves the task dependencies.

Returns:
an iterator of tasks corresponding to the dependencies of this task.

getRequiredTasks

public final TaskCollection getRequiredTasks()

addDependency

public boolean addDependency(Task task)
Adds a dependency to this task. Dependencies must be completed before this task becomes enabled.

Parameters:
task - Another task that this task depends on
Returns:
true if the task was added successfully; false otherwise.

removeDependency

public void removeDependency(Task task)
Removes a dependency from this task. (persistent operation) If the state changed, then a call to save save method is made.

Parameters:
task -

isDependency

public boolean isDependency(Task task)
Checks whether this task depends directly on another task.

Parameters:
task - the task to check
Returns:
true if this task depends on a passed in task; false otherwise.

removeAllDependencies

public void removeAllDependencies()
Removes all dependencies from this task. (persistent operation)


removeAllFinishedListeners

public void removeAllFinishedListeners()
Removes all dependencies from this task. (persistent operation)


getDependencyCount

public int getDependencyCount()
Retrieves the number of dependencies.

Returns:
the number of dependencies

equals

public boolean equals(Object object)
An object is equal to this if the object is of type task and the IDs are the same.

Overrides:
equals in class DomainObject
Parameters:
object - the object
Returns:
true if the two objects have the same OID, unless no OID info exists in which case true if they are at the same memory location (the default .equals).

clone

public Object clone()
             throws CloneNotSupportedException
Clones a task. Copies dependencies.

Throws:
CloneNotSupportedException

copyAttributes

protected void copyAttributes(Task task)
Exports the attributes of this domain object.

Parameters:
task - the domain object to which this method copies the attributes of this object

toString

public String toString()
Returns a string describing the task.

Overrides:
toString in class DomainObject

addComment

public void addComment(TaskComment c)
Adds a comment (persistent after save).

Parameters:
c - the comment to add

addComment

public void addComment(User user,
                       String comment)
Adds a comment specifying the user (persistent after save).

Parameters:
user - the user
comment - the comment

addComment

public void addComment(String comment)
Adds a comment specifying the description string (persistent after save).

Parameters:
comment - the comment

removeComment

public void removeComment(TaskComment taskComment)
Removes comment (persistent after save).

Parameters:
taskComment - the comment

getComments

public Iterator getComments()
Returns an iterator over a set of task comments.

Returns:
the comments for this task.

getCommentsSize

public int getCommentsSize()
Gets the number of comments.

Returns:
the number comments for this task.

getLastComment

protected TaskComment getLastComment()
Get the last comment that was added to this Task


getLastCommentInWorkflow

protected TaskComment getLastCommentInWorkflow()
Get the last comment that was added to any task in this Workflow


getFinishedListeners

public Iterator getFinishedListeners()
Returns the list of finished listeners.

Returns:
an iterator of listening tasks.

getFinishedListenersInternal

protected Collection getFinishedListenersInternal()
Retrieves the finished listeners. Internal: Get the finished Listeners data association

Returns:
the set of finished listeners.

addFinishedListener

public void addFinishedListener(Task task)
Adds a task as a listener to this task. This task is notified in the finish method. (persistent operation)

Parameters:
task - a listener task in the process

removeFinishedListener

public void removeFinishedListener(Task task)
Removes a task from the list of listeners. (persistent after save)

Parameters:
task - the task to remove

getFinishedListenersCount

public int getFinishedListenersCount()
Returns the number of finished listeners

Returns:
the number of finished listeners

enable

public void enable()
Enables a task and calls enableEvt, which is overwritten by subclasses to extend functionality. (persistent operation)


disable

public void disable()
Disables a task. This occurs when a task is finished. (persistent operation) TODO: need to trigger update on listeners when this is called


getState

public int getState()
Get the state of a task.

Returns:
the task state.

setState

public void setState(int state)
DO NOT USE Should be private. Sets the current state of task (persistent after save).

Parameters:
state - the state to set the task

getStateString

public static String getStateString(int state)
Helper method to convert from object presentation to persistent presentation

Returns:
the State String

getStateMapping

public static int getStateMapping(String taskState)
Helper method to convert from persistent representation to object representation

Parameters:
taskState - the state string
Returns:
the object representation

finish

public void finish()
            throws TaskException
Marks the task as finished. This operation is only valid if the task is enabled. (persistent operation)

Throws:
TaskException

isEnabled

public boolean isEnabled()
Tests whether the task is enabled.

Returns:
true if the task is enabled; falseotherwise.

isFinished

public boolean isFinished()
Tests whether the task is finished.

Returns:
true if the task is finished; otherwise.

notifyFinished

public void notifyFinished(Task senderTask)
                    throws TaskException,
                           ProcessException
Notifies finished listeners.

Parameters:
senderTask - the task that is completed
Throws:
TaskException
ProcessException

delete

public void delete()
Description copied from class: DomainObject
Deletes this object.

Overrides:
delete in class DomainObject
See Also:
DataObject.delete()

getDisplayName

public String getDisplayName()
Description copied from class: ACSObject
Returns a display name for this object. The display name is produced by domain-specific logic based on any properties of the domain object. The display name is used internally for efficient access in cursors like ACSObjectCollection. ACSObject.save() takes care of populating the internal data object's displayName property with the result of the getDisplayName method. While this method is not abstract, the default implementation is very useless. All subclasses should provide their own implementations.

Overrides:
getDisplayName in class ACSObject
Returns:
the displayable name for this object.

rollbackEvt

protected void rollbackEvt()
When the task is moved from enabled to disabled state. This method is called.


enableEvt

protected void enableEvt()
Called when the task is enabled.


disableEvt

protected void disableEvt()
Called when a task is disabled.


finishEvt

protected void finishEvt()
Called when a task is finished.



Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2337 UTC