Class DefaultSkuInventoryAvailabilityStrategy<I extends SkuInventory>

java.lang.Object
com.broadleafcommerce.inventory.service.DefaultSkuInventoryAvailabilityStrategy<I>
Type Parameters:
I -
All Implemented Interfaces:
SkuInventoryAvailabilityStrategy<I>

public class DefaultSkuInventoryAvailabilityStrategy<I extends SkuInventory> extends Object implements SkuInventoryAvailabilityStrategy<I>
The default strategy for reading inventory for browsing and for the purpose of inventory reservations.
Author:
Kelly Tisdell (ktisdell)
  • Constructor Details

  • Method Details

    • readAvailableInventory

      public List<I> readAvailableInventory(String skuRefFieldTpe, Map<String,Integer> skuReferenceQuantities, Optional<Boolean> forShip, Optional<Boolean> forPickup, Optional<Boolean> inStore, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: SkuInventoryAvailabilityStrategy
      This reads inventory that is generally available (has at least 1 item at the time of the query) that are available in InventoryLocations that allow pickup, shipping, or in-store shopping. This method does not necessarily discriminate about which InventoryLocation, except that whether that location satisfies the pickup, shipping, or in-store shopping allowance. This is best used for general browsing (e.g. product list pages - PLP), when general availability is required and specific inventory reservations are not required. This should NOT be used for finding SkuInventory for inventory reservation.
      Specified by:
      readAvailableInventory in interface SkuInventoryAvailabilityStrategy<I extends SkuInventory>
      Parameters:
      skuRefFieldTpe - - the type of sku reference (see DefaultSkuReferenceFieldType).
      skuReferenceQuantities - - the values with which to look up SkuInventory based on the skuRefFieldTpe
      forShip - - informs whether inventory should be searched in InventoryLocations that allow shipping
      forPickup - - informs whether inventory should be searched in InventoryLocations that allow pickup
      inStore - - informs whether inventory should be searched in InventoryLocations that allow in-store shopping
      Returns:
    • readAvailableInventory

      public List<I> readAvailableInventory(@NonNull String skuRefFieldTpe, @NonNull Map<String,Integer> skuReferenceQuantities, @NonNull String inventoryLocationId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: SkuInventoryAvailabilityStrategy
      This method is used to find SkuInventory at a specific InventoryLocation. This can be useful for determining if a Store or a Pickup location have inventory available. This method MAY be used for determining which inventory is should be reserved when the InventoryLocation is known. This method returns inventory with at least the provided quantity available item at the time of the query.
      Specified by:
      readAvailableInventory in interface SkuInventoryAvailabilityStrategy<I extends SkuInventory>
      Parameters:
      skuRefFieldTpe - - the type of sku reference (see DefaultSkuReferenceFieldType).
      skuReferenceQuantities - - map of SKU Reference to quantity requested
      inventoryLocationId - - the inventory location id
      Returns:
    • readAvailableInventoryForShip

      public List<I> readAvailableInventoryForShip(@NonNull String skuRefFieldTpe, @NonNull Map<String,Integer> skuReferenceQuantities, @NonNull Optional<String> inventoryLocationId, @NonNull Optional<Address> address, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      It is expected that this method will be overridden in many cases to provide a particular algorithm for finding SkuInventory to be shipped to a particular address. Some implementors may wish to use the closest locations. Others may wish to group as many items together as possible to minimize shipments. Others may wish to draw on inventory from locations that have the highest or lowest quantities available. In other words, the default implementation does not make any assumptions about the particular algorithm or how it should be implemented.
      Specified by:
      readAvailableInventoryForShip in interface SkuInventoryAvailabilityStrategy<I extends SkuInventory>
      skuReferenceQuantities - - map of SKU Reference to quantity requested
      inventoryLocationId - - specifies the location, in lieu of an address, from which to check inventory. This is required if address is not present.
      address - - optional information to assist in choosing the InventoryLocations. This is required if inventoryLocationId is not present.
      Returns:
    • resolveInventoryFromAddress

      protected List<I> resolveInventoryFromAddress(@NonNull String skuRefFieldType, @NonNull Map<String,Integer> skuReferenceQuantities, @NonNull Address address, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Extension point to resolve inventory location based on the supplied address.
      Parameters:
      skuRefFieldType - the type of sku reference (see DefaultSkuReferenceFieldType).
      skuReferenceQuantities - map of SKU Reference to quantity requested
      address - The ship to address
      contextInfo -
      Returns:
    • getSkuInventoryRepository

      @NonNull protected SkuInventoryRepository<com.broadleafcommerce.data.tracking.core.Trackable> getSkuInventoryRepository()
    • getSkuFieldReferenceTypeUtility

      @NonNull protected SkuFieldReferenceTypeUtility getSkuFieldReferenceTypeUtility()
    • getHelper

      @NonNull protected com.broadleafcommerce.data.tracking.core.service.CrudEntityHelper getHelper()
    • getInventoryLocationService

      @NonNull protected InventoryLocationService<InventoryLocation> getInventoryLocationService()