Class CronTriggerFactory
- All Implemented Interfaces:
com.inet.plugin.NamedExtension
CronTrigger
components.- Since:
- taskplanner 3.0
- See Also:
-
CronTrigger
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Name of the Cron trigger to use as extension name in theTriggerDefinition
static final String
The cron expression which determines the time when this trigger will start the task. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected com.inet.taskplanner.server.api.trigger.cron.CronTrigger
createInstanceFrom
(TriggerDefinition definition, com.inet.id.GUID taskID) Construct a component (PRODUCT) from the given definition.getInformation
(com.inet.id.GUID taskID) Returns an information object about components which can be produced with this factory.static List<SummaryEntry>
getNextExecutionsAsSummary
(List<ZonedDateTime> nextExecutions) FOR INTERNAL USE ONLY.static List<ZonedDateTime>
getNextExecutionsForCronExpression
(String cronExpression) FOR INTERNAL USE ONLY.static List<ZonedDateTime>
getNextExecutionsForCronExpression
(String cronExpression, ZonedDateTime startDate, Predicate<ZonedDateTime> acceptDate) FOR INTERNAL USE ONLY.static String
getNextExecutionsSummaryText
(List<ZonedDateTime> nextExecutionDates) FOR INTERNAL USE ONLY.getNextExecutionTimes
(TriggerDefinition definition) Returns the calculated time of the next executions.getSummary
(TriggerDefinition definition) Construct Summary infos for the component represented by given definition.updateValues
(TriggerDefinition definition, com.inet.id.GUID taskID) Update values according to the give definition.void
validate
(TriggerDefinition definition, com.inet.id.GUID taskID) Validate the given definition.static String
validateCronExpression
(String cronExpression) FOR INTERNAL USE ONLY.Methods inherited from class com.inet.taskplanner.server.api.common.SeriesIndependentFactory
createFrom
Methods inherited from class com.inet.taskplanner.server.api.common.AbstractFactory
checkDefinitionArgument, createInstanceFrom, getExtensionName, isAvailable
-
Field Details
-
EXTENSION_NAME
Name of the Cron trigger to use as extension name in theTriggerDefinition
- See Also:
-
PROP_CRON_EXPRESSION
The cron expression which determines the time when this trigger will start the task.Format:
[minute] [hour] [dayOfMonth] [month] [dayOfWeek] [year]
One of dayOfMonth and dayOfWeek must be '?' and year can be omitted.Example:
TriggerDefinition cron = new TriggerDefinition(CronTriggerFactory.EXTENSION_NAME); cron.setProperty(CronTriggerFactory.PROP_CRON_EXPRESSION, "30 10 ? * 2"); //at 10:30 on each Monday
- See Also:
-
-
Constructor Details
-
CronTriggerFactory
public CronTriggerFactory()Creates a new nice CronTriggerFactory instance.- Since:
- taskplanner 3.0
-
-
Method Details
-
getInformation
Returns an information object about components which can be produced with this factory.The returned info contains information about how such a component is to be presented in the taskPlanner GUI. This are display-infos or available options to configure. The returned information contains
fields
which describes the values a user can specify in the WEB GUI. The field is also responsible to replace any placeholders for the corresponding property in aserial
task. That means properties without a field definition will not get any series placeholder replaced.If you implement a factory for a component only to be used by API, only then you can return null here.
- Specified by:
getInformation
in classAbstractFactory<com.inet.taskplanner.server.api.trigger.cron.CronTrigger,
TriggerDefinition, TriggerInfo, SummaryInfo> - Parameters:
taskID
- the ID of the task the definition belongs or will belong to, for optional use. Can be null if the operation is done for a non-saved task.- Returns:
- an information object for components this factory can produce
-
updateValues
Update values according to the give definition.The given definition is guaranteed to belong to this factory
- Overrides:
updateValues
in classSeriesIndependentFactory<com.inet.taskplanner.server.api.trigger.cron.CronTrigger,
TriggerDefinition, TriggerInfo, SummaryInfo> - Parameters:
definition
- the definition with the current propertiestaskID
- the ID of the task the definition belongs or will belong to, for optional use- Returns:
- a map of property key with their values that have changed
-
getNextExecutionsSummaryText
FOR INTERNAL USE ONLY.
Generates the text of the next executions- Parameters:
nextExecutionDates
- list of next execution dates to get the summary text for- Returns:
- the next executions text
-
validate
public void validate(TriggerDefinition definition, com.inet.id.GUID taskID) throws ValidationException Validate the given definition.The given definition is guaranteed to belong to this factory
- Specified by:
validate
in classSeriesIndependentFactory<com.inet.taskplanner.server.api.trigger.cron.CronTrigger,
TriggerDefinition, TriggerInfo, SummaryInfo> - Parameters:
definition
- the definition to validatetaskID
- the ID of the task the definition belongs or will belong to, for optional use. Can be null if the operation is done for a non-saved task.- Throws:
ValidationException
- if the component has some errors
-
validateCronExpression
FOR INTERNAL USE ONLY. Validate the given cron expression and returns the error message.- Parameters:
cronExpression
- the expression to validate- Returns:
- Message describing the error in the expression. Null if expression is ok. Message may also say that expression is null.
-
createInstanceFrom
protected com.inet.taskplanner.server.api.trigger.cron.CronTrigger createInstanceFrom(TriggerDefinition definition, com.inet.id.GUID taskID) Construct a component (PRODUCT) from the given definition.- Overrides:
createInstanceFrom
in classAbstractFactory<com.inet.taskplanner.server.api.trigger.cron.CronTrigger,
TriggerDefinition, TriggerInfo, SummaryInfo> - Parameters:
definition
- the definition holding information for the PRODUCTtaskID
- the ID of the task the definition belongs or will belong to, for optional use. Can be null if the operation is done for a non-saved task.- Returns:
- a new PRODUCT
-
getSummary
Construct Summary infos for the component represented by given definition.The summary info is used when the webgui displays the component.
When implementing a factory for a component only to be used per API, only then you can return null here.
- Specified by:
getSummary
in classAbstractFactory<com.inet.taskplanner.server.api.trigger.cron.CronTrigger,
TriggerDefinition, TriggerInfo, SummaryInfo> - Parameters:
definition
- the definition with the settings made by a user- Returns:
- summary infos containing text lines to be displayed in the webgui for this component.
-
getNextExecutionTimes
Returns the calculated time of the next executions. If the trigger is e.g. event based and does not provide a time,null
is returned. In case time based trigger is configured incorrectly or does not have any future executions, then an empty list is returned.- Overrides:
getNextExecutionTimes
in classTriggerFactory<com.inet.taskplanner.server.api.trigger.cron.CronTrigger>
- Parameters:
definition
- the current definition where to get the next executions for- Returns:
- the calculated time of the next execution. Normally 3 future executions are returned, or less if there are not 3 more from now.
-
getNextExecutionsAsSummary
FOR INTERNAL USE ONLY. Create a List withinfos
for the next executions which will come from the given cron expression starting at given Date.- Parameters:
nextExecutions
- list of next execution dates to get the summary text for- Returns:
- List with summary infos, can be empty. Is also empty if the cronExpression is null or empty.
- See Also:
-
getNextExecutionsForCronExpression
FOR INTERNAL USE ONLY. Get the date of the next executions for the given cron expression fromnow
.- Parameters:
cronExpression
- the expression to analyse- Returns:
- list with future executions. Can be empty if there are no future executions or the expression is invalid or null.
-
getNextExecutionsForCronExpression
public static List<ZonedDateTime> getNextExecutionsForCronExpression(String cronExpression, ZonedDateTime startDate, @Nullable Predicate<ZonedDateTime> acceptDate) FOR INTERNAL USE ONLY. Get the date of the next executions for the given cron expression from the the given date on.- Parameters:
cronExpression
- the expression to analysestartDate
- date when he next executions are to findacceptDate
- optional filter which will be applied on next execution date. Each next execution will be checked with this, and the filter declines the date, then that date will not be used as next execution date. It continues until enough next dates have passed the filter. BEWARE of possible endless loops!- Returns:
- list with future executions. Can be empty if there are no future executions or the expression is invalid or null.
-