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 Summary
ConstructorDescriptionDefaultSkuInventoryAvailabilityStrategy
(SkuInventoryRepository<com.broadleafcommerce.data.tracking.core.Trackable> skuInventoryRepository, SkuFieldReferenceTypeUtility skuFieldReferenceTypeUtility, InventoryLocationService<InventoryLocation> inventoryLocationService, com.broadleafcommerce.data.tracking.core.service.CrudEntityHelper helper) -
Method Summary
Modifier and TypeMethodDescriptionprotected com.broadleafcommerce.data.tracking.core.service.CrudEntityHelper
protected InventoryLocationService<InventoryLocation>
protected SkuFieldReferenceTypeUtility
protected SkuInventoryRepository<com.broadleafcommerce.data.tracking.core.Trackable>
readAvailableInventory
(String skuRefFieldTpe, Map<String, Integer> skuReferenceQuantities, String inventoryLocationId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This method is used to findSkuInventory
at a specificInventoryLocation
.readAvailableInventory
(String skuRefFieldTpe, Map<String, Integer> skuReferenceQuantities, Optional<Boolean> forShip, Optional<Boolean> forPickup, Optional<Boolean> inStore, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This reads inventory that is generally available (has at least 1 item at the time of the query) that are available inInventoryLocation
s that allow pickup, shipping, or in-store shopping.readAvailableInventoryForShip
(String skuRefFieldTpe, Map<String, Integer> skuReferenceQuantities, Optional<String> inventoryLocationId, Optional<Address> address, 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 findingSkuInventory
to be shipped to a particular address.resolveInventoryFromAddress
(String skuRefFieldType, Map<String, Integer> skuReferenceQuantities, Address address, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Extension point to resolve inventory location based on the supplied address.
-
Constructor Details
-
DefaultSkuInventoryAvailabilityStrategy
public DefaultSkuInventoryAvailabilityStrategy(SkuInventoryRepository<com.broadleafcommerce.data.tracking.core.Trackable> skuInventoryRepository, SkuFieldReferenceTypeUtility skuFieldReferenceTypeUtility, InventoryLocationService<InventoryLocation> inventoryLocationService, com.broadleafcommerce.data.tracking.core.service.CrudEntityHelper helper)
-
-
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 inInventoryLocation
s that allow pickup, shipping, or in-store shopping. This method does not necessarily discriminate about whichInventoryLocation
, 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 findingSkuInventory
for inventory reservation.- Specified by:
readAvailableInventory
in interfaceSkuInventoryAvailabilityStrategy<I extends SkuInventory>
- Parameters:
skuRefFieldTpe
- - the type of sku reference (see DefaultSkuReferenceFieldType).skuReferenceQuantities
- - the values with which to look upSkuInventory
based on the skuRefFieldTpeforShip
- - informs whether inventory should be searched inInventoryLocation
s that allow shippingforPickup
- - informs whether inventory should be searched inInventoryLocation
s that allow pickupinStore
- - informs whether inventory should be searched inInventoryLocation
s 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 findSkuInventory
at a specificInventoryLocation
. 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 theInventoryLocation
is known. This method returns inventory with at least the provided quantity available item at the time of the query.- Specified by:
readAvailableInventory
in interfaceSkuInventoryAvailabilityStrategy<I extends SkuInventory>
- Parameters:
skuRefFieldTpe
- - the type of sku reference (see DefaultSkuReferenceFieldType).skuReferenceQuantities
- - map of SKU Reference to quantity requestedinventoryLocationId
- - 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 findingSkuInventory
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 interfaceSkuInventoryAvailabilityStrategy<I extends SkuInventory>
skuReferenceQuantities
- - map of SKU Reference to quantity requestedinventoryLocationId
- - 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 theInventoryLocation
s. 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 requestedaddress
- The ship to addresscontextInfo
-- Returns:
-
getSkuInventoryRepository
@NonNull protected SkuInventoryRepository<com.broadleafcommerce.data.tracking.core.Trackable> getSkuInventoryRepository() -
getSkuFieldReferenceTypeUtility
-
getHelper
@NonNull protected com.broadleafcommerce.data.tracking.core.service.CrudEntityHelper getHelper() -
getInventoryLocationService
-