Class SeriesDependentFactory<COMPONENT,​DEFINITION extends AbstractDefinition<DEFINITION>,​INFO extends AbstractInfo,​SUMMARY extends SummaryInfo>

    • 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
    • Constructor Detail

      • SeriesDependentFactory

        public SeriesDependentFactory​(java.lang.String extensionName)
        Creates a new SeriesFactory instance.
        Parameters:
        extensionName - unique name for this kind of components
        Since:
        taskplanner 3.0
    • 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 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 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 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 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 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 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 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:
        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 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:
        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 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