Class Step

All Implemented Interfaces:
Serializable, Comparable
Direct Known Subclasses:
GeneratedMediaProcessorStep

public abstract class Step extends GeneratedStep
A Step implements one part of the logic of a complex / modular task and is part of a BatchJob, a subclass of Job. The BatchJob supplies the logic to manage multiple steps.
See Also:
  • Constructor Details

    • Step

      public Step()
  • Method Details

    • createItem

      protected Item createItem(SessionContext ctx, ComposedType type, Item.ItemAttributeMap allAttributes) throws JaloBusinessException
      Description copied from class: Item
      Has to be implemented for each concrete subtype of item. This method is responsible for creating a new item instance ( by calling managers, ejb homes, etc. ) during ComposedType.newInstance(Map).

      In case this method uses any of the attribute values during creation it is required to override Item.getNonInitialAttributes(SessionContext, ItemAttributeMap) too.
      Sn example:

      
       public static final String MY_ATTRIBUTE = "someAttribute"; ... protected Item createItem(SessionContext
       ctx, ComposedType type, Map allAttributes ) throws JaloBusinessException { MyManager man = ... return
       man.createMyItem( (String)allAttributes.get(MY_ATTRIBUTE) );
       // here MY_ATTRIBUTE is used for creation, so it must not be set again } protected Map getNonInitialAttributes(
       SessionContext ctx, Map allAttributes ) { // let superclass remove its own initial attributes Map ret =
       super.getNonInitialAttributes( ctx, allAttributes );
       // remove MY_ATTRIBUTE from all attributes since if has already been set ret.remove(MY_ATTRIBUTE); return ret; }
      
       
      Overrides:
      createItem in class GenericItem
      Parameters:
      ctx - the current session context which this item is created within
      type - the actual item type ( since subtypes may not provide a own jalo class this may be different from the type which this method was implemented for )
      Returns:
      the new item instance
      Throws:
      JaloBusinessException - indicates an error during creation - any changes will be rollbacked
    • getNonInitialAttributes

      protected Item.ItemAttributeMap getNonInitialAttributes(SessionContext ctx, Item.ItemAttributeMap allAttributes)
      Description copied from class: GenericItem
      The default implementation of GenericItem.getNonInitialAttributes(SessionContext, Item.ItemAttributeMap) assures that the 'registered initial' properties GenericItem.getInitialProperties(JaloSession, Item.ItemAttributeMap) will be removed from the 'non initial map'.
      Overrides:
      getNonInitialAttributes in class GenericItem
      Parameters:
      ctx - session context with language = NULL
      allAttributes - a ItemAttributeMap contaning attribute values.
      Returns:
      a ItemAttributeMap containing all attribute values, which belong to non-initial attributes.
    • setNonInitialAttributes

      public void setNonInitialAttributes(SessionContext ctx, Item item, Item.ItemAttributeMap nonInitialAttributes) throws JaloBusinessException
      Description copied from class: Item
      Sets all attributes which could not be set during Item.createItem(SessionContext, ComposedType, ItemAttributeMap). as default this method just iterates over all attribute mappings and sets the value by invoking Item.setAttribute(SessionContext, String, Object).
      Overrides:
      setNonInitialAttributes in class Item
      Parameters:
      ctx - session context with language = NULL
      item - the newly created item
      nonInitialAttributes - the non-initial attributed obtained via Item.getNonInitialAttributes(SessionContext, ItemAttributeMap)
      Throws:
      JaloBusinessException
    • log

      public void log(String message, org.apache.log4j.Level level)
    • debug

      public void debug(String message)
    • info

      public void info(String message)
    • warn

      public void warn(String message)
    • error

      public void error(String message)
    • fatal

      public void fatal(String message)
    • isDebugEnabled

      public boolean isDebugEnabled()
    • isInfoEnabled

      public boolean isInfoEnabled()
    • isWarnEnabled

      public boolean isWarnEnabled()
    • isErrorEnabled

      public boolean isErrorEnabled()
    • getChanges

      protected Collection<ChangeDescriptor> getChanges(CronJob cronJob)
      Returns a Collection of ChangeDescriptors, which were created by this Step. These ChangeDescriptors normally are created during execution by using addChange(CronJob, String, Item, String).
      Parameters:
      cronJob - the CronJob which is used by this Step for execution
      Returns:
      a Collection of ChangeDescriptors, which were created by this Step
    • getChanges

      protected Collection<ChangeDescriptor> getChanges(CronJob cronJob, String changeType)
      Returns a Collection of ChangeDescriptors of the specified changeType, which were created by this Step. These ChangeDescriptors normally are created during execution by using addChange(CronJob, String, Item, String).
      Parameters:
      cronJob - the CronJob which is used by the Step for execution
      changeType - specifes which kind of changes should be considered
      Returns:
      a Collection of ChangeDescriptors, which were created by this Step
    • getChanges

      protected Collection<ChangeDescriptor> getChanges(CronJob cronJob, int start, int count)
      Returns a Collection of ChangeDescriptors, which were created by this Step. The collection contains a ChangeDescriptors which belong to the specified range (start -> start + count).

      These ChangeDescriptors normally are created during execution by using addChange(CronJob, String, Item, String).

      Parameters:
      cronJob - the CronJob which is used by this Step for execution
      start - the index of the first ChangeDescriptor of the range
      count - the number of ChangeDescriptors in the range
      Returns:
      a Collection of ChangeDescriptors of the specified changeType, which were created by this Step
    • getChanges

      protected Collection<ChangeDescriptor> getChanges(CronJob cronJob, String changeType, int start, int count)
      Returns a Collection of ChangeDescriptors of the specified changeType, which were created by this Step. The collection contains a ChangeDescriptors which belong to the specified range (start -> start + count).

      These ChangeDescriptors normally are created during execution by using addChange(CronJob, String, Item, String).

      Parameters:
      cronJob - the CronJob which is used by this Step for execution
      changeType - specifes which kind of changes should be considered
      start - the index of the first ChangeDescriptor of the range
      count - the number of ChangeDescriptors in the range
      Returns:
      a Collection of ChangeDescriptors of the specified changeType, which were created by this Step
    • addChange

      protected ChangeDescriptor addChange(CronJob cronJob, String changeType, Item changedItem, String description)
      Creates a new ChangeDescriptor for the specified CronJob with the specified changeType, changedItem and description.
      Parameters:
      cronJob - the CronJob which is used for execution
      changeType - specifes which type of change (create, delete, modify...)
      changedItem - the changed item (optional)
      description - a description (optional)
      Returns:
      the new ChangeDescriptor
    • hasChanges

      protected boolean hasChanges(CronJob cronJob, String changeType)
      Returns true, if there are ChangeDescriptors for this Step and the specified CronJob. Otherwise false is returned.
      Parameters:
      cronJob - the CronJob which is used for execution
      changeType - specifes which type of change should be considered. This parameter is optional, if null is specified, all ChangeDescriptors will be considered
      Returns:
      true, if there are ChangeDescriptors for this Step and the specified CronJob
    • getMostRecentChange

      protected ChangeDescriptor getMostRecentChange(CronJob cronJob, String changeType)
      Returns the most recent ChangeDescriptor for this Step and the specified CronJob. Optionally the changeType can be specified.
      Parameters:
      cronJob - the CronJob which is used for execution
      changeType - specifes which kind of changes should be considered
      Returns:
      Returns the most recent ChangeDescriptor for this Step and the specified CronJob
    • canUndo

      protected boolean canUndo(CronJob cronJob)
      Returns true, if this Step is undoable for the specified CronJob. Otherwise false is returned.

      If one step of a CronJob returns false the whole CronJob will stop the undo process. The default implementation returns false. If your subclass of Step supports the undo-feature, override this method and return true.

      Parameters:
      cronJob - the CronJob which is used for execution
      Returns:
      true, if this Step is undoable for the specified CronJob
      See Also:
    • undoStep

      protected abstract void undoStep(CronJob cronJob)
      Starts the undo processing for this Step and the specified CronJob.
      Add your undo logic here to support the undo feature.
      Parameters:
      cronJob - the CronJob which is used for execution
      See Also:
    • canPerform

      protected abstract boolean canPerform(CronJob cronJob)
      Returns true, if this Step can be performed for the specified CronJob. Otherwise false is returned.
      Parameters:
      cronJob - the CronJob which is used for execution
      Returns:
      true, if this Step can be performed for the specified CronJob
    • performStep

      protected abstract void performStep(CronJob cronJob) throws AbortCronJobException
      Executes this Step using the specified CronJob.

      Implement this method in your Step subclass and add the logic here.

      Parameters:
      cronJob - the CronJob which is used for execution
      Throws:
      AbortCronJobException - if the execution is aborted due to an error
      See Also:
    • getFailErrorMode

      public EnumerationValue getFailErrorMode()
      Returns:
      the EnumerationValue GeneratedCronJobConstants.Enumerations.ErrorMode.FAIL
    • getPauseErrorMode

      public EnumerationValue getPauseErrorMode()
      Returns:
      the EnumerationValue GeneratedCronJobConstants.Enumerations.ErrorMode.PAUSE
    • getIgnoreErrorMode

      public EnumerationValue getIgnoreErrorMode()
      Returns:
      the EnumerationValue GeneratedCronJobConstants.Enumerations.ErrorMode.IGNORE
    • toString

      public String toString()
      Returns the String representation of a Step. The representation has the following structure:
          BatchJob.CODE -> Step.CODE[ sync|async, Step.ERRORMODE]
       
      Overrides:
      toString in class Item
      Returns:
      the String representation of a Step. The representation has the following structure:
    • isAbortable

      public boolean isAbortable()
      Returns true, if this Step is abortable.

      The default implementation returns always false. To mark your Step subclass as abortable, override this method and return true.

      Returns:
      true, if this Step is abortable