Class Step
- java.lang.Object
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable
- Direct Known Subclasses:
GeneratedMediaProcessorStep
public abstract class Step extends GeneratedStep
AStepimplements one part of the logic of a complex / modular task and is part of aBatchJob, a subclass ofJob. TheBatchJobsupplies the logic to manage multiple steps.- See Also:
BatchJob,Job, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class de.hybris.platform.jalo.GenericItem
GenericItem.GenericItemImpl
-
Nested classes/interfaces inherited from class de.hybris.platform.jalo.c2l.LocalizableItem
LocalizableItem.LocalizableItemImpl
-
Nested classes/interfaces inherited from class de.hybris.platform.jalo.ExtensibleItem
ExtensibleItem.ExtensibleItemImpl
-
Nested classes/interfaces inherited from class de.hybris.platform.jalo.Item
Item.AttributeFilter, Item.AttributeMode, Item.CachedGetter, Item.CachedSetter, Item.ItemAttributeMap, Item.ItemConstraint, Item.ItemImpl, Item.JaloCachedComputationException
-
-
Field Summary
-
Fields inherited from class de.hybris.platform.cronjob.jalo.GeneratedStep
BATCHJOB, CODE, CRONJOBPENDINGSTEPSRELATION_MARKMODIFIED, CRONJOBPENDINGSTEPSRELATION_SRC_ORDERED, CRONJOBPENDINGSTEPSRELATION_TGT_ORDERED, CRONJOBPROCESSEDSTEPSRELATION_MARKMODIFIED, CRONJOBPROCESSEDSTEPSRELATION_SRC_ORDERED, CRONJOBPROCESSEDSTEPSRELATION_TGT_ORDERED, DEFAULT_INITIAL_ATTRIBUTES, ERRORMODE, PENDINGCRONJOBS, PROCESSEDCRONJOBS, SEQUENCENUMBER, SYNCHRONOUS
-
Fields inherited from class de.hybris.platform.jalo.c2l.LocalizableItem
LANGUAGE_FALLBACK_ENABLED
-
Fields inherited from class de.hybris.platform.jalo.Item
_CREATION_TIME_INTERNAL, _MODIFIED_TIME_INTERNAL, accessorLog, CREATION_TIME, DISABLE_ATTRIBUTE_CHECK, DISABLE_ITEMCHECK_BEFORE_REMOVABLE, EVEN, FEATURE_ACCESSMAP_QUALIFIER, HJMPTS, INITIAL_CREATION_FLAG, isJaloOnly, MODIFIED_TIME, NEGATIVE, NOT_FOUND, OWNER, PK, POSITIVE, SAVE_FROM_SERVICE_LAYER, staticTransientObjects, TYPE
-
Fields inherited from class de.hybris.platform.util.BridgeAbstraction
impl, tenant
-
-
Constructor Summary
Constructors Constructor Description Step()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected ChangeDescriptoraddChange(CronJob cronJob, java.lang.String changeType, Item changedItem, java.lang.String description)Creates a newChangeDescriptorfor the specifiedCronJobwith the specified changeType, changedItem and description.protected abstract booleancanPerform(CronJob cronJob)Returnstrue, if thisStepcan be performed for the specifiedCronJob.protected booleancanUndo(CronJob cronJob)Returnstrue, if thisStepis undoable for the specifiedCronJob.protected ItemcreateItem(SessionContext ctx, ComposedType type, Item.ItemAttributeMap allAttributes)Has to be implemented for each concrete subtype of item.voiddebug(java.lang.String message)voiderror(java.lang.String message)voidfatal(java.lang.String message)protected java.util.Collection<ChangeDescriptor>getChanges(CronJob cronJob)Returns aCollectionofChangeDescriptors, which were created by thisStep.protected java.util.Collection<ChangeDescriptor>getChanges(CronJob cronJob, int start, int count)Returns aCollectionofChangeDescriptors, which were created by thisStep.protected java.util.Collection<ChangeDescriptor>getChanges(CronJob cronJob, java.lang.String changeType)Returns aCollectionofChangeDescriptorsof the specified changeType, which were created by thisStep.protected java.util.Collection<ChangeDescriptor>getChanges(CronJob cronJob, java.lang.String changeType, int start, int count)Returns aCollectionofChangeDescriptorsof the specified changeType, which were created by thisStep.EnumerationValuegetFailErrorMode()Returns the EnumerationValueGeneratedCronJobConstants.Enumerations.ErrorMode.FAIL.EnumerationValuegetIgnoreErrorMode()Returns the EnumerationValueGeneratedCronJobConstants.Enumerations.ErrorMode.IGNORE.protected ChangeDescriptorgetMostRecentChange(CronJob cronJob, java.lang.String changeType)Returns the most recentChangeDescriptorfor thisStepand the specifiedCronJob.protected Item.ItemAttributeMapgetNonInitialAttributes(SessionContext ctx, Item.ItemAttributeMap allAttributes)The default implementation ofGenericItem.getNonInitialAttributes(SessionContext, Item.ItemAttributeMap)assures that the 'registered initial' propertiesGenericItem.getInitialProperties(JaloSession, Item.ItemAttributeMap)will be removed from the 'non initial map'.EnumerationValuegetPauseErrorMode()Returns the EnumerationValueGeneratedCronJobConstants.Enumerations.ErrorMode.PAUSE.protected booleanhasChanges(CronJob cronJob, java.lang.String changeType)voidinfo(java.lang.String message)booleanisAbortable()Returnstrue, if thisStepis abortable.booleanisDebugEnabled()booleanisErrorEnabled()booleanisInfoEnabled()booleanisWarnEnabled()voidlog(java.lang.String message, org.apache.log4j.Level level)protected abstract voidperformStep(CronJob cronJob)Executes this Step using the specifiedCronJob.voidsetNonInitialAttributes(SessionContext ctx, Item item, Item.ItemAttributeMap nonInitialAttributes)Sets all attributes which could not be set duringItem.createItem(SessionContext, ComposedType, ItemAttributeMap).java.lang.StringtoString()Returns theStringrepresentation of aStep.protected abstract voidundoStep(CronJob cronJob)Starts the undo processing for thisStepand the specifiedCronJob.voidwarn(java.lang.String message)-
Methods inherited from class de.hybris.platform.cronjob.jalo.GeneratedStep
getBatchJob, getBatchJob, getCode, getCode, getDefaultAttributeModes, getErrorMode, getErrorMode, getSequenceNumber, getSequenceNumber, getSequenceNumberAsPrimitive, getSequenceNumberAsPrimitive, isMarkModifiedDisabled, isSynchronous, isSynchronous, isSynchronousAsPrimitive, isSynchronousAsPrimitive, setBatchJob, setBatchJob, setCode, setCode, setErrorMode, setErrorMode, setSequenceNumber, setSequenceNumber, setSequenceNumber, setSequenceNumber, setSynchronous, setSynchronous, setSynchronous, setSynchronous
-
Methods inherited from class de.hybris.platform.jalo.GenericItem
getImplementation, getInitialProperties, getRelatedItems, setRelatedItems
-
Methods inherited from class de.hybris.platform.jalo.c2l.LocalizableItem
getAllLocalizedProperties, getAllLocalizedProperties, getAllLocalizedProperties, getAllLocalizedProperties, getAllValuesSessionContext, getLocalizedProperty, getLocalizedProperty, getLocalizedPropertyInternal, getLocalizedPropertyNames, getLocalizedPropertyNames, hasLanguage, isEmptyValue, isFallbackEnabled, removeLocalizedProperty, removeLocalizedProperty, setAllLocalizedProperties, setAllLocalizedProperties, setLocalizedProperty, setLocalizedProperty
-
Methods inherited from class de.hybris.platform.jalo.ExtensibleItem
createNonClassAccessor, getAllProperties, getAllProperties, getProperty, getProperty, getPropertyNames, getPropertyNames, removeProperty, removeProperty, setAllProperties, setAllProperties, setProperty, setProperty
-
Methods inherited from class de.hybris.platform.jalo.Item
addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addNegativePermission, addPermission, addPositivePermission, assureExtensionsLoaded, changeTypeAfterCreation, checkConstraint, checkItemPermission, checkMandatoryAttribute, checkMandatoryAttribute, checkPermission, checkPermission, checkRemovable, clearPermission, compareTo, ctx, doAfterRemove, doBeforeRemove, equals, getAccessorFor, getAllAttributes, getAllAttributes, getAllAttributes, getAllAttributes, getAllAttributesInternal, getAllLinkedItems, getAndCheckCacheBoundItem, getAttribute, getAttribute, getCacheBoundItem, getComposedType, getComposedTypePK, getCreationTime, getCurrentlyRemovingCount, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItemsCount, getLinkedItemsCount, getLinkedItemsCount, getModificationTime, getNegativePermissions, getOwner, getPermissionMap, getPermissions, getPersistenceVersion, getPK, getPositivePermissions, getRestrictedPrincipals, getSession, getSyncObject, getTenant, getTransientObject, getTransientObjectMap, hashCode, hasRegisteredClassAccessorFor, internal_registerClassAccessorFor, internal_registerNonClassAccessorFor, invalidateLocalCaches, isAlive, isCacheBound, isCurrentlyRemoving, isCurrentlyRemoving, isEmptyRelationValue, isInCreate, isInstanceOf, isItemCheckBeforeRemoveableDisabled, isRelationLocalizationFallbackEnabled, newInstance, notifyExtensionsAfterItemCreation, notifyExtensionsBeforeItemCreation, notifyItemRemoval, notifyManagerAboutItemRemoval, readResolve, registerAccessFor, registerAccessFor, registerJaloInvalidationListeners, remove, remove, removeItemCollection, removeItemCollection, removeLinkedItems, removeLinkedItems, removeLinkedItems, removeLinkedItems, removeLinks, removePartOfItems, removePartOfItems, setAllAttributes, setAllAttributes, setAllAttributesInternal, setAllLinkedItems, setAllLinkedItems, setAllLinkedItems, setAllLinkedItems, setAttribute, setAttribute, setAttributeFromString, setAttributeFromString, setCacheBound, setComposedType, setCreationTime, setImplementation, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setModificationTime, setOwner, setPermissionsByMap, setTransientObject, setUseTA, useTA, writeReplace
-
Methods inherited from class de.hybris.platform.util.BridgeAbstraction
setTenant
-
-
-
-
Method Detail
-
createItem
protected Item createItem(SessionContext ctx, ComposedType type, Item.ItemAttributeMap allAttributes) throws JaloBusinessException
Description copied from class:ItemHas 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. ) duringComposedType.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:
createItemin classGenericItem- Parameters:
ctx- the current session context which this item is created withintype- 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:GenericItemThe default implementation ofGenericItem.getNonInitialAttributes(SessionContext, Item.ItemAttributeMap)assures that the 'registered initial' propertiesGenericItem.getInitialProperties(JaloSession, Item.ItemAttributeMap)will be removed from the 'non initial map'.- Overrides:
getNonInitialAttributesin classGenericItem- Parameters:
ctx- session context with language = NULLallAttributes- aItemAttributeMapcontaning attribute values.- Returns:
- a
ItemAttributeMapcontaining 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:ItemSets all attributes which could not be set duringItem.createItem(SessionContext, ComposedType, ItemAttributeMap). as default this method just iterates over all attribute mappings and sets the value by invokingItem.setAttribute(SessionContext, String, Object).- Overrides:
setNonInitialAttributesin classItem- Parameters:
ctx- session context with language = NULLitem- the newly created itemnonInitialAttributes- the non-initial attributed obtained viaItem.getNonInitialAttributes(SessionContext, ItemAttributeMap)- Throws:
JaloBusinessException
-
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 aCollectionofChangeDescriptors, which were created by thisStep. TheseChangeDescriptorsnormally are created during execution by usingaddChange(CronJob, String, Item, String).- Parameters:
cronJob- theCronJobwhich is used by thisStepfor execution- Returns:
- a
CollectionofChangeDescriptors, which were created by thisStep
-
getChanges
protected java.util.Collection<ChangeDescriptor> getChanges(CronJob cronJob, java.lang.String changeType)
Returns aCollectionofChangeDescriptorsof the specified changeType, which were created by thisStep. TheseChangeDescriptorsnormally are created during execution by usingaddChange(CronJob, String, Item, String).- Parameters:
cronJob- theCronJobwhich is used by theStepfor executionchangeType- specifes which kind of changes should be considered- Returns:
- a
CollectionofChangeDescriptors, which were created by thisStep
-
getChanges
protected java.util.Collection<ChangeDescriptor> getChanges(CronJob cronJob, int start, int count)
Returns aCollectionofChangeDescriptors, which were created by thisStep. The collection contains a ChangeDescriptors which belong to the specified range (start -> start + count).These
ChangeDescriptorsnormally are created during execution by usingaddChange(CronJob, String, Item, String).- Parameters:
cronJob- theCronJobwhich is used by thisStepfor executionstart- the index of the firstChangeDescriptorof the rangecount- the number ofChangeDescriptorsin the range- Returns:
- a
CollectionofChangeDescriptorsof the specified changeType, which were created by thisStep
-
getChanges
protected java.util.Collection<ChangeDescriptor> getChanges(CronJob cronJob, java.lang.String changeType, int start, int count)
Returns aCollectionofChangeDescriptorsof the specified changeType, which were created by thisStep. The collection contains a ChangeDescriptors which belong to the specified range (start -> start + count).These
ChangeDescriptorsnormally are created during execution by usingaddChange(CronJob, String, Item, String).- Parameters:
cronJob- theCronJobwhich is used by thisStepfor executionchangeType- specifes which kind of changes should be consideredstart- the index of the firstChangeDescriptorof the rangecount- the number ofChangeDescriptorsin the range- Returns:
- a
CollectionofChangeDescriptorsof the specified changeType, which were created by thisStep
-
addChange
protected ChangeDescriptor addChange(CronJob cronJob, java.lang.String changeType, Item changedItem, java.lang.String description)
Creates a newChangeDescriptorfor the specifiedCronJobwith the specified changeType, changedItem and description.- Parameters:
cronJob- theCronJobwhich is used for executionchangeType- 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)
Returnstrue, if there areChangeDescriptorsfor thisStepand the specifiedCronJob. Otherwisefalseis returned.- Parameters:
cronJob- theCronJobwhich is used for executionchangeType- specifes which type of change should be considered. This parameter is optional, ifnullis specified, allChangeDescriptorswill be considered- Returns:
true, if there areChangeDescriptorsfor thisStepand the specifiedCronJob
-
getMostRecentChange
protected ChangeDescriptor getMostRecentChange(CronJob cronJob, java.lang.String changeType)
Returns the most recentChangeDescriptorfor thisStepand the specifiedCronJob. Optionally the changeType can be specified.- Parameters:
cronJob- theCronJobwhich is used for executionchangeType- specifes which kind of changes should be considered- Returns:
- Returns the most recent
ChangeDescriptorfor thisStepand the specifiedCronJob
-
canUndo
protected boolean canUndo(CronJob cronJob)
Returnstrue, if thisStepis undoable for the specifiedCronJob. Otherwisefalseis returned.If one step of a CronJob returns
falsethe whole CronJob will stop the undo process. The default implementation returnsfalse. If your subclass ofStepsupports the undo-feature, override this method and returntrue.- Parameters:
cronJob- theCronJobwhich is used for execution- Returns:
true, if thisStepis undoable for the specifiedCronJob- See Also:
undoStep(CronJob)
-
undoStep
protected abstract void undoStep(CronJob cronJob)
Starts the undo processing for thisStepand the specifiedCronJob.
Add your undo logic here to support the undo feature.- Parameters:
cronJob- theCronJobwhich is used for execution- See Also:
canUndo(CronJob)
-
canPerform
protected abstract boolean canPerform(CronJob cronJob)
Returnstrue, if thisStepcan be performed for the specifiedCronJob. Otherwisefalseis returned.- Parameters:
cronJob- theCronJobwhich is used for execution- Returns:
true, if thisStepcan be performed for the specifiedCronJob
-
performStep
protected abstract void performStep(CronJob cronJob) throws AbortCronJobException
Executes this Step using the specifiedCronJob.Implement this method in your
Stepsubclass and add the logic here.- Parameters:
cronJob- theCronJobwhich is used for execution- Throws:
AbortCronJobException- if the execution is aborted due to an error- See Also:
canPerform(CronJob)
-
getFailErrorMode
public EnumerationValue getFailErrorMode()
Returns the EnumerationValueGeneratedCronJobConstants.Enumerations.ErrorMode.FAIL.- Returns:
- the EnumerationValue
GeneratedCronJobConstants.Enumerations.ErrorMode.FAIL
-
getPauseErrorMode
public EnumerationValue getPauseErrorMode()
Returns the EnumerationValueGeneratedCronJobConstants.Enumerations.ErrorMode.PAUSE.- Returns:
- the EnumerationValue
GeneratedCronJobConstants.Enumerations.ErrorMode.PAUSE
-
getIgnoreErrorMode
public EnumerationValue getIgnoreErrorMode()
Returns the EnumerationValueGeneratedCronJobConstants.Enumerations.ErrorMode.IGNORE.- Returns:
- the EnumerationValue
GeneratedCronJobConstants.Enumerations.ErrorMode.IGNORE
-
toString
public java.lang.String toString()
Returns theStringrepresentation of aStep. The representation has the following structure:BatchJob.CODE -> Step.CODE[ sync|async, Step.ERRORMODE]
-
isAbortable
public boolean isAbortable()
Returnstrue, if thisStepis abortable.The default implementation returns always
false. To mark yourStepsubclass as abortable, override this method and returntrue.- Returns:
true, if thisStepis abortable
-
-