Package com.inet.taskplanner.server.api
Class TaskDefinition
- java.lang.Object
-
- com.inet.taskplanner.server.api.TaskDefinition
-
@JsonData public class TaskDefinition extends java.lang.ObjectThis represents the settings of a task. It containstriggers,jobsandactions.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,jobsandactions, 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 TaskDefinitionaddJob(JobDefinition definition)Adds a job to this task by its definition.TaskDefinitionaddResultAction(ResultActionDefinition definition)Adds a result action to this task by its definition.TaskDefinitionaddTrigger(TriggerDefinition definition)Adds a trigger to this task by its definition.TaskDefinitioncopyTaskModel()Create a deep copy of this model.booleanequals(java.lang.Object obj)java.lang.StringgetDescription()Returns the description for this task.java.util.List<JobDefinition>getJobs()Get the list of jobs configured in this task.java.lang.StringgetName()Get the display name of this task.java.util.List<ResultActionDefinition>getResultActions()Get the list of result actions configured in this task.SeriesDefinitiongetSeries()Get the optional series of this task.java.util.List<TriggerDefinition>getTriggers()Get the list of triggers configured in this task.inthashCode()booleanisActivated()Returns whether this task is activated.booleanremoveJob(JobDefinition definition)Removes a job from this task.booleanremoveResultAction(ResultActionDefinition definition)Removes a result action from this task.booleanremoveTrigger(TriggerDefinition definition)Removes a trigger from this task.voidsetActivated(boolean activated)Mark this task as activated.voidsetDescription(java.lang.String description)Use this method to set the description of the task.voidsetName(java.lang.String name)Set the display name of this task.voidsetSeries(SeriesDefinition series)Set the optional series definition of this task.voidvalidate()Validate all settings from this task.
This includes jobs with conditions, triggers, actions, series.voidvalidate(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 toTriggerDefinitionon 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:
trueif 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 toJobDefinitionon 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:
trueif 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 toResultActionDefinitionon 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:
trueif 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:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
validate
public void validate() throws ValidationExceptionValidate 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 ValidationExceptionValidate 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. theNextTaskResultActionmay not reference the own task.- Throws:
ValidationException- if some problems are found. The Exception contains all found errors.- Since:
- taskplanner 3.0
-
-