Class BatchJob

All Implemented Interfaces:
Serializable, Comparable

public class BatchJob extends GeneratedBatchJob
A BatchJob is a subclass of Job, which divides the task which should be performed into several Steps. Thus a complex task (for example a BMECat import) can be divided into several small steps (for example article, media and price import) which are assigned to one BatchJob.

The performCronJob(CronJob) implementation of the BatchJob iterates over all pending steps and executes each Step.

See Also:
  • Constructor Details

    • BatchJob

      public BatchJob()
  • Method Details

    • remove

      public void remove(SessionContext ctx) throws ConsistencyCheckException
      Description copied from class: Job
      First all assigned CronJobs were removed, than the Job itself.
      Overrides:
      remove in class Job
      Parameters:
      ctx - A SessionContext object
      Throws:
      ConsistencyCheckException - if this item could not be removed for some reason
      See Also:
    • setCurrentlyExecutingStep

      protected static final void setCurrentlyExecutingStep(Step step)
    • unsetCurrentlyExecutingStep

      protected static final void unsetCurrentlyExecutingStep()
    • getCurrentlyExecutingStep

      protected static final Step getCurrentlyExecutingStep()
    • hasCurrentlyExecutingStep

      protected static final boolean hasCurrentlyExecutingStep()
    • isAbortable

      public boolean isAbortable(CronJob cronJob)
      Is abortable if the current step supports abort (see Step.isAbortable().
      Overrides:
      isAbortable in class Job
      Parameters:
      cronJob - the current execution of this job.
      Returns:
      true if the cronjob is running and the job supports aborting via GeneratedCronJob.setRequestAbort(boolean)
      See Also:
    • setSteps

      public void setSteps(SessionContext ctx, List<Step> steps)
      Sets the Steps of the BatchJob and deletes all Steps which were assigned before and which are not part of the specified Collection.
      Specified by:
      setSteps in class GeneratedBatchJob
      Parameters:
      ctx - 123
      steps - the List of the new Steps
    • getSteps

      public List<Step> getSteps()
      Returns a List of all Steps of the BatchJob.
      Overrides:
      getSteps in class GeneratedBatchJob
      Returns:
      a List of all Steps of the BatchJob
    • getSteps

      public List<Step> getSteps(SessionContext ctx)
      Returns a List of all Steps of the BatchJob.
      Specified by:
      getSteps in class GeneratedBatchJob
      Parameters:
      ctx - 123
      Returns:
      a List of all Steps of the BatchJob
    • getSteps

      public List<Step> getSteps(int start, int count)
      Returns a List containing the specified range of Steps of the BatchJob. (Range: start -> (start + count))
      Parameters:
      start - the start index of the range
      count - the number of steps in the range
      Returns:
      a List containing the specified range of Steps of the BatchJob
    • getSteps

      public List<Step> getSteps(SessionContext ctx, int start, int count)
      Returns a List containing the specified range of Steps of the BatchJob. (Range: start -> (start + count))
      Parameters:
      ctx - 123
      start - the start index of the range
      count - the number of steps in the range
      Returns:
      a List containing the specified range of Steps of the BatchJob
    • getFirstStep

      public Step getFirstStep()
      Returns the first Step.
      Returns:
      the first Step
    • getFirstStep

      public Step getFirstStep(SessionContext ctx)
      Returns the first Step.
      Parameters:
      ctx -
      Returns:
      the first Step
    • getLastStep

      public Step getLastStep()
      Returns the last Step.
      Returns:
      the last Step
    • getLastStep

      public Step getLastStep(SessionContext ctx)
      Returns the last Step.
      Parameters:
      ctx -
      Returns:
      the last Step
    • getAllPreviousSteps

      public Collection<Step> getAllPreviousSteps(Step step)
      Returns a Collection of all predecessor Steps of the specified Step.
      Parameters:
      step - the Step whose predecessor Steps should be returned
      Returns:
      a Collection of all predecessor Steps of the specified Step
    • getAllPreviousSteps

      public Collection<Step> getAllPreviousSteps(SessionContext ctx, Step step)
      Returns a Collection of all predecessor Steps of the specified Step.
      Parameters:
      ctx - 123
      step - the Step whose predecessor Steps should be returned
      Returns:
      a Collection of all predecessor Steps of the specified Step
    • getNextSequenceNumber

      protected Integer getNextSequenceNumber()
      Returns the next sequence number.
      Returns:
      the next sequence number
    • getNextSequenceNumber

      protected Integer getNextSequenceNumber(SessionContext ctx)
      Returns the next sequence number.
      Parameters:
      ctx - 123
      Returns:
      the next sequence number
    • addStep

      protected Step addStep()
    • addStep

      public Step addStep(ComposedType stepType)
      Adds a Step of the specified type to the BatchJob and returns it.
      Parameters:
      stepType - the ComposedType of the Step, which will be added
      Returns:
      the new Step which have been added to the BatchJob
    • addStep

      public Step addStep(ComposedType stepType, Map additionalAttributes)
      Adds a Step of the specified type to the BatchJob and returns it.
      Parameters:
      stepType - the ComposedType of the Step, which will be added
      additionalAttributes - additionalAttributes, which will be used to the create the specified Step type
      Returns:
      the new Step which have been added to the BatchJob
    • undoCronJob

      protected CronJob.CronJobResult undoCronJob(CronJob cronJob)
      Starts the undo-process of the BatchJob for the specified CronJob.
      Overrides:
      undoCronJob in class Job
      Parameters:
      cronJob - the CronJob, which is used for the undo-process
      Returns:
      CronJob.CronJobResult the result of the undo-process
    • performCronJob

      protected CronJob.CronJobResult performCronJob(CronJob cronJob)
      Performs the BatchJob using the specified CronJob. The BatchJob will execute all pending Steps in the given order. If one Step cannot be performed, the execution of the BatchJob is paused.
      Specified by:
      performCronJob in class Job
      Parameters:
      cronJob - the CronJob, which should used for execution
      Returns:
      CronJob.CronJobResult the result of the execution
      See Also:
    • canUndo

      protected boolean canUndo(CronJob cronJob)
      Returns true, if the BatchJob can be undone using the specified CronJob.
      Overrides:
      canUndo in class Job
      Parameters:
      cronJob - the CronJob to undo changes for
      Returns:
      true, if the BatchJob can be undone using the specified CronJob
      See Also: