Interface ContextualInventoryService
- All Superinterfaces:
InventoryService
- All Known Implementing Classes:
InventoryServiceImpl
InventoryService but with optional, additional context information. This context
can then be passed on to an InventoryServiceExtensionHandler- Author:
- Phillip Verheyden (phillipuniverse)
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbuildSkuInventoryMap(Order order) Convenience method to build the sku inventory map given anOrdervoidcheckSkuAvailability(Order order, Sku sku, Integer requestedQuantity) voidUsually invoked fromDecrementInventoryActivityvoiddecrementInventory(Sku sku, int quantity, Map<String, Object> context) Pass through fordecrementInventory(Map, Map)voidCallers that invoke this method directly should check for aROLLBACK_STATE_KEYin the given context.voidincrementInventory(Sku sku, int quantity, Map<String, Object> context) booleanisAvailable(Sku sku, int quantity, Map<String, Object> context) voidreconcileChangeOrderInventory(Map<Sku, Integer> decrementSkuQuantities, Map<Sku, Integer> incrementSkuQuantities, Map<String, Object> context) Explicit method that defines exactly how to reconcile inventory in the event of a change order.retrieveQuantitiesAvailable(Collection<Sku> skus, Map<String, Object> context) retrieveQuantityAvailable(Sku sku, Map<String, Object> context) Methods inherited from interface org.broadleafcommerce.core.inventory.service.InventoryService
checkBasicAvailablility, decrementInventory, decrementInventory, incrementInventory, incrementInventory, isAvailable, retrieveQuantitiesAvailable, retrieveQuantityAvailable
-
Field Details
-
ORDER_KEY
Used as a key in the context map methods below. This is used for the current order that should be used to evaluate the methods below- See Also:
-
CHANGE_ORDER_KEY
Used as a key in the context map methods below. This is used for the newly created change order that should be used in evaluation of thereconcileChangeOrderInventory(java.util.Map, java.util.Map, java.util.Map)below- See Also:
-
ROLLBACK_STATE_KEY
Used as a key in the context map methods below. This key is normally populated from theDecrementInventoryActivityand is utilized in theDecrementInventoryRollbackHandler. This can be cast to a Map<String, Object> and is designed such that when it is used, non-read operations (decrement and increment) can add what actually happened so that it can be reversed.- See Also:
-
-
Method Details
-
retrieveQuantityAvailable
- Parameters:
context- can be null. If not null, this should at least contain the#CART_CONTEXT_KEY
-
retrieveQuantitiesAvailable
- Parameters:
context- can be null. If not null, this should at least contain the#CART_CONTEXT_KEY
-
isAvailable
- Parameters:
context- can be null. If not null, this should at least contain the#CART_CONTEXT_KEY
-
decrementInventory
void decrementInventory(Sku sku, int quantity, Map<String, Object> context) throws InventoryUnavailableExceptionPass through for
decrementInventory(Map, Map)- Throws:
InventoryUnavailableException
-
decrementInventory
void decrementInventory(Map<Sku, Integer> skuQuantities, Map<String, throws InventoryUnavailableExceptionObject> context) Usually invoked from
DecrementInventoryActivityCallers that invoke this method directly should check the given context object for a
ROLLBACK_STATE_KEY. This will contain information about what actually happened in terms of decrementing inventory. For implementers of this interfaceImplementers of this method (explicitly those that are utilizing the
InventoryServiceExtensionHandler) should populate aROLLBACK_STATE_KEYwithin the given context in order to communicate back to the caller what actually happened while decrementing inventory so that it can be undone later- Parameters:
context- can be null. If not null, this should at least contain theORDER_KEYand/or theROLLBACK_STATE_KEY- Throws:
InventoryUnavailableException
-
incrementInventory
-
incrementInventory
Callers that invoke this method directly should check for a
ROLLBACK_STATE_KEYin the given context. This will contain information about what actually happened in terms of decrementing inventoryImplementers of this method (explicitly those that are utilizing the
InventoryServiceExtensionHandler) should populate aROLLBACK_STATE_KEYwithin the given context in order to communicate back to the caller what actually happened while decrementing inventory so that it can be undone later- Parameters:
context- can be null. If not null, this should at least contain theROLLBACK_STATE_KEY
-
reconcileChangeOrderInventory
void reconcileChangeOrderInventory(Map<Sku, Integer> decrementSkuQuantities, Map<Sku, throws InventoryUnavailableExceptionInteger> incrementSkuQuantities, Map<String, Object> context) Explicit method that defines exactly how to reconcile inventory in the event of a change order. This usually occurs after an order has been submitted and any inventory changes and reservations/holds have already been committed.
Implementers of this method should assume that the quantities passed in are deltas and represent the changed quantities (either incremented or decremented) from the old order to the newly changed order.
- Parameters:
decrementSkuQuantities- - the delta change of sku quantities to decrementincrementSkuQuantities- - the delta change of sku quantities to incrementcontext-- Throws:
InventoryUnavailableException
-
buildSkuInventoryMap
Convenience method to build the sku inventory map given an
Order- Parameters:
order-- Returns:
- a SKU to Quantity map represented by the items and quantities on the fulfillment group and fulfillment group items in the order.
-
checkSkuAvailability
void checkSkuAvailability(Order order, Sku sku, Integer requestedQuantity) throws InventoryUnavailableException - Parameters:
order-sku-requestedQuantity-- Throws:
InventoryUnavailableException
-