org.openmrs.scheduler
Class TaskDefinition

java.lang.Object
  extended by org.openmrs.BaseOpenmrsObject
      extended by org.openmrs.BaseOpenmrsMetadata
          extended by org.openmrs.scheduler.TaskDefinition
All Implemented Interfaces:
Auditable, OpenmrsMetadata, OpenmrsObject, Retireable

public class TaskDefinition
extends BaseOpenmrsMetadata

Represents the metadata for a task that can be scheduled.


Constructor Summary
TaskDefinition()
          Default no-arg public constructor
TaskDefinition(java.lang.Integer id, java.lang.String name, java.lang.String description, java.lang.String taskClass)
          Public constructor
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 java.lang.Object getCreatedBy()
          Deprecated. use BaseOpenmrsMetadata.getCreator()
 java.lang.Integer getId()
          Get the task identifier.
 java.util.Date getLastExecutionTime()
          Get the time the task was last executed.
 java.util.Date getNextExecutionTime()
          Convenience method that asks SchedulerUtil for it's next execution time.
 java.util.Map<java.lang.String,java.lang.String> getProperties()
          Get the data map used to provide the task with runtime data.
 java.lang.String getProperty(java.lang.String key)
          Get task configuration property.
 java.lang.Long getRepeatInterval()
          Gets the number of seconds until task is executed again.
 long getSecondsUntilNextExecutionTime()
          Convenience method to calculate the seconds until the next execution time.
 java.lang.Boolean getStarted()
          Gets the flag that indicates whether the task has been started.
 java.lang.Boolean getStartOnStartup()
          Gets the flag that indicates whether the task should startup as soon as the scheduler starts.
 java.util.Date getStartTime()
          Get the start time for when the task should be executed.
 java.lang.String getStartTimePattern()
          Get the date format used to set the start time.
 java.lang.String getTaskClass()
          Get the schedulable object to be executed.
 Task getTaskInstance()
          Gets the runnable task instance associated with this definition.
 int hashCode()
           
 void setCreatedBy(User authenticatedUser)
          Deprecated. use BaseOpenmrsMetadata.setCreator(User)
 void setId(java.lang.Integer id)
          Set the task identifier.
 void setLastExecutionTime(java.util.Date lastExecutionTime)
          Set the time the task was last executed
 void setProperties(java.util.Map<java.lang.String,java.lang.String> properties)
          Set the properties of the task.
 void setProperty(java.lang.String key, java.lang.String value)
          Set task configuration property.
 void setRepeatInterval(java.lang.Long repeatInterval)
          Sets the number of seconds until task is executed again.
 void setStarted(java.lang.Boolean started)
          Sets the flag that indicates whether the task has been started.
 void setStartOnStartup(java.lang.Boolean startOnStartup)
          Sets the flag that indicates whether the task should startup as soon as the scheduler starts.
 void setStartTime(java.util.Date startTime)
          Set the start time for when the task should be executed.
 void setStartTimePattern(java.lang.String pattern)
          Sets the date format used to set the start time.
 void setTaskClass(java.lang.String taskClass)
          Set the schedulable object to be executed.
 void setTaskInstance(Task taskInstance)
          Sets the runnable task instance associated with this definition.
 java.lang.String toString()
           
 
Methods inherited from class org.openmrs.BaseOpenmrsMetadata
getChangedBy, getCreator, getDateChanged, getDateCreated, getDateRetired, getDescription, getName, getRetired, getRetiredBy, getRetireReason, isRetired, setChangedBy, setCreator, setDateChanged, setDateCreated, setDateRetired, setDescription, setName, setRetired, setRetiredBy, setRetireReason
 
Methods inherited from class org.openmrs.BaseOpenmrsObject
getUuid, setUuid
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.openmrs.OpenmrsObject
getUuid, setUuid
 

Constructor Detail

TaskDefinition

public TaskDefinition()
Default no-arg public constructor


TaskDefinition

public TaskDefinition(java.lang.Integer id,
                      java.lang.String name,
                      java.lang.String description,
                      java.lang.String taskClass)
