Class AbstractFactory<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>
Type Parameters:
COMPONENT - type of the component to produce (Trigger, Job or ResultAction)
DEFINITION - type of the definition to use. The definition contains all settings for the component.
INFO - type of the info object to produce
SUMMARY - type of the summary object to produce
All Implemented Interfaces:
com.inet.plugin.NamedExtension
Direct Known Subclasses:
SeriesDependentFactory, SeriesIndependentFactory

public abstract class AbstractFactory<COMPONENT, DEFINITION extends AbstractDefinition<DEFINITION>, INFO extends AbstractInfo, SUMMARY extends SummaryInfo> extends Object implements com.inet.plugin.NamedExtension
Base class for all factories producing components for the TaskPlanner.

A factory produces a COMPONENT from a DEFINITION. A product is a real implementation of a Trigger, Job, Series, or ResultAction; an Definition is a POJO containing information and properties about the trigger, job, series, or result action. The definition is constructed by users through the TaskPlanner API or the Task Planner web GUI.

Additionally a factory must produce some information about a component it can create, must validate the Definition and produce a summary for a Definition.

The extensionName passed in with the constructor is a unique name describing the type of components constructed from this factory. I.e. the Trigger FileChangeTrigger has a unique extension key which no other Trigger is allowed to have. That extensionName is contained in the Definition.

The life cycle of the component, definition, info, and summary is as follows (using a Trigger as an example):

  • When the user accesses the Task Planner web GUI, it allows the user to select a trigger from the factory. In order to correctly display the name and possible settings for the Trigger, it needs the information from getInformation(GUID).
  • When the user sets up the trigger (in the web GUI or through the API), it creates a TriggerDefinition that contains the settings made by the user.
  • In the web GUI, the settings made by the user are validated with validate(AbstractDefinition, GUID).
  • In the web GUI, a small summary of the trigger settings is shown using the result from getSummary(AbstractDefinition).
  • When the task with this Trigger is saved, a real implementation of Trigger is constructed out of the TriggerDefinition in createInstanceFrom(AbstractDefinition,GUID). The Trigger is then able to really send a signal to start the execution.
