Class Step

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.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:
    BatchJob, Job, Serialized Form
    • Constructor Detail

      • Step

        public Step()
    • Method Detail

      • 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
      • log

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

        public void debug​(java.lang.String message)
      • info

        public void info​(java.lang.String message)
      • warn

        public void warn​(java.lang.String message)
      • error

        public void error​(java.lang.String message)
      • fatal

        public void fatal​(java.lang.String message)
      • isDebugEnabled

        public boolean isDebugEnabled()
      • isInfoEnabled

        public boolean isInfoEnabled()
      • isWarnEnabled

        public boolean isWarnEnabled()
      • isErrorEnabled

        public boolean isErrorEnabled()
      • getChanges

        protected java.util.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 java.util.Collection<ChangeDescriptor> getChanges​(CronJob cronJob,
                                                                    java.lang.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 java.util.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 java.util.Collection<ChangeDescriptor> getChanges​(CronJob cronJob,
                                                                    java.lang.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,
                                             java.lang.String changeType,
                                             Item changedItem,
                                             java.lang.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,
                                     java.lang.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,
                                                       java.lang.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(CronJob)
      • 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:
        canUndo(CronJob)
      • 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:
        canPerform(CronJob)
      • toString

        public java.lang.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