Class JobFactory<T extends Job>
- Type Parameters:
T
- the concrete type of the Job implementation
- All Implemented Interfaces:
com.inet.plugin.NamedExtension
Job
components.
See documentation ofJobDefinition
----> JobFactory ---->Job
AbstractFactory
for more information about the life cycle.
When a factory is implemented, use ServerPluginManager.register(Class, Object)
with JobFactory
.class
as first argument:
spm.register(JobFactory.class, new MouseJobFactory());
Implementations sample: because the extensionName must be unique and must be used when a JobDefinition
is
created by API, it is recommended to set up a public constant with the extensionName:
public class MouseJobFactory extends JobFactory<MouseJob> {
public static final String EXTENSION_NAME = "job.mouse";
public MouseJobFactory(){
super(EXTENSION_NAME);
}
@Override
protected MouseJob createInstanceFrom( JobDefinition definition, GUID taskID ) {
MouseJob job = new MouseJob();
//put values from definition to job impl
...
return job;
}
...
//somewhere using public API
JobDefinition mouseJob = new JobDefinition(MouseJobFactory.EXTENSION_NAME);
//configure it
...
- Since:
- taskplanner 3.0
-
Field Summary
Fields inherited from class com.inet.taskplanner.server.api.common.SeriesDependentFactory
PLACEHOLDER_END_CHARACTER, PLACEHOLDER_START_CHARACTER
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract List<ResultFlavor>
getResultFlavors
(JobDefinition definition) Returns the list of supported flavors.protected final JobDefinition
patchDefinitionProperties
(JobDefinition baseDefinition, Map<String, String> seriesProperties, @Nullable com.inet.id.GUID taskID) Patch the properties of the given baseDefinition with properties from the seriesProperties.protected abstract void
validateCondition
(@Nonnull JobDefinition definition) Validate the condition.final void
validateCondition
(@Nonnull JobDefinition definition, @Nullable SeriesDefinition seriesDefinition, @Nullable com.inet.id.GUID taskID) Validate the given condition.Methods inherited from class com.inet.taskplanner.server.api.common.SeriesDependentFactory
createFrom, getFirstValueFromSeries, updateValues, updateValues, validate
Methods inherited from class com.inet.taskplanner.server.api.common.AbstractFactory
checkDefinitionArgument, createInstanceFrom, createInstanceFrom, getExtensionName, getInformation, getSummary, isAvailable, validate
-
Constructor Details
-
JobFactory
Creates a new JobFactory instance.- Parameters:
extensionName
- the unique extensionName for this Job.- Since:
- taskplanner 3.0
-
-
Method Details
-
getResultFlavors
Returns the list of supported flavors.- Parameters:
definition
- the definition with the settings made by a user- Returns:
- the list of supported flavors.
- Since:
- taskplanner 3.0
-
validateCondition
public final void validateCondition(@Nonnull @Nonnull JobDefinition definition, @Nullable @Nullable SeriesDefinition seriesDefinition, @Nullable @Nullable com.inet.id.GUID taskID) throws ValidationException Validate the given condition.The given definition is guaranteed to belong to this factory
- Parameters:
definition
- definition of the job to validateseriesDefinition
- the series which the user have configured, if anytaskID
- 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 configured condition is not valid- Since:
- taskplanner 3.0
-
patchDefinitionProperties
protected final JobDefinition patchDefinitionProperties(JobDefinition baseDefinition, Map<String, String> seriesProperties, @Nullable @Nullable com.inet.id.GUID taskID) Patch the properties of the given baseDefinition with properties from the seriesProperties.Patch and Replacement:
Properties from seriesProperties will overwrite properties with the same name from the definition. Other new properties are added.
Placeholders in the properties will be replaced. Sth like {path} will be replaced with the value of a property 'path'. If no property 'path' exists then the placeholder is replaced with empty string.- Overrides:
patchDefinitionProperties
in classSeriesDependentFactory<T extends Job,
JobDefinition, JobInfo, JobSummaryInfo> - Parameters:
baseDefinition
- original definition from the model, this one will not be changedseriesProperties
- properties from the current series settaskID
- 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 Definition with patched properties
-
validateCondition
protected abstract void validateCondition(@Nonnull @Nonnull JobDefinition definition) throws ValidationException Validate the condition. This is only called if a condition is set.- Parameters:
definition
- definition of the job to validate. This already has patched properties from series if any.- Throws:
ValidationException
- if the configured condition is not valid- Since:
- taskplanner 3.0
-