Class DefaultPropagationManager
java.lang.Object
com.broadleafcommerce.data.tracking.core.transition.DefaultPropagationManager
- All Implemented Interfaces:
PropagationManager
Default version of
PropagationManager
- Author:
- Jeff Fischer
-
Constructor Summary
ConstructorDescriptionDefaultPropagationManager
(CommonCatalogService<? extends Catalog> catalogService, List<PropagationHandler> handlers) -
Method Summary
Modifier and TypeMethodDescriptionprotected org.springframework.context.ApplicationEventPublisher
protected Trackable
handleCreate
(Trackable incoming, String incomingCatalog, String parentCatalog, String propagationId, TrackableRepository<Trackable> repository) protected Trackable
handleDelete
(Trackable incoming, String incomingCatalog, String parentCatalog, String propagationId, Trackable candidate, TrackableRepository<Trackable> repository) protected Trackable
handleUpdate
(Trackable incoming, String incomingCatalog, String parentCatalog, String propagationId, Trackable candidate, TrackableRepository<Trackable> repository) protected void
notifyCatalogEntityDeletion
(Trackable entity, String catalogId) Inform the system via aCatalogEntityDeletedEvent
message that a catalog entity has been deleted if applicable.void
propagate
(Trackable deployed, String parentCatalog, OperationType changeType, String propagationId, TrackableRepository<Trackable> repository) 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
.protected void
propagateThroughChildCatalogs
(Trackable deployed, String parentCatalog, OperationType changeType, String propagationId, TrackableRepository<Trackable> repository) Propagates the changes for each child catalog of the given parent catalog.void
setEventPublisher
(org.springframework.context.ApplicationEventPublisher eventPublisher)
-
Constructor Details
-
DefaultPropagationManager
public DefaultPropagationManager(CommonCatalogService<? extends Catalog> catalogService, List<PropagationHandler> handlers)
-
-
Method Details
-
propagate
@SuppressNotification("SINGLE_INDEX_REQUEST") public void propagate(Trackable deployed, String parentCatalog, OperationType changeType, String propagationId, TrackableRepository<Trackable> repository) Description copied from interface:PropagationManager
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.For deletion, a
CatalogEntityDeletedEvent
is emitted at the parent catalog level, and then one for each child catalog if propagation candidate doesn't exist. If propagation candidate exists for a child catalog,InternalPersistenceEvent
is used instead.- Specified by:
propagate
in interfacePropagationManager
- 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()
.repository
- The repository responsible for persistence of the entity type
-
propagateThroughChildCatalogs
protected void propagateThroughChildCatalogs(Trackable deployed, String parentCatalog, OperationType changeType, String propagationId, TrackableRepository<Trackable> repository) Propagates the changes for each child catalog of the given parent catalog.- 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()
.repository
- The repository responsible for persistence of the entity type
-
handleDelete
-
handleCreate
-
handleUpdate
-
notifyCatalogEntityDeletion
Inform the system via aCatalogEntityDeletedEvent
message that a catalog entity has been deleted if applicable.This is useful for consuming services to delete any relationship entities that are no longer relevant.
The given entity class is still checked for whether it's
CatalogTrackable
, to avoid sending the event for entities that only haveTrackableBehavior.CATALOG
through its inheritance from another entity, e.g. translations.- Parameters:
entity
- the entity to notify deletion if it's CatalogTrackablecatalogId
- the id of the catalog to emit the event for- See Also:
-
getEventPublisher
protected org.springframework.context.ApplicationEventPublisher getEventPublisher() -
setEventPublisher
@Autowired public void setEventPublisher(@Nullable org.springframework.context.ApplicationEventPublisher eventPublisher)
-