Class AbstractFulfillmentStatusChangeInventoryAdjustmentListener
- java.lang.Object
-
- com.broadleafcommerce.inventory.service.messaging.AbstractInventoryAdjustmentListener
-
- com.broadleafcommerce.inventory.service.messaging.fulfillments.AbstractFulfillmentStatusChangeInventoryAdjustmentListener
-
- Direct Known Subclasses:
FulfillmentCancelledInventoryAdjustmentListener
,FulfillmentFulfilledInventoryAdjustmentListener
public abstract class AbstractFulfillmentStatusChangeInventoryAdjustmentListener extends AbstractInventoryAdjustmentListener
Listens for fulfillment status changes to createInventoryTransactions
and updateSkuInventory
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractFulfillmentStatusChangeInventoryAdjustmentListener.OrderFulfillmentItem
Order fulfillment item fields relevant for adjusting inventory.static class
AbstractFulfillmentStatusChangeInventoryAdjustmentListener.OrderItem
Summarization of cart item fields relevant for creating an inventory reservation request.
-
Field Summary
Fields Modifier and Type Field Description protected static String
FULFILLMENT_ID_PATH
protected static String
FULFILLMENT_ITEMS_PATH
protected static String
FULFILLMENT_STATUS_PATH
static String
NEVER_RESERVATION_STRATEGY
protected static String
ORDER_ITEMS_PATH
-
Fields inherited from class com.broadleafcommerce.inventory.service.messaging.AbstractInventoryAdjustmentListener
APPLICATION_ID_PATH, TENANT_ID_PATH
-
-
Constructor Summary
Constructors Constructor Description AbstractFulfillmentStatusChangeInventoryAdjustmentListener(com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService idempotentConsumptionService, com.broadleafcommerce.common.extension.TypeFactory typeFactory, SkuInventoryService<SkuInventory> skuInventoryService)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected List<SkuInventoryAdjustmentRequestItem>
buildRequestedItems(List<AbstractFulfillmentStatusChangeInventoryAdjustmentListener.OrderFulfillmentItem> fulfillmentItems, List<AbstractFulfillmentStatusChangeInventoryAdjustmentListener.OrderItem> orderItems)
BuildsSkuInventoryAdjustmentRequestItems
for each of thefulfillmentItems
.protected SkuInventoryAdjustmentRequest
buildSkuInventoryAdjustmentRequest(@NonNull com.jayway.jsonpath.DocumentContext jsonContext, @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Builds theSkuInventoryAdjustmentRequest
based on the fulfillment info in the status change message.protected abstract String
getValidFulfillmentStatus()
Supplies the valid fulfillment status which can be handled.protected abstract void
performInventoryAdjustment(SkuInventoryAdjustmentRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Execute the required inventory adjustment for the status change.void
process(@NonNull org.springframework.messaging.Message<String> message)
Extracts the message, createsInventoryTransactions
and updatesSkuInventory
.-
Methods inherited from class com.broadleafcommerce.inventory.service.messaging.AbstractInventoryAdjustmentListener
buildContextInfo, buildContextInfo, getDocumentContext, getIdempotentConsumptionService, getSkuInventoryService, getSkuReferenceFieldType, getTypeFactory
-
-
-
-
Field Detail
-
FULFILLMENT_ID_PATH
protected static final String FULFILLMENT_ID_PATH
- See Also:
- Constant Field Values
-
FULFILLMENT_STATUS_PATH
protected static final String FULFILLMENT_STATUS_PATH
- See Also:
- Constant Field Values
-
FULFILLMENT_ITEMS_PATH
protected static final String FULFILLMENT_ITEMS_PATH
- See Also:
- Constant Field Values
-
ORDER_ITEMS_PATH
protected static final String ORDER_ITEMS_PATH
- See Also:
- Constant Field Values
-
NEVER_RESERVATION_STRATEGY
public static final String NEVER_RESERVATION_STRATEGY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractFulfillmentStatusChangeInventoryAdjustmentListener
public AbstractFulfillmentStatusChangeInventoryAdjustmentListener(com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService idempotentConsumptionService, com.broadleafcommerce.common.extension.TypeFactory typeFactory, SkuInventoryService<SkuInventory> skuInventoryService)
-
-
Method Detail
-
process
public void process(@NonNull @NonNull org.springframework.messaging.Message<String> message)
Extracts the message, createsInventoryTransactions
and updatesSkuInventory
.- Parameters:
message
- The fulfillment cancelled event message
-
getValidFulfillmentStatus
protected abstract String getValidFulfillmentStatus()
Supplies the valid fulfillment status which can be handled.- Returns:
- the valid fulfillment status which can be handled
-
buildSkuInventoryAdjustmentRequest
protected SkuInventoryAdjustmentRequest buildSkuInventoryAdjustmentRequest(@NonNull @NonNull com.jayway.jsonpath.DocumentContext jsonContext, @NonNull @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Builds theSkuInventoryAdjustmentRequest
based on the fulfillment info in the status change message.- Parameters:
jsonContext
- aDocumentContext
representation of the fulfillment message payloadcontextInfo
- Context information around sandbox and multitenant state.- Returns:
- The
SkuInventoryAdjustmentRequest
based on the fulfillment info in the status change message.
-
buildRequestedItems
protected List<SkuInventoryAdjustmentRequestItem> buildRequestedItems(List<AbstractFulfillmentStatusChangeInventoryAdjustmentListener.OrderFulfillmentItem> fulfillmentItems, List<AbstractFulfillmentStatusChangeInventoryAdjustmentListener.OrderItem> orderItems)
BuildsSkuInventoryAdjustmentRequestItems
for each of thefulfillmentItems
.- Parameters:
fulfillmentItems
- the fulfillment items to build adjustment request items fororderItems
- the order items from the fulfillment's order which contain item SKU data- Returns:
- inventory adjustment request items for the
fulfillmentItems
-
performInventoryAdjustment
protected abstract void performInventoryAdjustment(SkuInventoryAdjustmentRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) throws InventoryUnavailableException, InventoryNotReservedException
Execute the required inventory adjustment for the status change.- Parameters:
request
- the request to adjust inventorycontextInfo
- context information surrounding sandboxing and multitenant state- Throws:
InventoryUnavailableException
- if inventory could not be decrementedInventoryNotReservedException
- if inventory was not already reserved
-
-