Public constructor

Method Detail

getId

public java.lang.Integer getId()
Get the task identifier.

Returns:
Integer identifier of the task

setId

public void setId(java.lang.Integer id)
Set the task identifier.

Parameters:
id -

getProperties

public java.util.Map<java.lang.String,java.lang.String> getProperties()
Get the data map used to provide the task with runtime data.

Returns:
the data map

setProperties

public void setProperties(java.util.Map<java.lang.String,java.lang.String> properties)
Set the properties of the task. This overrides any properties previously set with the setProperty(String, String) method.

Parameters:
properties - Map of the properties to set

getTaskClass

public java.lang.String getTaskClass()
Get the schedulable object to be executed.

Returns:
the schedulable object

setTaskClass

public void setTaskClass(java.lang.String taskClass)
Set the schedulable object to be executed.

Parameters:
taskClass - String taskClass of a schedulable object

getStartTime

public java.util.Date getStartTime()
Get the start time for when the task should be executed.

Returns:
long start time

setStartTime

public void setStartTime(java.util.Date startTime)
Set the start time for when the task should be executed. For instance, use "new Date()", if you want it to start now.

Parameters:
startTime - start time for the task

getLastExecutionTime

public java.util.Date getLastExecutionTime()
Get the time the task was last executed.

Returns:
long last execution time

setLastExecutionTime

public void setLastExecutionTime(java.util.Date lastExecutionTime)
Set the time the task was last executed

Parameters:
lastExecutionTime - last execution time

getRepeatInterval

public java.lang.Long getRepeatInterval()
Gets the number of seconds until task is executed again.

Returns:
long number of seconds.

setRepeatInterval

public void setRepeatInterval(java.lang.Long repeatInterval)
Sets the number of seconds until task is executed again.

Parameters:
repeatInterval - number of seconds, or 0 to indicate to repetition

getStartTimePattern

public java.lang.String getStartTimePattern()
Get the date format used to set the start time.


setStartTimePattern

public void setStartTimePattern(java.lang.String pattern)
Sets the date format used to set the start time.


getStartOnStartup

public java.lang.Boolean getStartOnStartup()
Gets the flag that indicates whether the task should startup as soon as the scheduler starts.


setStartOnStartup

public void setStartOnStartup(java.lang.Boolean startOnStartup)
Sets the flag that indicates whether the task should startup as soon as the scheduler starts.


getStarted

public java.lang.Boolean getStarted()
Gets the flag that indicates whether the task has been started.


setStarted

public void setStarted(java.lang.Boolean started)
Sets the flag that indicates whether the task has been started.


getProperty

public java.lang.String getProperty(java.lang.String key)
Get task configuration property.

Parameters:
key - the String key of the property to get
Returns:
the String value for the given key

setProperty

public void setProperty(java.lang.String key,
                        java.lang.String value)
Set task configuration property. Only supports strings at the moment.

Parameters:
key - the String key of the property to set
value - the String value of the property to set

getNextExecutionTime

public java.util.Date getNextExecutionTime()
Convenience method that asks SchedulerUtil for it's next execution time.

Returns:
the Date of the next execution

getSecondsUntilNextExecutionTime

public long getSecondsUntilNextExecutionTime()
Convenience method to calculate the seconds until the next execution time.

Returns:
the number of seconds until the next execution

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

getTaskInstance

public Task getTaskInstance()
Gets the runnable task instance associated with this definition.

Returns:
related task, or null if none instantiated (definition hasn't been scheduled)

setTaskInstance

public void setTaskInstance(Task taskInstance)
Sets the runnable task instance associated with this definition. This should be set by the scheduler which instantiates the task.

Parameters:
taskInstance -

getCreatedBy

public java.lang.Object getCreatedBy()
Deprecated. use BaseOpenmrsMetadata.getCreator()


setCreatedBy

public void setCreatedBy(User authenticatedUser)
Deprecated. use BaseOpenmrsMetadata.setCreator(User)


OpenMRS-1.7.x

Generated Apr 27 2012 10:06 PM. NOTE - these libraries are in active development and subject to change