Class DefaultJpaCustomizableSkuInventoryRepository<D extends JpaSkuInventory>
- Type Parameters:
D
-
- All Implemented Interfaces:
CustomizableSkuInventoryRepository<D>
,org.springframework.beans.factory.InitializingBean
SkuInventoryRepository
do not assign locks. These should generally not be used for
updates as there is no guarantee about concurrency. Reads that do not assign explicit locks are
not guaranteed to be accurate for read or update as another thread may be updating those records
concurrently. Read locks are less important because, although you can get unreliable data which
may be accurate enough for many applications, the persisted data will be accurate. But, in order
to have accurate persisted data in a highly concurrent system, you will need to ensure that write
locks are properly applied.
However, no read locks are required when having an exact inventory count is not required (where
there is some room for inaccuracies).- Author:
- Kelly Tisdell (ktisdell)
- See Also:
-
Constructor Summary
ConstructorDescriptionDefaultJpaCustomizableSkuInventoryRepository
(com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil behaviorUtil, com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilder criteriaBuilder, List<com.broadleafcommerce.data.tracking.core.service.RsqlQueryTransformer> rsqlQueryTransformers, com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaCriteriaBuilderRsqlVisitor rsqlVisitor) -
Method Summary
Modifier and TypeMethodDescriptionvoid
protected Optional<jakarta.persistence.criteria.Predicate>
buildContextFilterPredicate
(jakarta.persistence.criteria.Path<?> path, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Optionally returns basicPredicate
forTenantJpaTracking.getTenant()
based on theContextInfo
argument.protected Optional<jakarta.persistence.criteria.Predicate>
buildInventoryLocationCorrelatedSubQueryPredicate
(jakarta.persistence.criteria.Root<?> root, jakarta.persistence.criteria.CriteriaQuery<?> criteriaQuery, Optional<Boolean> shippingLocation, Optional<Boolean> pickupLocation, Optional<Boolean> storeLocation, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This creates a subquery that ensures that the associatedJpaInventoryLocation
record is valid (i.e.protected Optional<jakarta.persistence.criteria.Predicate>
buildInventoryLocationCorrelatedSubQueryPredicate
(jakarta.persistence.criteria.Root<? extends JpaSkuInventory> root, jakarta.persistence.criteria.CriteriaQuery<? extends JpaSkuInventory> criteriaQuery, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This creates a subquery that ensures that the associatedJpaInventoryLocation
record is valid (i.e.protected jakarta.persistence.criteria.Predicate
buildPredicateForSkuRefs
(@NonNull SkuReferenceFieldType skuReferenceFieldType, @NonNull Set<String> skuReferences, Integer minQuantity, @NonNull jakarta.persistence.criteria.Root<?> root, @NonNull jakarta.persistence.criteria.CriteriaQuery<?> criteria, @NonNull jakarta.persistence.criteria.CriteriaBuilder builder) protected Optional<jakarta.persistence.criteria.Predicate>
buildSerializedInventoryQueryPredicate
(@NonNull String serializationValue, Integer quantity, @NonNull jakarta.persistence.criteria.Root<?> root, @NonNull jakarta.persistence.criteria.CriteriaQuery<?> criteria, @NonNull jakarta.persistence.criteria.CriteriaBuilder builder) Builds an optionalPredicate
for a serialized inventory.protected List<jakarta.persistence.criteria.Predicate>
buildSkuRefAndQuantityAvailablePredicates
(@NonNull Map<String, Integer> skuReferenceQuantities, @NonNull String skuRefFieldName, @NonNull jakarta.persistence.criteria.Root<?> root, @NonNull jakarta.persistence.criteria.CriteriaQuery<?> criteria, @NonNull jakarta.persistence.criteria.CriteriaBuilder builder) Builds a list ofPredicates
based on the given skuRefs and quantities inskuReferenceQuantities
.protected jakarta.persistence.criteria.Predicate
buildSkuRefFieldPredicate
(@NonNull jakarta.persistence.criteria.Root<?> root, @NonNull jakarta.persistence.criteria.CriteriaBuilder builder, Optional<String> externalId, Optional<String> skuCode, Optional<String> upc, Optional<String> ean, Optional<String> gtin) protected List<jakarta.persistence.criteria.Predicate>
buildSkuRefPredicates
(String skuRef, String skuRefFieldName, Integer quantity, @NonNull jakarta.persistence.criteria.Root<?> root, @NonNull jakarta.persistence.criteria.CriteriaQuery<?> criteria, @NonNull jakarta.persistence.criteria.CriteriaBuilder builder) protected jakarta.persistence.criteria.Predicate[]
collectNonNullPredicates
(jakarta.persistence.criteria.Predicate archivedIsFalsePredicate, jakarta.persistence.criteria.Predicate tenantMatch, jakarta.persistence.criteria.Predicate applicationMatch) void
deleteAllByInventoryLocationId
(String inventoryLocationId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Softly deletes all theSkuInventory
for the specified inventory location idfindAll
(Optional<cz.jirutka.rsql.parser.ast.Node> filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Generally used for batch export, this allows a caller to query, filter, and stream paged results.findAllByContextId
(Iterable<String> contextIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Overrides defaultTrackableRepository.findByContextId(String, ContextInfo)
to add aLockModeType.PESSIMISTIC_WRITE
lock.findAvailableBySkuReferenceForQuantity
(Map<String, Integer> skuReferenceQuantities, SkuReferenceFieldType skuReferenceFieldType, String inventoryLocationId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) FindsSkuInventory
records with at least the mapped available quantities for a given inventory location.findAvailableBySkuReferenceForQuantity
(Map<String, Integer> skuReferenceQuantities, SkuReferenceFieldType skuReferenceFieldType, Optional<Boolean> shippingLocation, Optional<Boolean> pickupLocation, Optional<Boolean> storeLocation, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) FindsSkuInventory
records with the mapped available quantities for given fulfillment types.findAvailableBySkuReferenceForQuantity
(Set<String> skuReferences, int minQuantityAvailable, SkuReferenceFieldType skuReferenceFieldType, Optional<Boolean> shippingLocation, Optional<Boolean> pickupLocation, Optional<Boolean> storeLocation, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Finds availableSkuInventory
records for the provided skuReferences where each have at least the minQuantityAvailable.findByContextId
(String contextId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieve a domain instance based on the context id (seeTrackable.getContextId()
).findByInventoryLocationAndSkuRefFieldValues
(String inventoryLocationId, Optional<String> externalId, Optional<String> skuCode, Optional<String> upc, Optional<String> ean, Optional<String> gtin, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Tries to find a uniqueSkuInventory
record based on theInventoryLocation.getId()
and any one ofSkuRef
field values.findByInventoryLocationAndSkuRefFieldValuesAndNotSerialized
(String inventoryLocationId, Optional<String> externalId, Optional<String> skuCode, Optional<String> upc, Optional<String> ean, Optional<String> gtin, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Tries to find a unique non-serializedSkuInventory
record based on theInventoryLocation.getId()
and any one ofSkuRef
field values.findBySkuReferencesAndLocationId
(Set<String> skuReferences, Integer minQuantity, String locationId, SkuReferenceFieldType skuReferenceFieldType, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) RetrievesSkuInventory
records, filtering onSkuRef
, based on the skuReferenceFieldType parameter, andInventoryLocation.getId()
.protected com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil
protected com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilder
protected jakarta.persistence.EntityManager
protected com.broadleafcommerce.data.tracking.jpa.filtering.narrow.JpaNarrowingHelper
protected List<com.broadleafcommerce.data.tracking.core.service.RsqlQueryTransformer>
protected com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaCriteriaBuilderRsqlVisitor
protected String
protected SkuInventoryRepository<D>
protected jakarta.persistence.criteria.Predicate
getUnarchivedAndInventoryLocationIdEqualsPredicate
(jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<D> entity, String inventoryLocationId) Builds the predicate for getting all unarchived skuInventory from a particular inventoryLocationIdboolean
isAvailableBySkuReferenceForQuantity
(String skuReference, int quantity, SkuReferenceFieldType skuReferenceFieldType, Optional<Boolean> shippingLocation, Optional<Boolean> pickupLocation, Optional<Boolean> storeLocation, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Determines if theSkuInventory
, identified by skuReference, is available for the specified quantity across one or moreInventoryLocation
s, identified by their allowed fulfillment types.protected boolean
isSerializedSkuRef
(@NonNull String skuRef) Determines if the given skuRef is serialized.readAllByInventoryLocationId
(String inventoryLocationId, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Read all Sku Inventories for the specified inventory location id matching the given filters.readConsolidatedInventoryQuantities
(Set<String> skus, Optional<Boolean> shippingLocation, Optional<Boolean> pickupLocation, Optional<Boolean> storeLocation, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) This reads a sum of inventory quantities available for a particular SKU.Object[][]
readSummaryAvailability
(SkuReferenceFieldType skuReferenceFieldType, Set<String> skuReferences, int minQuantity, Optional<Boolean> shippingLocation, Optional<Boolean> pickupLocation, Optional<Boolean> storeLocation, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Queries for applications and tenant IDs associated with the requested availability.protected String
resolveSkuRefFieldName
(SkuReferenceFieldType skuRefFieldType) Resolves the name of the field that should be used in a Predicate based on the providedSkuReferenceFieldType
.void
setSkuInventoryRepository
(SkuInventoryRepository<D> skuInventoryRepository)
-
Constructor Details
-
DefaultJpaCustomizableSkuInventoryRepository
public DefaultJpaCustomizableSkuInventoryRepository(@NonNull com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil behaviorUtil, @NonNull com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilder criteriaBuilder, @NonNull List<com.broadleafcommerce.data.tracking.core.service.RsqlQueryTransformer> rsqlQueryTransformers, @NonNull com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaCriteriaBuilderRsqlVisitor rsqlVisitor)
-
-
Method Details
-
findBySkuReferencesAndLocationId
@NonNull @Policy(operationTypes=READ) public List<D> findBySkuReferencesAndLocationId(@NonNull Set<String> skuReferences, @Nullable Integer minQuantity, @NonNull String locationId, @NonNull SkuReferenceFieldType skuReferenceFieldType, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CustomizableSkuInventoryRepository
RetrievesSkuInventory
records, filtering onSkuRef
, based on the skuReferenceFieldType parameter, andInventoryLocation.getId()
.- Specified by:
findBySkuReferencesAndLocationId
in interfaceCustomizableSkuInventoryRepository<D extends JpaSkuInventory>
minQuantity
- - (optional) the expected minimum quantity availablelocationId
- - the inventory location in which to find inventoryskuReferenceFieldType
- - the type of SKU reference (identifies whatSkuRef
field should be filtered by the skuReferences argument- Returns:
-
findByContextId
@Policy(operationTypes=READ) public Optional<D> findByContextId(String contextId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizableSkuInventoryRepository
Retrieve a domain instance based on the context id (seeTrackable.getContextId()
). If aNarrowExecutor
implementation was specified viaNarrow
, the result should be narrowed based on sandbox and catalog state. This overrides the methodTrackableRepository.findByContextId(String, ContextInfo)
. The mixin implementation will provide an exclusive write lock, if applicable, to prevent concurrent modification ofSkuInventory
records.- Specified by:
findByContextId
in interfaceCustomizableSkuInventoryRepository<D extends JpaSkuInventory>
- Parameters:
contextId
- An identifying idcontextInfo
- Request context information around sandbox and multitenant state- Returns:
- If nothing found, an empty Optional. Otherwise, an Optional containing the narrowed entity.
-
findAllByContextId
@Policy(operationTypes=READ) public Iterable<D> findAllByContextId(Iterable<String> contextIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Overrides defaultTrackableRepository.findByContextId(String, ContextInfo)
to add aLockModeType.PESSIMISTIC_WRITE
lock. Methods like this are used in update functionality withinCrudEntityHelper
andBaseCrudEntityService
.- Specified by:
findAllByContextId
in interfaceCustomizableSkuInventoryRepository<D extends JpaSkuInventory>
- Parameters:
contextIds
- A list of identifying idscontextInfo
- Request context information around sandbox and multitenant state- Returns:
- The list of narrowed entities
-
findAvailableBySkuReferenceForQuantity
@Policy(operationTypes=READ) public List<D> findAvailableBySkuReferenceForQuantity(@NonNull Map<String, Integer> skuReferenceQuantities, @NonNull SkuReferenceFieldType skuReferenceFieldType, @NonNull Optional<Boolean> shippingLocation, @NonNull Optional<Boolean> pickupLocation, @NonNull Optional<Boolean> storeLocation, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CustomizableSkuInventoryRepository
FindsSkuInventory
records with the mapped available quantities for given fulfillment types.- Specified by:
findAvailableBySkuReferenceForQuantity
in interfaceCustomizableSkuInventoryRepository<D extends JpaSkuInventory>
- Returns:
-
buildSkuRefAndQuantityAvailablePredicates
protected List<jakarta.persistence.criteria.Predicate> buildSkuRefAndQuantityAvailablePredicates(@NonNull @NonNull Map<String, Integer> skuReferenceQuantities, @NonNull @NonNull String skuRefFieldName, @NonNull @NonNull jakarta.persistence.criteria.Root<?> root, @NonNull @NonNull jakarta.persistence.criteria.CriteriaQuery<?> criteria, @NonNull @NonNull jakarta.persistence.criteria.CriteriaBuilder builder) Builds a list ofPredicates
based on the given skuRefs and quantities inskuReferenceQuantities
.If any skuRefs are serialized, e.g. FOOTBALL-GM1_GAME?serializationValue=100, the skuRef is parsed and a
Predicate
is built to filter as serialized inventory viabuildSerializedInventoryQueryPredicate(String, Integer, Root, CriteriaQuery, CriteriaBuilder)
.- Parameters:
skuReferenceQuantities
- map of sku reference to quantity requestedskuRefFieldName
- the name of sku referenceroot
- the root entity of the querycriteria
- the current query being built upbuilder
- theCriteriaBuilder
for the select query- Returns:
- a list of
Predicates
based on the given skuRefs and quantities inskuReferenceQuantities
-
buildPredicateForSkuRefs
protected jakarta.persistence.criteria.Predicate buildPredicateForSkuRefs(@NonNull @NonNull SkuReferenceFieldType skuReferenceFieldType, @NonNull @NonNull Set<String> skuReferences, @Nullable Integer minQuantity, @NonNull @NonNull jakarta.persistence.criteria.Root<?> root, @NonNull @NonNull jakarta.persistence.criteria.CriteriaQuery<?> criteria, @NonNull @NonNull jakarta.persistence.criteria.CriteriaBuilder builder) -
buildSkuRefPredicates
protected List<jakarta.persistence.criteria.Predicate> buildSkuRefPredicates(String skuRef, String skuRefFieldName, @Nullable Integer quantity, @NonNull @NonNull jakarta.persistence.criteria.Root<?> root, @NonNull @NonNull jakarta.persistence.criteria.CriteriaQuery<?> criteria, @NonNull @NonNull jakarta.persistence.criteria.CriteriaBuilder builder) -
isSerializedSkuRef
Determines if the given skuRef is serialized.- Parameters:
skuRef
- the sku ref to check- Returns:
- true if the given skuRef is serialized, otherwise false
-
getSerializedInventoryParam
-
buildSerializedInventoryQueryPredicate
protected Optional<jakarta.persistence.criteria.Predicate> buildSerializedInventoryQueryPredicate(@NonNull @NonNull String serializationValue, @Nullable Integer quantity, @NonNull @NonNull jakarta.persistence.criteria.Root<?> root, @NonNull @NonNull jakarta.persistence.criteria.CriteriaQuery<?> criteria, @NonNull @NonNull jakarta.persistence.criteria.CriteriaBuilder builder) Builds an optionalPredicate
for a serialized inventory.A
Subquery
is also included to query the inventory availability for the parent, which is needed for the availability of a serialized inventory since the parent could be sold as well.Consider stadium suites at a football game, there may be 10 gold suites, represented with SKU
FOOTBALL-GM1-GOLD-SUITE
. The parent sku inventory would have 10 as quantity available, and each serialized sku inventory for each suite would have 1 as quantity available. Let's say all 10 suites are sold out as a generic sku, which means that the suites are all sold but no one bought a specific suite. In this case, a serialized skuFOOTBALL-GM1-GOLD-SUITE?serializationValue=100
may seem available but in reality it is already sold, it is simply not sold as a serialized sku.- Parameters:
serializationValue
- the serialization valuequantity
- the quantity to checkroot
- the root entity of the querycriteria
- the current query being built upbuilder
- theCriteriaBuilder
for the select query- Returns:
- an optional
Predicate
for a serialized inventory if the pattern is found, otherwise anOptional.empty()
is returned
-
findAvailableBySkuReferenceForQuantity
@Policy(operationTypes=READ) public List<D> findAvailableBySkuReferenceForQuantity(@NonNull Map<String, Integer> skuReferenceQuantities, @NonNull SkuReferenceFieldType skuReferenceFieldType, @NonNull String inventoryLocationId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CustomizableSkuInventoryRepository
FindsSkuInventory
records with at least the mapped available quantities for a given inventory location.- Specified by:
findAvailableBySkuReferenceForQuantity
in interfaceCustomizableSkuInventoryRepository<D extends JpaSkuInventory>
- Returns:
-
readAllByInventoryLocationId
public Stream<D> readAllByInventoryLocationId(String inventoryLocationId, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizableSkuInventoryRepository
Read all Sku Inventories for the specified inventory location id matching the given filters.- Specified by:
readAllByInventoryLocationId
in interfaceCustomizableSkuInventoryRepository<D extends JpaSkuInventory>
- Parameters:
inventoryLocationId
- the inventory location idfilters
- additional filters to apply in the query, can be nullcontextInfo
- context information surrounding sandboxing and multitenant state- Returns:
- the Sku Inventories for the specified inventory location id
-
deleteAllByInventoryLocationId
public void deleteAllByInventoryLocationId(String inventoryLocationId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizableSkuInventoryRepository
Softly deletes all theSkuInventory
for the specified inventory location id- Specified by:
deleteAllByInventoryLocationId
in interfaceCustomizableSkuInventoryRepository<D extends JpaSkuInventory>
- Parameters:
inventoryLocationId
- the inventory location idcontextInfo
- context information surrounding sandboxing and multitenant state
-
getUnarchivedAndInventoryLocationIdEqualsPredicate
protected jakarta.persistence.criteria.Predicate getUnarchivedAndInventoryLocationIdEqualsPredicate(jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<D> entity, String inventoryLocationId) Builds the predicate for getting all unarchived skuInventory from a particular inventoryLocationId- Parameters:
builder
- the criteria-builderentity
- the entity whose attributes are to be queried uponinventoryLocationId
- the id of the inventoryLocation whose inventory is to be deleted- Returns:
- a predicate that performs the appropriate filtering
-
readSummaryAvailability
public Object[][] readSummaryAvailability(SkuReferenceFieldType skuReferenceFieldType, Set<String> skuReferences, int minQuantity, Optional<Boolean> shippingLocation, Optional<Boolean> pickupLocation, Optional<Boolean> storeLocation, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CustomizableSkuInventoryRepository
Queries for applications and tenant IDs associated with the requested availability. The response is a an Object array that contains: - skuReference (i.e. typically skuCode, but depends on what is requested by skuReferenceFieldType) - tenantId - applicationId (nullable) This method is pretty specific as it allows the Search Services, for example, to determine, for which SKUs have general availability across tenants and applications, not specific to inventory locations.- Specified by:
readSummaryAvailability
in interfaceCustomizableSkuInventoryRepository<D extends JpaSkuInventory>
- Parameters:
skuReferenceFieldType
- The type of fields for which we are search (e.g. SKU_CODE)skuReferences
- The SKU reference number or code e.g.SkuRef.skuCode
shippingLocation
- Indicates if we want to include availability at shipping locationspickupLocation
- - Indicates if we want to include availability at pickup locationsstoreLocation
- - Indicates if we want to include availability at store locationscontext
- the ContextInfo for this request- Returns:
- An object array, representing the rows and columns from the query
-
findAvailableBySkuReferenceForQuantity
@Policy(operationTypes=READ) public List<D> findAvailableBySkuReferenceForQuantity(@NonNull Set<String> skuReferences, int minQuantityAvailable, @NonNull SkuReferenceFieldType skuReferenceFieldType, @NonNull Optional<Boolean> shippingLocation, @NonNull Optional<Boolean> pickupLocation, @NonNull Optional<Boolean> storeLocation, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CustomizableSkuInventoryRepository
Finds availableSkuInventory
records for the provided skuReferences where each have at least the minQuantityAvailable.- Specified by:
findAvailableBySkuReferenceForQuantity
in interfaceCustomizableSkuInventoryRepository<D extends JpaSkuInventory>
- Returns:
-
findByInventoryLocationAndSkuRefFieldValues
@Policy(operationTypes=READ) public Optional<D> findByInventoryLocationAndSkuRefFieldValues(String inventoryLocationId, @NonNull Optional<String> externalId, @NonNull Optional<String> skuCode, @NonNull Optional<String> upc, @NonNull Optional<String> ean, @NonNull Optional<String> gtin, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CustomizableSkuInventoryRepository
Tries to find a uniqueSkuInventory
record based on theInventoryLocation.getId()
and any one ofSkuRef
field values. Note that for anySkuInventory
record, there can be only one unique SKU identifier, which includes any number of unique fields, perInventoryLocation
.- Specified by:
findByInventoryLocationAndSkuRefFieldValues
in interfaceCustomizableSkuInventoryRepository<D extends JpaSkuInventory>
- Returns:
-
findByInventoryLocationAndSkuRefFieldValuesAndNotSerialized
@Policy(operationTypes=READ) public Optional<D> findByInventoryLocationAndSkuRefFieldValuesAndNotSerialized(String inventoryLocationId, @NonNull Optional<String> externalId, @NonNull Optional<String> skuCode, @NonNull Optional<String> upc, @NonNull Optional<String> ean, @NonNull Optional<String> gtin, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CustomizableSkuInventoryRepository
Tries to find a unique non-serializedSkuInventory
record based on theInventoryLocation.getId()
and any one ofSkuRef
field values. Note that for anySkuInventory
record, there can be only one unique SKU identifier, which includes any number of unique fields, perInventoryLocation
.- Specified by:
findByInventoryLocationAndSkuRefFieldValuesAndNotSerialized
in interfaceCustomizableSkuInventoryRepository<D extends JpaSkuInventory>
-
readConsolidatedInventoryQuantities
public Map<String,Long> readConsolidatedInventoryQuantities(@NonNull Set<String> skus, @NonNull Optional<Boolean> shippingLocation, @NonNull Optional<Boolean> pickupLocation, @NonNull Optional<Boolean> storeLocation, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CustomizableSkuInventoryRepository
This reads a sum of inventory quantities available for a particular SKU. This returns aMap
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 interfaceCustomizableSkuInventoryRepository<D extends JpaSkuInventory>
- Parameters:
skus
- the skus for which we are requesting inventoryshippingLocation
- whether the inventory can come from a shipping locationpickupLocation
- whether the inventory can come from a pickup locationstoreLocation
- whether the inventory can come from a store or shopping locationcontext
- the context for which this query should be applied- Returns:
-
isAvailableBySkuReferenceForQuantity
@Policy(operationTypes=READ) public boolean isAvailableBySkuReferenceForQuantity(@NonNull String skuReference, int quantity, @NonNull SkuReferenceFieldType skuReferenceFieldType, @NonNull Optional<Boolean> shippingLocation, @NonNull Optional<Boolean> pickupLocation, @NonNull Optional<Boolean> storeLocation, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CustomizableSkuInventoryRepository
Determines if theSkuInventory
, identified by skuReference, is available for the specified quantity across one or moreInventoryLocation
s, identified by their allowed fulfillment types. SkuRef is determined by the skuReference argument and the- Specified by:
isAvailableBySkuReferenceForQuantity
in interfaceCustomizableSkuInventoryRepository<D extends JpaSkuInventory>
quantity
- - requested quantityskuReferenceFieldType
- - the type of skuReference being passed inshippingLocation
- -Optional
value represents whether we should query shipping locations. If not present, no filtering will be applied.pickupLocation
- -Optional
value represents whether we should query pickup locations. If not present, no filtering will be applied.storeLocation
- -Optional
value represents whether we should query store locations. If not present, no filtering will be applied.- Returns:
-
findAll
@Policy(operationTypes=READ) public Stream<D> findAll(@NonNull Optional<cz.jirutka.rsql.parser.ast.Node> filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizableSkuInventoryRepository
Generally used for batch export, this allows a caller to query, filter, and stream paged results.- Specified by:
findAll
in interfaceCustomizableSkuInventoryRepository<D extends JpaSkuInventory>
- Returns:
-
buildSkuRefFieldPredicate
protected jakarta.persistence.criteria.Predicate buildSkuRefFieldPredicate(@NonNull @NonNull jakarta.persistence.criteria.Root<?> root, @NonNull @NonNull jakarta.persistence.criteria.CriteriaBuilder builder, @NonNull Optional<String> externalId, @NonNull Optional<String> skuCode, @NonNull Optional<String> upc, @NonNull Optional<String> ean, @NonNull Optional<String> gtin) -
buildContextFilterPredicate
protected Optional<jakarta.persistence.criteria.Predicate> buildContextFilterPredicate(jakarta.persistence.criteria.Path<?> path, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Optionally returns basicPredicate
forTenantJpaTracking.getTenant()
based on theContextInfo
argument. This predicate provides filtering for tenantId and archived flags. Only use this to query or filterPath
elements that represent entities that implementTrackable
. This is applied to queries forJpaSkuInventory
as well as to correlated subqueries forJpaInventoryLocation
. This method also supports the "INCLUDE_APPLICATION_ID_PREDICATE" flag on ContextInfo.additionalProperties. If that attribute is set to Boolean.FALSE, then the application id predicate will not be included.- Parameters:
path
-contextInfo
-- Returns:
-
collectNonNullPredicates
protected jakarta.persistence.criteria.Predicate[] collectNonNullPredicates(jakarta.persistence.criteria.Predicate archivedIsFalsePredicate, jakarta.persistence.criteria.Predicate tenantMatch, jakarta.persistence.criteria.Predicate applicationMatch) -
resolveSkuRefFieldName
Resolves the name of the field that should be used in a Predicate based on the providedSkuReferenceFieldType
.- Parameters:
skuRefFieldType
-- Returns:
-
setSkuInventoryRepository
@Autowired @Lazy public void setSkuInventoryRepository(SkuInventoryRepository<D> skuInventoryRepository) -
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
Exception
-
getEntityManager
protected jakarta.persistence.EntityManager getEntityManager() -
getSkuInventoryRepository
-
getNarrowingHelper
protected com.broadleafcommerce.data.tracking.jpa.filtering.narrow.JpaNarrowingHelper getNarrowingHelper() -
getBehaviorUtil
protected com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil getBehaviorUtil() -
getCriteriaBuilder
protected com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilder getCriteriaBuilder() -
getRsqlQueryTransformers
protected List<com.broadleafcommerce.data.tracking.core.service.RsqlQueryTransformer> getRsqlQueryTransformers() -
getRsqlVisitor
protected com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaCriteriaBuilderRsqlVisitor getRsqlVisitor()
-