Class SeriesDependentFactory<COMPONENT,DEFINITION extends AbstractDefinition<DEFINITION>,INFO extends AbstractInfo,SUMMARY extends SummaryInfo>
- All Implemented Interfaces:
com.inet.plugin.NamedExtension
- Direct Known Subclasses:
JobFactory
,ResultActionFactory
Series
which the user may have configured. These are
jobs
and ResultActions
. This factory changes/updates the properties of
the definition before being passed to implementation methods.
For validation
, additional the possibly set
SeriesDefinition
is required. Validation will then validate against the component's properties patches with
the first set of the series properties.
For Component instantiation
, the current properties set from the series
is required. The implementation's AbstractFactory.createInstanceFrom(AbstractDefinition,GUID)
method will then receive a
definition with already patched/updated properties.
- Since:
- taskplanner 3.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSeriesDependentFactory
(String extensionName) Creates a new SeriesFactory instance. -
Method Summary
Modifier and TypeMethodDescriptionfinal COMPONENT
createFrom
(DEFINITION definition, Map<String, String> seriesProperties, com.inet.id.GUID taskID) Creates a concrete object to be used byTaskPlanner
from given definition.
Seevalidate(AbstractDefinition, SeriesDefinition, GUID)
for what is patched and replaced.getFirstValueFromSeries
(SeriesDefinition series, com.inet.id.GUID taskID) Get the first set of properties from the given seriesprotected DEFINITION
patchDefinitionProperties
(DEFINITION baseDefinition, Map<String, String> seriesProperties, com.inet.id.GUID taskID) Patch the properties of the given baseDefinition with properties from the seriesProperties.updateValues
(DEFINITION definition, SeriesDefinition seriesDefinition, com.inet.id.GUID taskID) Update values according to the give definition.updateValues
(DEFINITION patchedDefinition, DEFINITION unpatchedDefinition, SeriesDefinition seriesDefinition, com.inet.id.GUID taskID) Update values according to the give definition.final void
validate
(DEFINITION definition, SeriesDefinition seriesDefinition, com.inet.id.GUID taskID) Validate the given definition.Methods inherited from class com.inet.taskplanner.server.api.common.AbstractFactory
checkDefinitionArgument, createInstanceFrom, createInstanceFrom, getExtensionName, getInformation, getSummary, isAvailable, validate
-
Field Details
-
PLACEHOLDER_START_CHARACTER
The official start character of placeholder- See Also:
-
PLACEHOLDER_END_CHARACTER
The official end character of placeholder- See Also:
-
-
Constructor Details
-
SeriesDependentFactory
Creates a new SeriesFactory instance.- Parameters:
extensionName
- unique name for this kind of components- Since:
- taskplanner 3.0
-
-
Method Details
-
validate
public final void validate(@Nonnull DEFINITION definition, @Nullable SeriesDefinition seriesDefinition, @Nullable com.inet.id.GUID taskID) throws ValidationException Validate the given definition. This will take the first set from the series patching the definition's properties before validating them.
Patch and Replacement:
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 not replaced. This replacement is only done for properties having a field inAbstractFactory.getInformation(GUID)
.The original definition object is not changed.
- Parameters:
definition
- the definition to validateseriesDefinition
- the series definition if one exists. If null, then no properties are added an no placeholders are replaced (also not with empty string).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.- Throws:
ValidationException
- if the component has some errors- Since:
- taskplanner 3.0
-
updateValues
@Nullable public final Map<String,String> updateValues(@Nonnull DEFINITION definition, @Nullable SeriesDefinition seriesDefinition, com.inet.id.GUID taskID) Update values according to the give definition. This will take the first set from the series patching the definition's properties before updating the values.
Patch and Replacement:
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 not replaced. This replacement is only done for properties having a field inAbstractFactory.getInformation(GUID)
.The original definition object is not changed.
The given definition is guaranteed to belong to this factory
- Parameters:
definition
- the definition with the current propertiesseriesDefinition
- the series definition if one exists. If null, then no placeholders are replaced.taskID
- 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
- Since:
- taskplanner 3.0
-
updateValues
@Nullable public Map<String,String> updateValues(@Nonnull DEFINITION patchedDefinition, @Nullable DEFINITION unpatchedDefinition, @Nullable SeriesDefinition seriesDefinition, @Nonnull com.inet.id.GUID taskID) Update values according to the give definition. Here it is possible to change some values that are updated in the client. For example do some time calculations and show the next executions.
This method returns a map with only changed values. Other values don't need to be added. If nothing should be changed, null can be returned. If it is required to have values that are not patched by a series the unpatchedDefinition can be used.The given definition is guaranteed to belong to this factory
- Parameters:
patchedDefinition
- the definition with the current properties, patched with the first data set from the series, if availableunpatchedDefinition
- the original definition with the current properties,null
if no series is available.seriesDefinition
- seriesDefinition the series definition if one exists. Ifnull
, then no properties are added an no placeholders are replaced (also not with empty string).taskID
- 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
- Since:
- taskplanner 3.0
-
createFrom
@Nonnull public final COMPONENT createFrom(@Nonnull DEFINITION definition, @Nullable Map<String, String> seriesProperties, @Nullable com.inet.id.GUID taskID) Creates a concrete object to be used byTaskPlanner
from given definition.
Seevalidate(AbstractDefinition, SeriesDefinition, GUID)
for what is patched and replaced.- Parameters:
definition
- holds information about the component to createseriesProperties
- set of properties for the current series, if there is one. Properties of the definition will be patched with this. If null, then nothing is replaced or patched.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:
- the created component
- Throws:
IllegalArgumentException
- if definition is null or the definition's extension name does not match this factory's extension name.- Since:
- taskplanner 3.0
- See Also:
-
getFirstValueFromSeries
@Nonnull protected Map<String,String> getFirstValueFromSeries(@Nonnull SeriesDefinition series, @Nullable com.inet.id.GUID taskID) throws IllegalStateException Get the first set of properties from the given series- Parameters:
series
- the configured seriestaskID
- 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:
- the first set of properties from the series, not null. Can be empty if the series does not have any data or the first set has no properties.
- Throws:
IllegalStateException
- if the series definition is not valid- Since:
- taskplanner 3.0
-
patchDefinitionProperties
protected DEFINITION patchDefinitionProperties(@Nonnull DEFINITION baseDefinition, @Nonnull Map<String, 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.- 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
- Since:
- taskplanner 3.0
-