Class JobFactory<T extends Job>
- java.lang.Object
-
- com.inet.taskplanner.server.api.common.AbstractFactory<COMPONENT,DEFINITION,INFO,SUMMARY>
-
- com.inet.taskplanner.server.api.common.SeriesDependentFactory<T,JobDefinition,JobInfo,JobSummaryInfo>
-
- com.inet.taskplanner.server.api.job.JobFactory<T>
-
- Type Parameters:
T
- the concrete type of the Job implementation
- All Implemented Interfaces:
com.inet.plugin.NamedExtension
public abstract class JobFactory<T extends Job> extends SeriesDependentFactory<T,JobDefinition,JobInfo,JobSummaryInfo>
Base class for factories producingJob
components.JobDefinition
----> JobFactory ---->Job
AbstractFactory
for more information about the life cycle.When a factory is implemented, use
ServerPluginManager.register(Class, Object)
withJobFactory
.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 Constructor Description JobFactory(java.lang.String extensionName)
Creates a new JobFactory instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract java.util.List<ResultFlavor>
getResultFlavors(JobDefinition definition)
Returns the list of supported flavors.protected JobDefinition
patchDefinitionProperties(JobDefinition baseDefinition, java.util.Map<java.lang.String,java.lang.String> seriesProperties, com.inet.id.GUID taskID)
Patch the properties of the given baseDefinition with properties from the seriesProperties.protected abstract void
validateCondition(JobDefinition definition)
Validate the condition.void
validateCondition(JobDefinition definition, SeriesDefinition seriesDefinition, 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
-
-
-
-
Method Detail
-
getResultFlavors
public abstract java.util.List<ResultFlavor> getResultFlavors(JobDefinition definition)
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 JobDefinition definition, @Nullable SeriesDefinition seriesDefinition, @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, java.util.Map<java.lang.String,java.lang.String> seriesProperties, @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 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
-
-