Package com.inet.taskplanner.server.api
Class TaskDefinition
java.lang.Object
com.inet.taskplanner.server.api.TaskDefinition
This represents the settings of a task. It contains
triggers
, jobs
and actions
.
A TaskDefinition can easily be instantiated and modified. Use TaskPlanner.addTask(TaskDefinition, GUID)
to save new
Tasks.
It is recommended to use Builder classes to construct new Definitions for triggers
,
jobs
and actions
, but you can also construct them manually by
using the properties described in the corresponding factory.
Example:
TaskDefinition task = new TaskDefinition( "Send Reports every Week" );
task.setDescription( "Send the request report every two weeks to steve" );
TriggerDefinition triggerDefinition = new TimeTriggerBuilder().withHourAndMinute( 10, 00 ).withRepeating( RepeatInterval.WEEKLY ).create();
task.addTrigger( triggerDefinition );
//manually
JobDefinition job = new JobDefinition( ReportJobFactory.EXTENSION );
job.setProperty( UrlConstants.REPORTS, "file:C:/report/request.rpt" );
job.setProperty( UrlConstants.EXPORT_FMT, Engine.EXPORT_HTML );
task.addJob( job );
ResultActionDefinition emailAction = new EmailResultActionBuilder( "Request Report", "This is the weekly request report. --- CompanyName Inc.---", "steve@companyname.com", "david@companyname.com" ).create();
task.addResultAction( emailAction );
TaskPlanner.getInstance().addTask( task, "CompanyName Inc." );
Changes in existing task
's definition must be saved using
TaskPlanner.updateTask(com.inet.id.GUID, TaskDefinition)
.
- Since:
- taskplanner 3.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddJob
(JobDefinition definition) Adds a job to this task by its definition.addResultAction
(ResultActionDefinition definition) Adds a result action to this task by its definition.addTrigger
(TriggerDefinition definition) Adds a trigger to this task by its definition.Create a deep copy of this model.boolean
Returns the description for this task.getJobs()
Get the list of jobs configured in this task.getName()
Get the display name of this task.Get the list of result actions configured in this task.Get the optional series of this task.Get the list of triggers configured in this task.int
hashCode()
boolean
Returns whether this task is activated.boolean
removeJob
(JobDefinition definition) Removes a job from this task.boolean
removeResultAction
(ResultActionDefinition definition) Removes a result action from this task.boolean
removeTrigger
(TriggerDefinition definition) Removes a trigger from this task.void
setActivated
(boolean activated) Mark this task as activated.void
setDescription
(String description) Use this method to set the description of the task.void
Set the display name of this task.void
setSeries
(SeriesDefinition series) Set the optional series definition of this task.void
validate()
Validate all settings from this task.
This includes jobs with conditions, triggers, actions, series.void
validate
(com.inet.id.GUID taskID) Validate all settings from this task.
This includes jobs with conditions, triggers, actions, series.
-
Constructor Details
-
TaskDefinition
Creates a new TaskModel instance.- Parameters:
name
- the display name for this task- Throws:
IllegalArgumentException
- if the given name is null- Since:
- taskplanner 3.0
-
-
Method Details
-
isActivated
public boolean isActivated()Returns whether this task is activated. This means it's trigger are active.- Returns:
- true if this task is activated
- Since:
- taskplanner 3.0
-
setActivated
public void setActivated(boolean activated) Mark this task as activated. Keep in mind that this method does not save the task inTaskPlanner
.- Parameters:
activated
- the activated state to be set- Since:
- taskplanner 3.0
-
getName
Get the display name of this task.- Returns:
- the display name of this task
- Since:
- taskplanner 3.0
-
setName
Set the display name of this task.- Parameters:
name
- the display name- Throws:
IllegalArgumentException
- if the given name is null- Since:
- taskplanner 3.0
-
getDescription
Returns the description for this task. Can be null if no description was set.- Returns:
- The task description. Can be null.
- Since:
- taskplanner 3.0
- See Also:
-
setDescription
Use this method to set the description of the task.- Parameters:
description
- A description of the task.- Throws:
IllegalArgumentException
- if the description is null.- Since:
- taskplanner 3.0
- See Also:
-
getSeries
Get the optional series of this task.- Returns:
- the series definition
- Since:
- taskplanner 3.0
-
setSeries
Set the optional series definition of this task.- Parameters:
series
- the series- Since:
- taskplanner 3.0
-
getTriggers
Get the list of triggers configured in this task. This list is immutable, to add or remove triggers please useaddTrigger(TriggerDefinition)
andremoveTrigger(TriggerDefinition)
- Returns:
- the list of triggers
- Since:
- taskplanner 3.0
-
addTrigger
Adds a trigger to this task by its definition. Please refer toTriggerDefinition
on how to create a valid trigger definition.- Parameters:
definition
- the definition for the new trigger- Returns:
- this instance to allow chaining
- Since:
- taskplanner 3.0
-
removeTrigger
Removes a trigger from this task. This requires the passed trigger to be equal to a trigger in the task to have any effect.- Parameters:
definition
- the definition of the trigger to remove- Returns:
true
if the trigger was actually removed- Since:
- taskplanner 3.0
-
getJobs
Get the list of jobs configured in this task. This list is immutable, to add or remove please useaddJob(JobDefinition)
andremoveJob(JobDefinition)
- Returns:
- the list of jobs
- Since:
- taskplanner 3.0
-
addJob
Adds a job to this task by its definition. Please refer toJobDefinition
on how to create a valid job definition.- Parameters:
definition
- the definition for the new job- Returns:
- this instance to allow chaining
- Since:
- taskplanner 3.0
-
removeJob
Removes a job from this task. This requires the passed job to be equal to a job in the task to have any effect.- Parameters:
definition
- the definition of the job to remove- Returns:
true
if the job was actually removed- Since:
- taskplanner 3.0
-
getResultActions
Get the list of result actions configured in this task. This list is immutable, to add or remove please useaddResultAction(ResultActionDefinition)
andremoveResultAction(ResultActionDefinition)
- Returns:
- the list of jobs
- Since:
- taskplanner 3.0
-
addResultAction
Adds a result action to this task by its definition. Please refer toResultActionDefinition
on how to create a valid result action definition.- Parameters:
definition
- the definition for the new result action- Returns:
- this instance to allow chaining
- Since:
- taskplanner 3.0
-
removeResultAction
Removes a result action from this task. This requires the passed result action to be equal to a result action in the task to have any effect.- Parameters:
definition
- the definition of the result action to remove- Returns:
true
if the result action was actually removed- Since:
- taskplanner 3.0
-
copyTaskModel
Create a deep copy of this model.- Returns:
- the copy of this model
- Since:
- taskplanner 3.0
-
hashCode
public int hashCode() -
equals
-
validate
Validate all settings from this task.
This includes jobs with conditions, triggers, actions, series.- Throws:
ValidationException
- if some problems are found. The Exception contains all found errors.- Since:
- taskplanner 3.0
-
validate
Validate all settings from this task.
This includes jobs with conditions, triggers, actions, series.- Parameters:
taskID
- the ID of the task this model belongs to. Can be null. In most of the cases it does not make any difference whether passing the taskID or not. Only in special constellations where the components (trigger, job, resultAction) somehow reference other tasks you may get a more precise validation result with a taskID. E.g. theNextTaskResultAction
may not reference the own task.- Throws:
ValidationException
- if some problems are found. The Exception contains all found errors.- Since:
- taskplanner 3.0
-