Package com.inet.taskplanner.server.api
Class TaskDefinition
- java.lang.Object
-
- com.inet.taskplanner.server.api.TaskDefinition
-
@JsonData public class TaskDefinition extends java.lang.Object
This represents the settings of a task. It containstriggers
,jobs
andactions
.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
andactions
, 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 usingTaskPlanner.updateTask(com.inet.id.GUID, TaskDefinition)
.- Since:
- taskplanner 3.0
- See Also:
TriggerDefinition
,JobDefinition
,ResultActionDefinition
-
-
Constructor Summary
Constructors Constructor Description TaskDefinition(java.lang.String name)
Creates a new TaskModel instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TaskDefinition
addJob(JobDefinition definition)
Adds a job to this task by its definition.TaskDefinition
addResultAction(ResultActionDefinition definition)
Adds a result action to this task by its definition.TaskDefinition
addTrigger(TriggerDefinition definition)
Adds a trigger to this task by its definition.TaskDefinition
copyTaskModel()
Create a deep copy of this model.boolean
equals(java.lang.Object obj)
java.lang.String
getDescription()
Returns the description for this task.java.util.List<JobDefinition>
getJobs()
Get the list of jobs configured in this task.java.lang.String
getName()
Get the display name of this task.java.util.List<ResultActionDefinition>
getResultActions()
Get the list of result actions configured in this task.SeriesDefinition
getSeries()
Get the optional series of this task.java.util.List<TriggerDefinition>
getTriggers()
Get the list of triggers configured in this task.int
hashCode()
boolean
isActivated()
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(java.lang.String description)
Use this method to set the description of the task.void
setName(java.lang.String name)
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.
-
-
-
Method Detail
-
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
public java.lang.String getName()
Get the display name of this task.- Returns:
- the display name of this task
- Since:
- taskplanner 3.0
-
setName
public void setName(@Nonnull java.lang.String name)
Set the display name of this task.- Parameters:
name
- the display name- Throws:
java.lang.IllegalArgumentException
- if the given name is null- Since:
- taskplanner 3.0
-
getDescription
public java.lang.String 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(String)
-
setDescription
public void setDescription(java.lang.String description)
Use this method to set the description of the task.- Parameters:
description
- A description of the task.- Throws:
java.lang.IllegalArgumentException
- if the description is null.- Since:
- taskplanner 3.0
- See Also:
getDescription()
-
getSeries
@Nullable public SeriesDefinition getSeries()
Get the optional series of this task.- Returns:
- the series definition
- Since:
- taskplanner 3.0
-
setSeries
public void setSeries(@Nullable SeriesDefinition series)
Set the optional series definition of this task.- Parameters:
series
- the series- Since:
- taskplanner 3.0
-
getTriggers
@Nonnull public java.util.List<TriggerDefinition> 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
@Nonnull public TaskDefinition addTrigger(@Nullable TriggerDefinition definition)
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
public boolean removeTrigger(@Nullable TriggerDefinition definition)
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
@Nonnull public java.util.List<JobDefinition> 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
@Nonnull public TaskDefinition addJob(@Nullable JobDefinition definition)
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
public boolean removeJob(@Nullable JobDefinition definition)
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
@Nonnull public java.util.List<ResultActionDefinition> 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
@Nonnull public TaskDefinition addResultAction(@Nullable ResultActionDefinition definition)
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
public boolean removeResultAction(@Nullable ResultActionDefinition definition)
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
public TaskDefinition copyTaskModel()
Create a deep copy of this model.- Returns:
- the copy of this model
- Since:
- taskplanner 3.0
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
validate
public void validate() throws ValidationException
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
public void validate(com.inet.id.GUID taskID) throws ValidationException
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
-
-