Class DefaultSkuInventorySummaryService<T extends SkuInventoryAvailabilitySummary>
- Type Parameters:
T-
- All Implemented Interfaces:
SkuInventorySummaryService<T>
SkuInventory.- Author:
- Kelly Tisdell (ktisdell)
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultSkuInventorySummaryService(SkuFieldReferenceTypeUtility skuFieldReferenceTypeUtility, SkuInventoryAvailabilityStrategy<? extends SkuInventory> skuInventoryAvailabilityStrategy, SkuInventoryRepository<com.broadleafcommerce.data.tracking.core.Trackable> skuInventoryRepository, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbuildConsolidatedInventory(Object[] queryResult, List<ConsolidatedInventoryAvailability> consolidatedInventory) protected voidbuildNotFoundSummaries(List<T> summaries, SkuReferenceFieldType type, Collection<String> notFound, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Build summaries for unavailable/not found SKUs.protected TbuildSummary(boolean available, SkuRef skuRef, String locationId, String vendorRef, Integer quantity) protected TbuildSummary(SkuInventory inventory, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Build availability summary from the supplied SkuInventory.buildSummaryResults(List<? extends SkuInventory> skuInventories, SkuReferenceFieldType fieldType, Collection<String> requestedSkus, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected booleanprotected InventoryTransactionService<InventoryTransaction>getQuantitySoftReservedByReferenceNumber(Collection<String> referenceNumbers, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Gets a map of quantity from existing soft reservations by reference numbers.protected StringgetSerializedSku(String sku, String serializedValue) protected SkuFieldReferenceTypeUtilityprotected SkuInventoryAvailabilityStrategy<? extends SkuInventory>getSkuInventoryAvailabilityStrategy(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected SkuInventoryRepository<com.broadleafcommerce.data.tracking.core.Trackable>protected com.broadleafcommerce.common.extension.TypeFactoryprotected Tprotected voidpopulateFutureStockSummary(SkuInventory result, SkuInventoryAvailabilitySummary summary, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected voidpopulateSerializedValue(SkuInventory result, SkuRef skuRef) readConsolidatedAvailability(Set<String> skuCodes, int minQuantityAvailable, Optional<Boolean> forShip, Optional<Boolean> forPickup, Optional<Boolean> inStore, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns the consolidated availability based on what is requested.readConsolidatedInventoryQuantities(Set<String> skuCodes, Optional<Boolean> forShip, Optional<Boolean> forPickup, Optional<Boolean> inStore, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) readConsolidatedInventoryQuantities(Set<String> skuCodes, Optional<Boolean> forShip, Optional<Boolean> forPickup, Optional<Boolean> inStore, Optional<Boolean> availableNow, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns aMapof quantities available.readInventoryAvailability(String skuRefFieldType, String skuReference, int minQuantityAvailable, Optional<Boolean> forShip, Optional<Boolean> forPickup, Optional<Boolean> inStore, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) <R extends SkuInventoryAvailabilityRequest>
List<T>readInventoryAvailability(String skuRefFieldTpe, List<R> availabilityRequests, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads inventory summary data, typically for browsing of SKUs or Products by a particular inventory location.readInventoryAvailability(String skuRefFieldTpe, Map<String, Integer> skuReferenceQuantities, String inventoryLocationId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads inventory summary data, typically for browsing of SKUs or Products by a particular inventory location.readInventoryAvailability(String skuRefFieldTpe, Map<String, Integer> skuReferenceQuantities, Optional<Boolean> forShip, Optional<Boolean> forPickup, Optional<Boolean> inStore, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads inventory summary data, typically for browsing of SKUs or Products.readInventoryAvailability(List<SkuInventoryAvailabilityRequest> availabilityRequests, String skuRefFieldTpe, Optional<Boolean> forShip, Optional<Boolean> forPickup, Optional<Boolean> inStore, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads inventory summary data based on the givenSkuInventoryAvailabilityRequests.voidsetInventoryTransactionService(InventoryTransactionService<InventoryTransaction> inventoryTransactionService) protected voidupdateRequestedQuantitiesToAccountForReserved(List<SkuInventoryAvailabilityRequest> availabilityRequests, Map<String, Integer> quantityReservedByReferenceNumber)
-
Constructor Details
-
DefaultSkuInventorySummaryService
public DefaultSkuInventorySummaryService(SkuFieldReferenceTypeUtility skuFieldReferenceTypeUtility, SkuInventoryAvailabilityStrategy<? extends SkuInventory> skuInventoryAvailabilityStrategy, SkuInventoryRepository<com.broadleafcommerce.data.tracking.core.Trackable> skuInventoryRepository, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
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:SkuInventorySummaryServiceReads inventory summary data, typically for browsing of SKUs or Products.- Specified by:
readInventoryAvailabilityin interfaceSkuInventorySummaryService<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:SkuInventorySummaryServiceReads inventory summary data based on the givenSkuInventoryAvailabilityRequests.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:
readInventoryAvailabilityin interfaceSkuInventorySummaryService<T extends SkuInventoryAvailabilitySummary>- Parameters:
availabilityRequests- the list ofSkuInventoryAvailabilityRequeststo processskuRefFieldTpe- the type of the sku ref fieldforShip- indicates if the SKU should be available for shippingforPickup- indicates if the SKU should be available for pickupinStore- indicates if the SKU should be available in storecontextInfo- the ContextInfo of the request- Returns:
-
readInventoryAvailability
public List<T> readInventoryAvailability(@NonNull String skuRefFieldTpe, @NonNull Map<String, Integer> skuReferenceQuantities, @NonNull String inventoryLocationId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SkuInventorySummaryServiceReads inventory summary data, typically for browsing of SKUs or Products by a particular inventory location.- Specified by:
readInventoryAvailabilityin interfaceSkuInventorySummaryService<T extends SkuInventoryAvailabilitySummary>- Returns:
-
readInventoryAvailability
public <R extends SkuInventoryAvailabilityRequest> List<T> readInventoryAvailability(@NonNull String skuRefFieldTpe, @NonNull List<R> availabilityRequests, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SkuInventorySummaryServiceReads inventory summary data, typically for browsing of SKUs or Products by a particular inventory location.- Specified by:
readInventoryAvailabilityin interfaceSkuInventorySummaryService<T extends SkuInventoryAvailabilitySummary>- Parameters:
skuRefFieldTpe- the type of the sku ref fieldavailabilityRequests- the list ofSkuInventoryAvailabilityRequestto build a query fromcontextInfo- the ContextInfo of the request- Returns:
- a list of
SkuInventoryAvailabilitySummarymatching the requests
-
readInventoryAvailability
public T readInventoryAvailability(String skuRefFieldType, String skuReference, int minQuantityAvailable, Optional<Boolean> forShip, Optional<Boolean> forPickup, Optional<Boolean> inStore, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) - Specified by:
readInventoryAvailabilityin interfaceSkuInventorySummaryService<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:SkuInventorySummaryServiceReturns 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 setContextInfo.setIgnoreNarrowing(boolean)to true so that all availability is returned for the tenant and all associated applications.- Specified by:
readConsolidatedAvailabilityin interfaceSkuInventorySummaryService<T extends SkuInventoryAvailabilitySummary>- Parameters:
skuCodes- A Set of values associated with the skuCode field onSkuRefminQuantityAvailable- The minimum quantity requested for all SKUs queriedforShip- Indicates if the SKU should be available for shippingforPickup- Indicates if the SKU should be available for pickupinStore- Indicates if the SKU should be available in storecontextInfo- 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) - Specified by:
readConsolidatedInventoryQuantitiesin interfaceSkuInventorySummaryService<T extends SkuInventoryAvailabilitySummary>
-
readConsolidatedInventoryQuantities
public Map<String,Long> readConsolidatedInventoryQuantities(@NonNull Set<String> skuCodes, @NonNull Optional<Boolean> forShip, @NonNull Optional<Boolean> forPickup, @NonNull Optional<Boolean> inStore, @NonNull Optional<Boolean> availableNow, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SkuInventorySummaryServiceReturns aMapof quantities available. The Map has a key that represents the SKU with a value that represents the quantity available for that SKU.- Specified by:
readConsolidatedInventoryQuantitiesin interfaceSkuInventorySummaryService<T extends SkuInventoryAvailabilitySummary>- Parameters:
skuCodes- the sku codesforShip- whether this inventory can be shippedforPickup- whether this inventory can be picked upinStore- whether this inventory is for in store- Returns:
-
buildSummaryResults
protected List<T> buildSummaryResults(List<? extends SkuInventory> skuInventories, SkuReferenceFieldType fieldType, Collection<String> requestedSkus, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
buildConsolidatedInventory
protected void buildConsolidatedInventory(Object[] queryResult, List<ConsolidatedInventoryAvailability> consolidatedInventory) -
buildNotFoundSummaries
protected void buildNotFoundSummaries(List<T> summaries, SkuReferenceFieldType type, Collection<String> notFound, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Build summaries for unavailable/not found SKUs.- Parameters:
summaries- The summaries list to add the unavailable SKUs to.type- The sku field reference typenotFound- The not found SKUscontextInfo- The current context
-
buildSummary
protected T buildSummary(SkuInventory inventory, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Build availability summary from the supplied SkuInventory.- Parameters:
inventory-context-- Returns:
-
buildSummary
-
populateSerializedValue
-
getSerializedSku
-
newSummary
-
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 forcontextInfo- 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) -
doesSkuInventoryHaveUnlimitedFutureStock
-
populateFutureStockSummary
protected void populateFutureStockSummary(@NonNull SkuInventory result, @NonNull SkuInventoryAvailabilitySummary summary, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
updateRequestedQuantitiesToAccountForReserved
protected void updateRequestedQuantitiesToAccountForReserved(List<SkuInventoryAvailabilityRequest> availabilityRequests, Map<String, Integer> quantityReservedByReferenceNumber) -
getSkuFieldReferenceTypeUtility
-
getSkuInventoryRepository
@NonNull protected SkuInventoryRepository<com.broadleafcommerce.data.tracking.core.Trackable> getSkuInventoryRepository() -
getTypeFactory
@NonNull protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getInventoryTransactionService
-
setInventoryTransactionService
@Autowired public void setInventoryTransactionService(InventoryTransactionService<InventoryTransaction> inventoryTransactionService)
-