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, a Definition is a POJO containing information and properties about the Trigger, Job, Series or Actions. The definition is constructed from users using the TaskPlanner API or the task planner webgui.

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 can be seen like this (example for a Trigger):

  • When the user accesses the task planner webgui, it allows him to select the 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 webgui or in API) it creates a TriggerDefinition which contains the settings made by the user.
  • In case of webgui, the settings made by the user are validated with validate(AbstractDefinition, GUID).
  • In case of webgui, a small summary of the settings for the Trigger is shown. For that is used 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 Details

    • AbstractFactory

      public AbstractFactory(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 String getExtensionName()
      Specified by:
      getExtensionName in interface com.inet.plugin.NamedExtension
    • checkDefinitionArgument

      protected final void checkDefinitionArgument(DEFINITION definition)
      Check if the given definition is not 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 @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 taskPlanner GUI. This are display-infos or available options to configure. The returned information contains fields which describes the values a user can specify in the WEB GUI. The field is also responsible to replace any 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 only to be used by API, only then 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
    • validate

      protected abstract void validate(@Nonnull DEFINITION definition, @Nullable @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.
      Construct 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,taskD ) has to be used.
      Since:
      taskplanner 3.0
    • createInstanceFrom

      protected COMPONENT createInstanceFrom(@Nonnull DEFINITION definition, @Nullable @Nullable com.inet.id.GUID taskID)
      Construct 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)
      Construct Summary infos for the component represented by given definition.

      The summary info is used when the webgui displays the component.

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

      Parameters:
      definition - the definition with the settings made by a user
      Returns:
      summary infos containing text lines to be displayed in the webgui 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