Class WorkflowTransitionHelper
- java.lang.Object
-
- com.broadleafcommerce.data.tracking.core.transition.WorkflowTransitionHelper
-
- All Implemented Interfaces:
WorkflowTransitionService
public class WorkflowTransitionHelper extends Object implements WorkflowTransitionService
Helper class for executing aTrackable
entity promotion and persisting state after.- Author:
- Jeff Fischer
-
-
Field Summary
Fields Modifier and Type Field Description static String
LOCK_CONCEPT_KEY
-
Constructor Summary
Constructors Constructor Description WorkflowTransitionHelper(TrackableRepository<Trackable> repository, WorkflowMapper mapper, com.broadleafcommerce.common.messaging.repository.ResourceLockRepository<?,?> resourceLockRepository, com.broadleafcommerce.common.messaging.notification.NotificationManager notificationManager, WorkflowRequestCompletionNotifier completionNotifier, com.broadleafcommerce.common.messaging.notification.NotificationStateService notificationStateService, com.broadleafcommerce.common.messaging.notification.MessageSerializationHelper helper)
WorkflowTransitionHelper(TrackableRepository<Trackable> repository, WorkflowMapper mapper, CommonCatalogService<Catalog> catalogService, com.broadleafcommerce.common.messaging.repository.ResourceLockRepository<?,?> resourceLockRepository, com.broadleafcommerce.common.messaging.notification.NotificationManager notificationManager, WorkflowRequestCompletionNotifier completionNotifier, com.broadleafcommerce.common.messaging.notification.NotificationStateService notificationStateService, com.broadleafcommerce.common.messaging.notification.MessageSerializationHelper helper)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
applyDeployment(WorkflowDeployRequest request, Trackable target, Trackable original)
Apply changes from an "original" entity to a target production entity (if any).protected void
applyPromotion(WorkflowPromoteRequest request, Trackable target, Trackable original)
Apply changes from an "original" entity to a target sandbox entity (if any).protected void
applyReject(WorkflowRejectRequest request, Trackable target, Trackable original)
Apply one or more changes related to a promotion from an "original" entity to a target user sandbox entity (if any).void
deploy(WorkflowDeployRequest request)
Perform the deployment, moving the requested item forward to production state.protected TempOverrideMapResponse
evaluateForTemporaryOverride(WorkflowDeployRequest request, Trackable target, Trackable original)
In the case where a change was propagated after deployment viaVendorSandboxPropagationHandler
, temporary override state for an application can be created.protected boolean
handleRecordFailure(TransitionRequest request, Exception e)
Handle failure to find the target record for the transitionprotected void
handleTransitionFailure(TransitionRequest request, Trackable original, Exception e)
Handle failure of a transition request and notify the messaging system of the failureprotected void
notifyOfCompletion(Trackable domain)
Inform the system via a message of typeWorkflowRequestCompletionProducer.TYPE
that transition processing is complete.protected void
notifyOfPersistence(Trackable domain)
Inform the system via a message of typePersistenceProducer.TYPE
that an entity has been persisted.void
promote(WorkflowPromoteRequest request)
Perform the promotion, moving the requested item forward in the workflowprotected void
propagate(Trackable deployed, String parentCatalog, boolean isDelete, String propagationId)
Deprecated.Only supportsDefaultPropagationHandler
.protected void
propagate(Trackable deployed, String parentCatalog, OperationType changeType, String propagationId)
Given a deployed catalog discriminated change, recurse through versions of the entity in child catalogs and transfer the deployed changes using the process defined implementations ofPropagationHandler
.void
rebase(WorkflowRebaseRequest request)
Perform the rebase, bringing an original item up-to-date with missing changes from the target that were created by another user.void
reject(WorkflowRejectRequest request)
Perform the reversal, move the requested changes backward in the workflow to the originating author's user state.void
revert(WorkflowRevertRequest request)
Perform the reversal, archiving the user state sandbox entity.protected void
updateCompletionState(Trackable originalTrackable, Tracking advancedTracking, TransitionRequest transitionRequest, boolean success, Exception e)
Setup the initialNotificationState
on aTrackable
entity in regard to the sending status of theWorkflowRequestCompletionProducer.TYPE
message for transition completion.protected void
updatePersistenceState(Trackable trackable)
Setup the initialNotificationState
on aTrackable
entity in regard to the sending status of thePersistenceProducer.TYPE
message for a persistence event.WorkflowTransitionHelper
withEventPublisher(org.springframework.context.ApplicationEventPublisher publisher)
WorkflowTransitionHelper
withPropagationManager(PropagationManager propagationManager)
WorkflowTransitionHelper
withSingleIndexRequestMessageFactory(SingleIndexRequestMessageFactory factory)
WorkflowTransitionHelper
withTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
-
Field Detail
-
LOCK_CONCEPT_KEY
public static final String LOCK_CONCEPT_KEY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
WorkflowTransitionHelper
public WorkflowTransitionHelper(TrackableRepository<Trackable> repository, WorkflowMapper mapper, CommonCatalogService<Catalog> catalogService, com.broadleafcommerce.common.messaging.repository.ResourceLockRepository<?,?> resourceLockRepository, com.broadleafcommerce.common.messaging.notification.NotificationManager notificationManager, WorkflowRequestCompletionNotifier completionNotifier, com.broadleafcommerce.common.messaging.notification.NotificationStateService notificationStateService, com.broadleafcommerce.common.messaging.notification.MessageSerializationHelper helper)
-
WorkflowTransitionHelper
public WorkflowTransitionHelper(TrackableRepository<Trackable> repository, WorkflowMapper mapper, com.broadleafcommerce.common.messaging.repository.ResourceLockRepository<?,?> resourceLockRepository, com.broadleafcommerce.common.messaging.notification.NotificationManager notificationManager, WorkflowRequestCompletionNotifier completionNotifier, com.broadleafcommerce.common.messaging.notification.NotificationStateService notificationStateService, com.broadleafcommerce.common.messaging.notification.MessageSerializationHelper helper)
-
-
Method Detail
-
withSingleIndexRequestMessageFactory
public WorkflowTransitionHelper withSingleIndexRequestMessageFactory(SingleIndexRequestMessageFactory factory)
-
withPropagationManager
public WorkflowTransitionHelper withPropagationManager(PropagationManager propagationManager)
-
withTypeFactory
public WorkflowTransitionHelper withTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
withEventPublisher
public WorkflowTransitionHelper withEventPublisher(org.springframework.context.ApplicationEventPublisher publisher)
-
promote
@SuppressNotification("SINGLE_INDEX_REQUEST") public void promote(WorkflowPromoteRequest request)
Description copied from interface:WorkflowTransitionService
Perform the promotion, moving the requested item forward in the workflow- Specified by:
promote
in interfaceWorkflowTransitionService
- Parameters:
request
- The request for aTrackable
entity promotion
-
updatePersistenceState
protected void updatePersistenceState(Trackable trackable)
Setup the initialNotificationState
on aTrackable
entity in regard to the sending status of thePersistenceProducer.TYPE
message for a persistence event.- Parameters:
trackable
-Trackable
the entity which experienced a persistence event
-
notifyOfPersistence
protected void notifyOfPersistence(Trackable domain)
Inform the system via a message of typePersistenceProducer.TYPE
that an entity has been persisted.- Parameters:
domain
- the entity that was persisted
-
rebase
@SuppressNotification("SINGLE_INDEX_REQUEST") public void rebase(WorkflowRebaseRequest request)
Description copied from interface:WorkflowTransitionService
Perform the rebase, bringing an original item up-to-date with missing changes from the target that were created by another user. If the original has conflicting changes, those changes win.- Specified by:
rebase
in interfaceWorkflowTransitionService
- Parameters:
request
- Perform the rebase, bringing an original item up-to-date with missing changes
-
deploy
@SuppressNotification("SINGLE_INDEX_REQUEST") public void deploy(WorkflowDeployRequest request)
Description copied from interface:WorkflowTransitionService
Perform the deployment, moving the requested item forward to production state.- Specified by:
deploy
in interfaceWorkflowTransitionService
- Parameters:
request
- The request for aTrackable
entity deployment
-
reject
@SuppressNotification("SINGLE_INDEX_REQUEST") public void reject(WorkflowRejectRequest request)
Description copied from interface:WorkflowTransitionService
Perform the reversal, move the requested changes backward in the workflow to the originating author's user state.- Specified by:
reject
in interfaceWorkflowTransitionService
- Parameters:
request
- The request for aTrackable
entity change rejection
-
revert
@SuppressNotification("SINGLE_INDEX_REQUEST") public void revert(WorkflowRevertRequest request)
Description copied from interface:WorkflowTransitionService
Perform the reversal, archiving the user state sandbox entity.- Specified by:
revert
in interfaceWorkflowTransitionService
- Parameters:
request
- The request for aTrackable
entity change reversion
-
notifyOfCompletion
protected void notifyOfCompletion(Trackable domain)
Inform the system via a message of typeWorkflowRequestCompletionProducer.TYPE
that transition processing is complete.- Parameters:
domain
- The entity that was transitioned
-
updateCompletionState
protected void updateCompletionState(Trackable originalTrackable, Tracking advancedTracking, TransitionRequest transitionRequest, boolean success, @Nullable Exception e)
Setup the initial
NotificationState
on aTrackable
entity in regard to the sending status of theWorkflowRequestCompletionProducer.TYPE
message for transition completion.NotificationState
s are ack'ed on theoriginalTracking
.- Parameters:
originalTrackable
- The original item that was promoted in. This receives NotificationStatesadvancedTracking
- the most updatedTracking
available. In the case of a promotion, this represents the promoted state. In the case of rebases, this is the same asoriginalTracking
. Can be null if not available (like in a revert)transitionRequest
- The initial request driving the transitionsuccess
- Whether or not the transition was successful (or failed with an error)e
- The exception that caused a failed transition, if applicable
-
handleTransitionFailure
protected void handleTransitionFailure(TransitionRequest request, Trackable original, Exception e)
Handle failure of a transition request and notify the messaging system of the failure- Parameters:
request
- The transition requestoriginal
- The entity targeted for transitione
- The exception that occurred during the transition
-
applyReject
protected void applyReject(WorkflowRejectRequest request, Trackable target, Trackable original)
Apply one or more changes related to a promotion from an "original" entity to a target user sandbox entity (if any). In the case of no target, then clone and update the original to establish target state.- Parameters:
request
- The request for aTrackable
entity rejectiontarget
- any available pre-existing target stateoriginal
- The entity containing changes to reject
-
applyPromotion
protected void applyPromotion(WorkflowPromoteRequest request, Trackable target, Trackable original)
Apply changes from an "original" entity to a target sandbox entity (if any). In the case of no target (i.e. create flow), then clone and update the original to establish target state.Will emit
PersistenceProducer.TYPE
andWorkflowRequestCompletionProducer.TYPE
messages after performing changes.- Parameters:
request
- The request for aTrackable
entity promotiontarget
- any available pre-existing target stateoriginal
- The entity containing changes to promote
-
applyDeployment
protected void applyDeployment(WorkflowDeployRequest request, Trackable target, Trackable original)
Apply changes from an "original" entity to a target production entity (if any). In the case of no target (i.e. create flow), then clone and update the original to establish target state.Will emit
PersistenceProducer.TYPE
andWorkflowRequestCompletionProducer.TYPE
messages after performing changes.- Parameters:
request
- The request for aTrackable
entity deploymenttarget
- any available pre-existing target stateoriginal
- The entity to deploy
-
evaluateForTemporaryOverride
protected TempOverrideMapResponse evaluateForTemporaryOverride(WorkflowDeployRequest request, Trackable target, Trackable original)
In the case where a change was propagated after deployment viaVendorSandboxPropagationHandler
, temporary override state for an application can be created. During subsequent deployment of that propagated application state, it is necessary to cleanup any temporary state that was introduced byVendorSandboxPropagationHandler
. This method checks the request (specifically,WorkflowDeployRequest.isRemoveTemporaryOverride()
, and also evaluates entity state to make a final determination viaTempOverrideMapResponse
.- Parameters:
request
- The deployment requesttarget
- The state receiving deployment, if applicableoriginal
- The state being transitioned from earlier promoted status- Returns:
- The evaluation results
-
propagate
protected void propagate(Trackable deployed, String parentCatalog, OperationType changeType, String propagationId)
Given a deployed catalog discriminated change, recurse through versions of the entity in child catalogs and transfer the deployed changes using the process defined implementations ofPropagationHandler
.PropagationHandler
instances are registered with Spring and ordered. The first instance capable of handling is used and others are ignored. This process is controlled by thePropagationManager
.- Parameters:
deployed
- The deployed item containing changes to propagateparentCatalog
- The catalog whose children will be checked for propagation itemschangeType
- The type of operation to be propagated (CREATE,UPDATE,DELETE)propagationId
- An id that identifies changes as part of this propagation. SeeChangeDetail.getPropagationId()
.
-
propagate
@Deprecated protected void propagate(Trackable deployed, String parentCatalog, boolean isDelete, String propagationId)
Deprecated.Only supportsDefaultPropagationHandler
. Usepropagate(Trackable, String, OperationType, String)
instead for full propagation support.propagate(Trackable, String, OperationType, String)
usage requiresbroadleaf.sandbox.propagation.enabled
property be set to true.Given a deployed catalog discriminated change, recurse through versions of the entity in child catalogs and transfer the deployed changes using the process defined inWorkflowMapper.propagateMap(Trackable, Trackable, boolean, String)
.- Parameters:
deployed
- The deployed item containing changes to propagateparentCatalog
- The catalog whose children will be checked for propagation itemsisDelete
- Whether or not the change is a deletionpropagationId
- An id that identifies changes as part of this propagation. SeeChangeDetail.getPropagationId()
.
-
handleRecordFailure
protected boolean handleRecordFailure(TransitionRequest request, Exception e)
Handle failure to find the target record for the transition- Parameters:
request
- The transition requeste
- The exception that occurred during the fetch- Returns:
- Whether or not the message was successfully sent to the broker
-
-