Class JobFactory<T extends Job>

Type Parameters:
T - the concrete type of the Job implementation
All Implemented Interfaces:
com.inet.plugin.NamedExtension

public abstract class JobFactory<T extends Job> extends SeriesDependentFactory<T,JobDefinition,JobInfo,JobSummaryInfo>
Base class for factories producing Job components.

           JobDefinition ----> JobFactory ----> Job
 
See documentation of AbstractFactory for more information about the life cycle.

When a factory is implemented, use ServerPluginManager.register(Class, Object) with JobFactory.class as first argument:

spm.register(JobFactory.class, new MouseJobFactory());

Implementations sample: because the extensionName must be unique and must be used when a JobDefinition is created by API, it is recommended to set up a public constant with the extensionName:


 public class MouseJobFactory extends JobFactory<MouseJob> {
      public static final String EXTENSION_NAME = "job.mouse";

      public MouseJobFactory(){
          super(EXTENSION_NAME);
      }


      @Override
      protected MouseJob createInstanceFrom( JobDefinition definition, GUID taskID ) {
          MouseJob job = new MouseJob();
          //put values from definition to job impl
          ...

          return job;
      }

      ...
      //somewhere using public API
      JobDefinition mouseJob = new JobDefinition(MouseJobFactory.EXTENSION_NAME);
      //configure it
      ...

 
Since:
taskplanner 3.0
  • Constructor Details

    • JobFactory

      public JobFactory(String extensionName)
      Creates a new JobFactory instance.
      Parameters:
      extensionName - the unique extensionName for this Job.
      Since:
      taskplanner 3.0
  • Method Details

    • getResultFlavors

      public abstract List<ResultFlavor> getResultFlavors(JobDefinition definition)
      Returns the list of supported flavors.
      Parameters:
      definition - the definition with the settings made by a user
      Returns:
      the list of supported flavors.
      Since:
      taskplanner 3.0
    • validateCondition

      public final void validateCondition(@Nonnull @Nonnull JobDefinition definition, @Nullable @Nullable SeriesDefinition seriesDefinition, @Nullable @Nullable com.inet.id.GUID taskID) throws ValidationException
      Validate the given condition.

      The given definition is guaranteed to belong to this factory

      Parameters:
      definition - definition of the job to validate
      seriesDefinition - the series which the user have configured, if any
      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 configured condition is not valid
      Since:
      taskplanner 3.0
    • patchDefinitionProperties

      protected final JobDefinition patchDefinitionProperties(JobDefinition baseDefinition, 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.

      Overrides:
      patchDefinitionProperties in class SeriesDependentFactory<T extends Job,JobDefinition,JobInfo,JobSummaryInfo>
      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
    • validateCondition

      protected abstract void validateCondition(@Nonnull @Nonnull JobDefinition definition) throws ValidationException
      Validate the condition. This is only called if a condition is set.
      Parameters:
      definition - definition of the job to validate. This already has patched properties from series if any.
      Throws:
      ValidationException - if the configured condition is not valid
      Since:
      taskplanner 3.0
    • isAutoResolvePlaceholders

      public boolean isAutoResolvePlaceholders()
      Defines whether placeholders will be automatically replaced before the execute method is called. The default implementation returns true.
      The automatic replacement will ask all fields, defined by the factory, to resolve all placeholders that match a field key and supports placeholders.

      For manual replacement, the PlaceholderResolver can be used.
      Returns:
      true if the placeholders shall be resolve automatically, false if the implementation needs to manage this by themselves.
      Since:
      taskplanner 25.4
    • customPatchDefinitionProperties

      protected JobDefinition customPatchDefinitionProperties(JobDefinition baseDefinition, Map<String,String> seriesProperties, @Nullable @Nullable com.inet.id.GUID taskID)
      custom patch definition properties (will be called if this factory returns false for isAutoResolvePlaceholders()
      Parameters:
      baseDefinition - base definition we are patching / cloning
      seriesProperties - typically: placeholder to patch
      taskID - id of task running
      Returns:
      custom patch definition properties (will be called if this factory returns false for isAutoResolvePlaceholders()
      Since:
      taskplanner 25.4