Class SeriesDependentFactory<COMPONENT,DEFINITION extends AbstractDefinition<DEFINITION>,INFO extends AbstractInfo,SUMMARY extends SummaryInfo>
- java.lang.Object
-
- com.inet.taskplanner.server.api.common.AbstractFactory<COMPONENT,DEFINITION,INFO,SUMMARY>
-
- com.inet.taskplanner.server.api.common.SeriesDependentFactory<COMPONENT,DEFINITION,INFO,SUMMARY>
-
- All Implemented Interfaces:
com.inet.plugin.NamedExtension
- Direct Known Subclasses:
JobFactory
,ResultActionFactory
public abstract class SeriesDependentFactory<COMPONENT,DEFINITION extends AbstractDefinition<DEFINITION>,INFO extends AbstractInfo,SUMMARY extends SummaryInfo> extends AbstractFactory<COMPONENT,DEFINITION,INFO,SUMMARY>
Factory for components whose properties depends on aSeries
which the user may have configured. These arejobs
andResultActions
. This factory changes/updates the properties of the definition before being passed to implementation methods.For
validation
, additional the possibly setSeriesDefinition
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'sAbstractFactory.createInstanceFrom(AbstractDefinition,GUID)
method will then receive a definition with already patched/updated properties.- Since:
- taskplanner 3.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
PLACEHOLDER_END_CHARACTER
The official end character of placeholderstatic java.lang.String
PLACEHOLDER_START_CHARACTER
The official start character of placeholder
-
Constructor Summary
Constructors Constructor Description SeriesDependentFactory(java.lang.String extensionName)
Creates a new SeriesFactory instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description COMPONENT
createFrom(DEFINITION definition, java.util.Map<java.lang.String,java.lang.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.protected java.util.Map<java.lang.String,java.lang.String>
getFirstValueFromSeries(SeriesDefinition series, com.inet.id.GUID taskID)
Get the first set of properties from the given seriesprotected DEFINITION
patchDefinitionProperties(DEFINITION 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.java.util.Map<java.lang.String,java.lang.String>
updateValues(DEFINITION definition, SeriesDefinition seriesDefinition, com.inet.id.GUID taskID)
Update values according to the give definition.java.util.Map<java.lang.String,java.lang.String>
updateValues(DEFINITION patchedDefinition, DEFINITION unpatchedDefinition, SeriesDefinition seriesDefinition, com.inet.id.GUID taskID)
Update values according to the give definition.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 Detail
-
PLACEHOLDER_START_CHARACTER
public static final java.lang.String PLACEHOLDER_START_CHARACTER
The official start character of placeholder- See Also:
- Constant Field Values
-
PLACEHOLDER_END_CHARACTER
public static final java.lang.String PLACEHOLDER_END_CHARACTER
The official end character of placeholder- See Also:
- Constant Field Values
-
-
Method Detail
-
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 java.util.Map<java.lang.String,java.lang.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 java.util.Map<java.lang.String,java.lang.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 java.util.Map<java.lang.String,java.lang.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:
java.lang.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:
validate(AbstractDefinition, SeriesDefinition, GUID)
-
getFirstValueFromSeries
@Nonnull protected java.util.Map<java.lang.String,java.lang.String> getFirstValueFromSeries(@Nonnull SeriesDefinition series, @Nullable com.inet.id.GUID taskID) throws java.lang.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:
java.lang.IllegalStateException
- if the series definition is not valid- Since:
- taskplanner 3.0
-
patchDefinitionProperties
protected DEFINITION patchDefinitionProperties(@Nonnull DEFINITION baseDefinition, @Nonnull 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.- 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
-
-