Class MetadataCharacteristicModifiedHandler
java.lang.Object
com.broadleafcommerce.metadata.core.service.messaging.characteristic.MetadataCharacteristicModifiedHandler
Handles the
CharacteristicModifiedEvent messages to create, update, or delete metadata
augmentations based on the modified Characteristic.- Since:
- 2.4.x
- Author:
- Sunny Yu
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMetadataCharacteristicModifiedHandler(com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService idempotentConsumptionService, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, AugmentationService<Augmentation> augmentationService) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanaugmentationIsSupported(@NonNull Characteristic characteristic) Whether theCharacteristic.getValueType()is supported for automatic Augmentation creation.protected voidcreateNewAugmentationIfSupported(@NonNull CharacteristicModifiedEvent event) Handles the creation of theCharacteristic, if theCharacteristic.getValueType()is supported.protected com.broadleafcommerce.data.tracking.core.context.ContextInfogetContextInfo(@NonNull CharacteristicModifiedEvent payload, @NonNull com.broadleafcommerce.data.tracking.core.type.OperationType operationType) protected com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionServicecom.fasterxml.jackson.databind.ObjectMappercom.broadleafcommerce.common.extension.TypeFactoryprotected voidhandleDelete(@NonNull CharacteristicModifiedEvent event, @NonNull Optional<Augmentation> maybeAugmentation) Handles the deletion of theCharacteristic.protected voidhandleUpdate(@NonNull CharacteristicModifiedEvent event, @NonNull Optional<Augmentation> maybeAugmentation) Handles the update of theCharacteristic.voidlisten(org.springframework.messaging.Message<CharacteristicModifiedEvent> message) protected voidpopulateJsonPayload(@NonNull Augmentation augmentation, @NonNull Characteristic characteristic) Populates theAugmentation.getJsonPayload()based on the givenCharacteristic.protected voidprocessMessage(@NonNull org.springframework.messaging.Message<CharacteristicModifiedEvent> message) protected StringtranslateCustomValueType(@NonNull String customValueType) Translates the customCharacteristic.getValueType()toFieldTypes.protected StringtranslateValueType(@NonNull String valueType) Translates theCharacteristic.getValueType()toFieldTypes.protected voidupdateExistingAugmentation(@NonNull CharacteristicModifiedEvent event, @NonNull Augmentation augmentation) Updates the existingAugmentationbased on the updatedCharacteristicif applicable.
-
Field Details
-
CONTAINER_KEY
- See Also:
-
-
Constructor Details
-
MetadataCharacteristicModifiedHandler
public MetadataCharacteristicModifiedHandler(com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService idempotentConsumptionService, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, AugmentationService<Augmentation> augmentationService)
-
-
Method Details
-
listen
@StreamListener("characteristicModifiedInputMetadata") public void listen(org.springframework.messaging.Message<CharacteristicModifiedEvent> message) -
processMessage
protected void processMessage(@NonNull @NonNull org.springframework.messaging.Message<CharacteristicModifiedEvent> message) -
handleDelete
protected void handleDelete(@NonNull @NonNull CharacteristicModifiedEvent event, @NonNull @NonNull Optional<Augmentation> maybeAugmentation) Handles the deletion of theCharacteristic.- Parameters:
event- theCharacteristicModifiedEventcontaining the event detailsmaybeAugmentation- anOptionalof existingAugmentation
-
handleUpdate
protected void handleUpdate(@NonNull @NonNull CharacteristicModifiedEvent event, @NonNull @NonNull Optional<Augmentation> maybeAugmentation) Handles the update of theCharacteristic.- Parameters:
event- theCharacteristicModifiedEventcontaining the event detailsmaybeAugmentation- anOptionalof existingAugmentation
-
updateExistingAugmentation
protected void updateExistingAugmentation(@NonNull @NonNull CharacteristicModifiedEvent event, @NonNull @NonNull Augmentation augmentation) Updates the existingAugmentationbased on the updatedCharacteristicif applicable.- Parameters:
event- theCharacteristicModifiedEventcontaining the event detailsaugmentation- the existingAugmentationto update
-
createNewAugmentationIfSupported
protected void createNewAugmentationIfSupported(@NonNull @NonNull CharacteristicModifiedEvent event) Handles the creation of theCharacteristic, if theCharacteristic.getValueType()is supported.- Parameters:
event- theCharacteristicModifiedEventcontaining the event details
-
augmentationIsSupported
Whether theCharacteristic.getValueType()is supported for automatic Augmentation creation.- Parameters:
characteristic- theCharacteristicto evaluate
-
translateValueType
Translates theCharacteristic.getValueType()toFieldTypes.- Parameters:
valueType- theCharacteristic.getValueType()to translate- Returns:
- the String of
FieldTypes
-
translateCustomValueType
Translates the customCharacteristic.getValueType()toFieldTypes.- Parameters:
customValueType- theCharacteristic.getValueType()to translate- Returns:
- the String of
FieldTypes - Throws:
UnsupportedOperationException- if the value type is not recognized and this method is not overridden
-
populateJsonPayload
protected void populateJsonPayload(@NonNull @NonNull Augmentation augmentation, @NonNull @NonNull Characteristic characteristic) Populates theAugmentation.getJsonPayload()based on the givenCharacteristic. .- Parameters:
augmentation- theAugmentationto populatecharacteristic- theCharacteristicto populate with
-
getContextInfo
@Nullable protected com.broadleafcommerce.data.tracking.core.context.ContextInfo getContextInfo(@NonNull @NonNull CharacteristicModifiedEvent payload, @NonNull @NonNull com.broadleafcommerce.data.tracking.core.type.OperationType operationType) -
getIdempotentConsumptionService
protected com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService getIdempotentConsumptionService() -
getObjectMapper
public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper() -
getTypeFactory
public com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getAugmentationService
-