Interface ContextualInventoryService

All Superinterfaces:
InventoryService
All Known Implementing Classes:
InventoryServiceImpl

public interface ContextualInventoryService extends InventoryService
Provides the same methods from InventoryService but with optional, additional context information. This context can then be passed on to an InventoryServiceExtensionHandler
Author:
Phillip Verheyden (phillipuniverse)
  • Field Details

  • Method Details

    • retrieveQuantityAvailable

      Integer retrieveQuantityAvailable(Sku sku, Map<String,Object> context)
      Parameters:
      context - can be null. If not null, this should at least contain the #CART_CONTEXT_KEY
    • retrieveQuantitiesAvailable

      Map<Sku,Integer> retrieveQuantitiesAvailable(Collection<Sku> skus, Map<String,Object> context)
      Parameters:
      context - can be null. If not null, this should at least contain the #CART_CONTEXT_KEY
    • isAvailable

      boolean isAvailable(Sku sku, int quantity, Map<String,Object> context)
      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 InventoryUnavailableException
      Throws:
      InventoryUnavailableException
    • decrementInventory

      void decrementInventory(Map<Sku,Integer> skuQuantities, Map<String,Object> context) throws InventoryUnavailableException

      Usually invoked from DecrementInventoryActivity

      Callers 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 interface

      Implementers of this method (explicitly those that are utilizing the InventoryServiceExtensionHandler) should populate a ROLLBACK_STATE_KEY within 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 the ORDER_KEY and/or the ROLLBACK_STATE_KEY
      Throws:
      InventoryUnavailableException
    • incrementInventory

      void incrementInventory(Sku sku, int quantity, Map<String,Object> context)
    • incrementInventory

      void incrementInventory(Map<Sku,Integer> skuQuantities, Map<String,Object> context)

      Callers that invoke this method directly should check for a ROLLBACK_STATE_KEY in the given context. This will contain information about what actually happened in terms of decrementing inventory

      Implementers of this method (explicitly those that are utilizing the InventoryServiceExtensionHandler) should populate a ROLLBACK_STATE_KEY within 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 the ROLLBACK_STATE_KEY
    • reconcileChangeOrderInventory

      void reconcileChangeOrderInventory(Map<Sku,Integer> decrementSkuQuantities, Map<Sku,Integer> incrementSkuQuantities, Map<String,Object> context) throws InventoryUnavailableException

      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 decrement
      incrementSkuQuantities - - the delta change of sku quantities to increment
      context -
      Throws:
      InventoryUnavailableException
    • buildSkuInventoryMap

      Map<Sku,Integer> buildSkuInventoryMap(Order order)

      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