Class DefaultSkuInventorySummaryService<T extends SkuInventoryAvailabilitySummary>

java.lang.Object
com.broadleafcommerce.inventory.service.DefaultSkuInventorySummaryService<T>
Type Parameters:
T -
All Implemented Interfaces:
SkuInventorySummaryService<T>

public class DefaultSkuInventorySummaryService<T extends SkuInventoryAvailabilitySummary> extends Object implements SkuInventorySummaryService<T>
Provides summary (browsing) data for SkuInventory.
Author:
Kelly Tisdell (ktisdell)
  • Constructor Details

  • Method Details

    • readInventoryAvailability

      public List<T> readInventoryAvailability(@NonNull String skuRefFieldTpe, @NonNull Map<String,Integer> skuReferenceQuantities, @NonNull Optional<Boolean> forShip, @NonNull Optional<Boolean> forPickup, @NonNull Optional<Boolean> inStore, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: SkuInventorySummaryService
      Reads inventory summary data, typically for browsing of SKUs or Products.
      Specified by:
      readInventoryAvailability in interface SkuInventorySummaryService<T extends SkuInventoryAvailabilitySummary>
      Returns:
    • readInventoryAvailability

      public List<T> readInventoryAvailability(@NonNull List<SkuInventoryAvailabilityRequest> availabilityRequests, @NonNull String skuRefFieldTpe, @NonNull Optional<Boolean> forShip, @NonNull Optional<Boolean> forPickup, @NonNull Optional<Boolean> inStore, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: SkuInventorySummaryService
      Reads inventory summary data based on the given SkuInventoryAvailabilityRequests.

      Existing soft reservations are excluded if SkuInventoryAvailabilityRequest.getReferenceNumber() is passed in. For example, if a SKU has total of 2 available and 1 is reserved for userA, and userA checks inventory availability for a quantity of 2 for the same SKU. The existing soft reservation is excluded from the check in this case, effectively making this request to check for an additional quantity of 1 to be available. However, if userB sends the same request to check availability for a quantity of 2 for the same SKU, it would return unavailable since only 1 is available as the other one is reserved for userA.

      Specified by:
      readInventoryAvailability in interface SkuInventorySummaryService<T extends SkuInventoryAvailabilitySummary>
      Parameters:
      availabilityRequests - the list of SkuInventoryAvailabilityRequests to process
      skuRefFieldTpe - the type of the sku ref field
      forShip - indicates if the SKU should be available for shipping
      forPickup - indicates if the SKU should be available for pickup
      inStore - indicates if the SKU should be available in store
      contextInfo - the ContextInfo of the request
      Returns:
    • readInventoryAvailability

      public List<T> readInventoryAvailability(String skuRefFieldTpe, Map<String,Integer> skuReferenceQuantities, String inventoryLocationId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: SkuInventorySummaryService
      Reads inventory summary data, typically for browsing of SKUs or Products by a particular inventory location.
      Specified by:
      readInventoryAvailability in interface SkuInventorySummaryService<T extends SkuInventoryAvailabilitySummary>
      Returns:
    • readInventoryAvailability

      public T readInventoryAvailability(String skuRefFieldTpe, String skuReference, int minQuantityAvailable, Optional<Boolean> forShip, Optional<Boolean> forPickup, Optional<Boolean> inStore, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Specified by:
      readInventoryAvailability in interface SkuInventorySummaryService<T extends SkuInventoryAvailabilitySummary>
      Returns:
    • readConsolidatedAvailability

      public List<ConsolidatedInventoryAvailability> readConsolidatedAvailability(Set<String> skuCodes, int minQuantityAvailable, Optional<Boolean> forShip, Optional<Boolean> forPickup, Optional<Boolean> inStore, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: SkuInventorySummaryService
      Returns the consolidated availability based on what is requested. This is typically used by other, aggregate services, such as Search Services, to indicate if a SKU is available for search or filtering purposes. Callers will typically set ContextInfo.setIgnoreNarrowing(boolean) to true so that all availability is returned for the tenant and all associated applications.
      Specified by:
      readConsolidatedAvailability in interface SkuInventorySummaryService<T extends SkuInventoryAvailabilitySummary>
      Parameters:
      skuCodes - A Set of values associated with the skuCode field on SkuRef
      minQuantityAvailable - The minimum quantity requested for all SKUs queried
      forShip - Indicates if the SKU should be available for shipping
      forPickup - Indicates if the SKU should be available for pickup
      inStore - Indicates if the SKU should be available in store
      contextInfo - The ContextInfo of the request.
      Returns:
    • readConsolidatedInventoryQuantities

      public Map<String,Long> readConsolidatedInventoryQuantities(@NonNull Set<String> skuCodes, @NonNull Optional<Boolean> forShip, @NonNull Optional<Boolean> forPickup, @NonNull Optional<Boolean> inStore, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: SkuInventorySummaryService
      Returns a Map of quantities available. The Map has a key that represents the SKU with a value that represents the quantity available for that SKU.
      Specified by:
      readConsolidatedInventoryQuantities in interface SkuInventorySummaryService<T extends SkuInventoryAvailabilitySummary>
      Parameters:
      skuCodes - the sku codes
      forShip - whether this inventory can be shipped
      forPickup - whether this inventory can be picked up
      inStore - whether this inventory is for in store
      Returns:
    • getQuantitySoftReservedByReferenceNumber

      protected Map<String,Integer> getQuantitySoftReservedByReferenceNumber(Collection<String> referenceNumbers, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Gets a map of quantity from existing soft reservations by reference numbers.

      The only time when there are 2 soft reservations for the same reference number would be for serialized SKUs, as the same reservation is done for the parent. In this case, only one of the soft reservations is counted to prevent double counting the soft reserved quantities.

      Parameters:
      referenceNumbers - the reference numbers to look for
      contextInfo - context information related to multitenancy
      Returns:
      a map of quantity from existing soft reservations by reference numbers
    • getSkuInventoryAvailabilityStrategy

      protected SkuInventoryAvailabilityStrategy<? extends SkuInventory> getSkuInventoryAvailabilityStrategy(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • getSkuFieldReferenceTypeUtility

      @NonNull protected SkuFieldReferenceTypeUtility getSkuFieldReferenceTypeUtility()
    • getSkuInventoryRepository

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

      @NonNull protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
    • getInventoryTransactionService

      protected InventoryTransactionService<InventoryTransaction> getInventoryTransactionService()
    • setInventoryTransactionService

      @Autowired public void setInventoryTransactionService(InventoryTransactionService<InventoryTransaction> inventoryTransactionService)