Since:
taskplanner 3.0
  • Constructor Summary

    Constructors
    Constructor
    Description
    AbstractFactory(@Nonnull String extensionName)
    Creates a new Factory instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected final void
    Checks that the given definition is non-null and belongs to this factory.
    protected COMPONENT
    createInstanceFrom(@Nonnull DEFINITION definition)
    Deprecated. 
    protected COMPONENT
    createInstanceFrom(@Nonnull DEFINITION definition, @Nullable com.inet.id.GUID taskID)
    Constructs a component (PRODUCT) from the given definition.
    final @Nonnull String
    getInformation(@Nonnull DEFINITION definition, @Nullable com.inet.id.GUID taskID)
    Returns an information object about components which can be produced with this factory, using the given definition to provide definition-specific information (such as placeholder keys that depend on the definition's properties).
    abstract INFO
    getInformation(@Nullable com.inet.id.GUID taskID)
    Returns an information object about components which can be produced with this factory.
    @Nonnull String
    Returns additional keywords that can be used to find this component in the "add" filter bar.
    abstract SUMMARY
    getSummary(@Nonnull DEFINITION definition)
    Constructs summary information for the component represented by the given definition.
    boolean
    Whether the (COMPONENT) is available or not.
    boolean
    Returns whether components produced by this factory can be used in system tasks.
    protected abstract void
    validate(@Nonnull DEFINITION definition, @Nullable com.inet.id.GUID taskID)
    Validate the given definition.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AbstractFactory

      public AbstractFactory(@Nonnull String extensionName)
      Creates a new Factory instance.
      Parameters:
      extensionName - unique name for this kind of components.
      Throws:
      IllegalArgumentException - if extensionName is null.
      Since:
      taskplanner 3.0
  • Method Details

    • getExtensionName

      public final @Nonnull String getExtensionName()
      Specified by:
      getExtensionName in interface com.inet.plugin.NamedExtension
    • checkDefinitionArgument

      protected final void checkDefinitionArgument(DEFINITION definition)
      Checks that the given definition is non-null and belongs to this factory.
      Parameters:
      definition - the passed in definition.
      Throws:
      IllegalArgumentException - if definition is null or it does not belong to this factory
      Since:
      taskplanner 3.0
    • getInformation

      public abstract INFO getInformation(@Nullable com.inet.id.GUID taskID)
      Returns an information object about components which can be produced with this factory.

      The returned info contains information about how such a component is to be presented in the Task Planner web GUI. This includes display information and available configuration options. The returned information contains fields that describe the values a user can specify in the web GUI. The fields are also responsible for replacing placeholders for the corresponding property in a serial task. That means properties without a field definition will not get any series placeholder replaced.

      If you implement a factory for a component used only through the API, you can return null here.

      Parameters:
      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:
      an information object for components this factory can produce
      Since:
      taskplanner 3.0
    • getInformation

      public INFO getInformation(@Nonnull DEFINITION definition, @Nullable com.inet.id.GUID taskID)
      Returns an information object about components which can be produced with this factory, using the given definition to provide definition-specific information (such as placeholder keys that depend on the definition's properties).

      The default implementation delegates to getInformation(GUID). Subclasses may override this method to include definition-dependent information.

      Parameters:
      definition - the definition holding the current user configuration, guaranteed to belong to this factory
      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:
      an information object for components this factory can produce
      Since:
      taskplanner 26.10
    • validate

      protected abstract void validate(@Nonnull DEFINITION definition, @Nullable com.inet.id.GUID taskID) throws ValidationException
      Validate the given definition.

      The given definition is guaranteed to belong to this factory

      Parameters:
      definition - the definition to validate
      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
    • createInstanceFrom

      @Deprecated protected COMPONENT createInstanceFrom(@Nonnull DEFINITION definition)
      Deprecated.
      Constructs a component (PRODUCT) from the given definition.
      Parameters:
      definition - the definition holding information for the PRODUCT
      Returns:
      a new PRODUCT
      Throws:
      IllegalStateException - to indicate that this method is deprecated and the method createInstanceFrom(definition, taskID) has to be used.
      Since:
      taskplanner 3.0
    • createInstanceFrom

      protected COMPONENT createInstanceFrom(@Nonnull DEFINITION definition, @Nullable com.inet.id.GUID taskID)
      Constructs a component (PRODUCT) from the given definition.
      Parameters:
      definition - the definition holding information for the PRODUCT
      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 PRODUCT
      Since:
      taskplanner 4.0
    • getSummary

      public abstract SUMMARY getSummary(@Nonnull DEFINITION definition)
      Constructs summary information for the component represented by the given definition.

      The summary information is used when the web GUI displays the component.

      When implementing a factory for a component to be used only through the API, you can return null here.

      Parameters:
      definition - the definition with the settings made by a user
      Returns:
      summary information containing text lines to be displayed in the web GUI for this component.
      Since:
      taskplanner 3.0
    • isAvailable

      public boolean isAvailable()
      Whether the (COMPONENT) is available or not.
      Returns:
      whether the (COMPONENT) is available or not
      Since:
      taskplanner 3.0
    • isSupportedForSystemTasks

      public boolean isSupportedForSystemTasks()
      Returns whether components produced by this factory can be used in system tasks.

      System tasks are executed with the privileged runtime owner. Factories can override this method if their components depend on a regular user account and therefore cannot run in that execution context.

      Returns:
      whether this factory supports system tasks
      Since:
      taskplanner 26.10
    • getKeywords

      public @Nonnull String getKeywords()
      Returns additional keywords that can be used to find this component in the "add" filter bar.

      The keywords are to be comma-separated and are searched in addition to the name and description. Subclasses can override this method to provide custom keywords.

      The default implementation returns an empty string (no additional keywords).

      Returns:
      comma-separated keywords for filtering, never null
      Since:
      taskplanner 26.4