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 a 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 Details

    • PLACEHOLDER_START_CHARACTER

      public static final String PLACEHOLDER_START_CHARACTER
      The official start character of placeholder
      See Also:
    • PLACEHOLDER_END_CHARACTER

      public static final String PLACEHOLDER_END_CHARACTER
      The official end character of placeholder
      See Also:
  • Constructor Details

    • SeriesDependentFactory

      public SeriesDependentFactory(String extensionName)
      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 @Nullable SeriesDefinition seriesDefinition, @Nullable @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 in AbstractFactory.getInformation(GUID).

      The original definition object is not changed.

      Parameters:
      definition - the definition to validate
      seriesDefinition - 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 @Nullable Map<String,String> updateValues(@Nonnull DEFINITION definition, @Nullable @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 in AbstractFactory.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 properties
      seriesDefinition - 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 @Nullable Map<String,String> updateValues(@Nonnull DEFINITION patchedDefinition, @Nullable DEFINITION unpatchedDefinition, @Nullable @Nullable SeriesDefinition seriesDefinition, @Nonnull @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 available
      unpatchedDefinition - the original definition with the current properties, null if no series is available.
      seriesDefinition - seriesDefinition 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
      Returns:
      a map of property key with their values that have changed
      Since:
      taskplanner 3.0
    • createFrom

      @Nonnull public COMPONENT createFrom(@Nonnull DEFINITION definition, @Nullable @Nullable Map<String,String> seriesProperties, @Nullable @Nullable com.inet.id.GUID taskID)
      Creates a concrete object to be used by TaskPlanner from given definition.
      See validate(AbstractDefinition, SeriesDefinition, GUID) for what is patched and replaced.
      Parameters:
      definition - holds information about the component to create
      seriesProperties - 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 @Nonnull Map<String,String> getFirstValueFromSeries(@Nonnull @Nonnull SeriesDefinition series, @Nullable @Nullable com.inet.id.GUID taskID) throws IllegalStateException
      Get the first set of properties from the given series
      Parameters:
      series - the configured series
      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 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 @Nonnull 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.

      Parameters:
      baseDefinition - original definition from the model, this one will not be changed
      seriesProperties - properties from the current series set
      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:
      a new Definition with patched properties
      Since:
      taskplanner 3.0