Class AbstractCatalogEntityDeletedEventHandler
java.lang.Object
com.broadleafcommerce.catalog.messaging.entitydeletion.handlers.AbstractCatalogEntityDeletedEventHandler
- All Implemented Interfaces:
CatalogEntityDeletedEventHandler
- Direct Known Subclasses:
CategoryAssetCatalogEntityDeletedEventHandler
,CategoryProductCatalogEntityDeletedEventHandler
,OptionTemplateCatalogEntityDeletedEventHandler
,ProductAssetCatalogEntityDeletedEventHandler
,ProductTagCatalogEntityDeletedEventHandler
,PromotionalCategoryProductCatalogEntityDeletedEventHandler
,PromotionalProductCatalogEntityDeletedEventHandler
,TranslationCatalogEntityDeletedEventHandler
,VariantCatalogEntityDeletedEventHandler
public abstract class AbstractCatalogEntityDeletedEventHandler
extends Object
implements CatalogEntityDeletedEventHandler
Provides common processing functionality to all
CatalogEntityDeletedEventHandler
instances.- Author:
- Sunny Yu
-
Constructor Summary
ConstructorDescriptionAbstractCatalogEntityDeletedEventHandler
(com.broadleafcommerce.data.tracking.core.tenant.service.CommonCatalogService<com.broadleafcommerce.data.tracking.core.tenant.domain.Catalog> catalogService, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.broadleafcommerce.data.tracking.core.web.ContextRequestHydrator contextRequestHydrator) -
Method Summary
Modifier and TypeMethodDescriptionprotected com.broadleafcommerce.data.tracking.core.context.ContextInfo
buildContext
(@NonNull com.broadleafcommerce.data.tracking.core.type.OperationType operationType, @NonNull com.broadleafcommerce.data.tracking.core.context.ContextRequest contextRequest) protected com.broadleafcommerce.data.tracking.core.context.ContextInfo
buildHydratedContextInfo
(@NonNull com.broadleafcommerce.data.tracking.core.context.ContextRequest dehydratedContextRequest) Hydrates and builds aContextInfo
based on the givenContextRequest
.protected com.broadleafcommerce.data.tracking.core.context.ContextInfo
buildMatchingContextInfo
(@NonNull org.springframework.context.ApplicationEvent event) Builds a hydratedContextInfo
that matches the context of the deleted entity from the given event.protected com.broadleafcommerce.data.tracking.core.context.ContextRequest
buildMatchingContextRequest
(@NonNull com.broadleafcommerce.common.messaging.notification.domain.InternalPersistenceEvent event) Builds a matchingContextInfo
based on the givenInternalPersistenceEvent
.protected com.broadleafcommerce.data.tracking.core.context.ContextRequest
buildMatchingContextRequest
(@NonNull com.broadleafcommerce.data.tracking.core.catalog.CatalogEntityDeletedEvent event) Builds a matchingContextInfo
based on the givenCatalogEntityDeletedEvent
.boolean
canHandle
(@NonNull org.springframework.context.ApplicationEvent event) Whether the givenApplicationEvent
can be handled.protected com.broadleafcommerce.data.tracking.core.tenant.service.CommonCatalogService<com.broadleafcommerce.data.tracking.core.tenant.domain.Catalog>
protected com.broadleafcommerce.data.tracking.core.web.ContextRequestHydrator
Class<?>
getDeletedEntityClassFromEvent
(@NonNull org.springframework.context.ApplicationEvent event) Gets the deleted entity class from the given event.com.broadleafcommerce.data.tracking.core.Trackable
getDeletedEntityFromEvent
(@NonNull org.springframework.context.ApplicationEvent event) Gets the deleted entity from the given event.protected com.fasterxml.jackson.databind.ObjectMapper
An abstract method to return aSet
of classes of the deleted entities that are supported.protected com.broadleafcommerce.common.extension.TypeFactory
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.broadleafcommerce.catalog.messaging.entitydeletion.handlers.CatalogEntityDeletedEventHandler
handle
-
Constructor Details
-
AbstractCatalogEntityDeletedEventHandler
public AbstractCatalogEntityDeletedEventHandler(com.broadleafcommerce.data.tracking.core.tenant.service.CommonCatalogService<com.broadleafcommerce.data.tracking.core.tenant.domain.Catalog> catalogService, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.broadleafcommerce.data.tracking.core.web.ContextRequestHydrator contextRequestHydrator)
-
-
Method Details
-
getSupportedDeletedEntityClasses
An abstract method to return aSet
of classes of the deleted entities that are supported.For example, if a
CatalogEntityDeletedEventHandler
instance can only handle the event when theJpaProduct
is deleted, this handler instance would be skipped when the emitted event is for aJpaCategoryProduct
. -
getDeletedEntityClassFromEvent
public Class<?> getDeletedEntityClassFromEvent(@NonNull @NonNull org.springframework.context.ApplicationEvent event) Gets the deleted entity class from the given event.- Parameters:
event
- theApplicationEvent
that was emitted for the deleted entity- Returns:
- the deleted entity class from the given event
-
getDeletedEntityFromEvent
public com.broadleafcommerce.data.tracking.core.Trackable getDeletedEntityFromEvent(@NonNull @NonNull org.springframework.context.ApplicationEvent event) Gets the deleted entity from the given event.- Parameters:
event
- theApplicationEvent
that was emitted for the deleted entity- Returns:
- the deleted entity from the given event
-
canHandle
public boolean canHandle(@NonNull @NonNull org.springframework.context.ApplicationEvent event) Description copied from interface:CatalogEntityDeletedEventHandler
Whether the givenApplicationEvent
can be handled.- Specified by:
canHandle
in interfaceCatalogEntityDeletedEventHandler
- Parameters:
event
- theApplicationEvent
that potentially represents the catalog entity deletion- Returns:
- true if the given
ApplicationEvent
can be handled, otherwise false
-
buildMatchingContextInfo
protected com.broadleafcommerce.data.tracking.core.context.ContextInfo buildMatchingContextInfo(@NonNull @NonNull org.springframework.context.ApplicationEvent event) throws UnsupportedOperationException Builds a hydratedContextInfo
that matches the context of the deleted entity from the given event.- Parameters:
event
- theApplicationEvent
that was emitted for the deleted entity- Returns:
- a
ContextInfo
that matches the context of the deleted entity from the given event - Throws:
UnsupportedOperationException
- if the givenApplicationEvent
is not supported
-
buildMatchingContextRequest
protected com.broadleafcommerce.data.tracking.core.context.ContextRequest buildMatchingContextRequest(@NonNull @NonNull com.broadleafcommerce.common.messaging.notification.domain.InternalPersistenceEvent event) Builds a matchingContextInfo
based on the givenInternalPersistenceEvent
. -
buildMatchingContextRequest
protected com.broadleafcommerce.data.tracking.core.context.ContextRequest buildMatchingContextRequest(@NonNull @NonNull com.broadleafcommerce.data.tracking.core.catalog.CatalogEntityDeletedEvent event) Builds a matchingContextInfo
based on the givenCatalogEntityDeletedEvent
. -
buildHydratedContextInfo
protected com.broadleafcommerce.data.tracking.core.context.ContextInfo buildHydratedContextInfo(@NonNull @NonNull com.broadleafcommerce.data.tracking.core.context.ContextRequest dehydratedContextRequest) Hydrates and builds aContextInfo
based on the givenContextRequest
.Note that
ContextRequest.isForceFilterByCatalogExcludeInheritance()
is set totrue
, which is to ensure that the relationship entities are only fetched from the specified catalog instead of from the entire catalog hierarchy. Since the catalog tree is walked and an event is emitted for each level, there is no need to fetch entities from other catalogs that are not explicitly specified in the current context.- Parameters:
dehydratedContextRequest
- theContextRequest
to hydrate- Returns:
- a hydrated
ContextInfo
based on the givenContextRequest
-
buildContext
protected com.broadleafcommerce.data.tracking.core.context.ContextInfo buildContext(@NonNull @NonNull com.broadleafcommerce.data.tracking.core.type.OperationType operationType, @NonNull @NonNull com.broadleafcommerce.data.tracking.core.context.ContextRequest contextRequest) -
getCatalogService
protected com.broadleafcommerce.data.tracking.core.tenant.service.CommonCatalogService<com.broadleafcommerce.data.tracking.core.tenant.domain.Catalog> getCatalogService() -
getObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper() -
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getContextRequestHydrator
protected com.broadleafcommerce.data.tracking.core.web.ContextRequestHydrator getContextRequestHydrator()
-