Class DefaultSkuInventoryService<I extends SkuInventory>
- java.lang.Object
-
- com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P>
-
- com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<I>
-
- com.broadleafcommerce.inventory.service.DefaultSkuInventoryService<I>
-
- Type Parameters:
I
-
- All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.service.CrudEntityService<I>
,com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<I>
,SkuInventoryService<I>
public class DefaultSkuInventoryService<I extends SkuInventory> extends com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<I> implements SkuInventoryService<I>
Service to assist in reading and/or adjustingSkuInventory
. This is not a typical CRUD service because it involves multiple access to repositories in a single JPA transaction.- Author:
- Kelly Tisdell (ktisdell)
-
-
Constructor Summary
Constructors Constructor Description DefaultSkuInventoryService(SkuInventoryRepository<com.broadleafcommerce.data.tracking.core.Trackable> skuInventoryRepository, InventoryLocationService<InventoryLocation> inventoryLocationService, SkuFieldReferenceTypeUtility skuFieldReferenceTypeUtility, SkuInventoryAdjustmentService<I> skuInventoryAdjustmentService, SkuInventoryAvailabilityStrategy<I> skuInventoryAvailabilityStrategy, StockChangeNotificationService stockChangeNotificationService, SkuInventoryReservationRequestValidator skuInventoryReservationRequestValidator, InventoryTransactionService<InventoryTransaction> inventoryTransactionService, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper, com.broadleafcommerce.data.tracking.core.mapping.DomainMapperManager domainMapperManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected com.broadleafcommerce.data.tracking.core.service.BulkPersistenceResponse<I>
buildBulkResponseOfFailures(List<com.broadleafcommerce.data.tracking.core.service.BulkPersistenceResponse.PersistenceFailure<I>> validationFailures)
List<InventoryTransaction>
cancelInventory(SkuInventoryAdjustmentRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Performs theDefaultInventoryTransactionType.CANCELLED
InventoryTransactions
to updateSkuInventory
for fulfilled items.I
create(I businessInstance, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
List<I>
createAll(List<I> businessInstances, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
com.broadleafcommerce.data.tracking.core.service.BulkPersistenceResponse<I>
createAllAllowingPartialSuccess(List<I> businessInstances, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
List<InventoryTransaction>
createSkuInventoryReservations(SkuInventoryReservationRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Creates HARD or a SOFT Inventory Reservations.void
delete(String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
protected String
determineSkuRefValue(SkuReferenceFieldType skuReferenceFieldType, I skuInventory, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected Map<I,List<SkuInventoryAdjustmentRequestItem>>
divideRequestItemsBySkuInventory(SkuInventoryAdjustmentRequest request, InventoryTransactionType latestExistingTransactionType, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
boolean
existsByInventoryLocationAndSkuRefFieldValues(String inventoryLocationId, Optional<String> skuContextId, Optional<String> externalId, Optional<String> skuCode, Optional<String> upc, Optional<String> ean, Optional<String> gtin, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Determines is aSkuInventory
record exists in a given location, based onSkuRef
fields.org.springframework.data.domain.Page<I>
findAllByInventoryLocationContextId(String inventoryLocationId, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Read all Sku Inventories for the specified inventory location id matching the given filters.List<InventoryTransaction>
fulfillInventory(SkuInventoryAdjustmentRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Performs theDefaultInventoryTransactionType.FULFILLED
InventoryTransactions
to updateSkuInventory
for fulfilled items.protected Set<I>
getAlreadyReservedSkuInventories(SkuInventoryReservationRequestGroup group, Map<String,List<InventoryTransaction>> existingSoftReservationsByReference, Map<String,Integer> nonReservedRequestedQuantitiesBySkuReference, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Reads theSkuInventory
records for the reservation request items which already have existing soft reservations.protected List<I>
getAvailableSkuInventories(SkuInventoryReservationRequestGroup group, SkuReferenceFieldType fieldType, Map<String,Integer> totalRequestedQuantitiesBySkuReference, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected com.broadleafcommerce.data.tracking.core.mapping.DomainMapperManager
getDomainMapperManager()
protected Map<String,List<InventoryTransaction>>
getExistingSoftReservationsByReferences(SkuInventoryReservationRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected Map<String,String>
getInventoryIdsForReferenceNumbersBasedOnExistingTransactions(List<SkuInventoryAdjustmentRequestItem> items, InventoryTransactionType latestExistingTransactionType, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Retrieves theSKU Inventory ID
for the items'reference numbers
based on existing transactions of typelatestExistingTransactionType
.protected InventoryLocationService<InventoryLocation>
getInventoryLocationService()
protected InventoryTransactionService<InventoryTransaction>
getInventoryTransactionService()
protected SkuFieldReferenceTypeUtility
getSkuFieldReferenceTypeUtility()
protected SkuInventoryAdjustmentService<I>
getSkuInventoryAdjustmentService()
protected SkuInventoryAvailabilityStrategy<I>
getSkuInventoryAvailabilityStrategy(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Allows for context-specific selection of a strategy for finding inventory availability for browsing and reservation.protected SkuInventoryRepository<com.broadleafcommerce.data.tracking.core.Trackable>
getSkuInventoryRepository()
protected SkuInventoryReservationRequestValidator
getSkuInventoryReservationRequestValidator()
protected StockChangeNotificationService
getStockChangeNotificationService()
protected Comparator<com.broadleafcommerce.data.tracking.core.service.Update<I>>
getUpdateComparator()
Provides aComparator
for sortingUpdate
instances.Stream<I>
readAll(Optional<cz.jirutka.rsql.parser.ast.Node> filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Generally used for batch export, this allows a caller to query, filter, and stream paged results.Stream<I>
readAllByInventoryLocationId(String inventoryLocationId, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Read all Sku Inventories for the specified inventory location id matching the given filters.org.springframework.data.domain.Page<I>
readAllByName(String nameQuery, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Read all Inventory Locations, optionally filtered by name or number.Optional<I>
readByInventoryLocationAndSkuRefFieldValues(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)
Reads a (unique)SkuInventory
record for a given location, based onSkuRef
fields.List<I>
readSkuInventoryDetails(SkuReferenceFieldType skuRefType, Set<String> skuRefs, InventoryLocation location, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
ReadsSkuInventory
details based on specificSkuRef
details, specified by theSkuReferenceFieldType
for a givenInventoryLocation
.I
replace(String id, I businessInstance, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
List<I>
replaceAll(List<com.broadleafcommerce.data.tracking.core.service.Update<I>> replacements, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
com.broadleafcommerce.data.tracking.core.service.BulkPersistenceResponse<I>
replaceAllAllowingPartialSuccess(List<com.broadleafcommerce.data.tracking.core.service.Update<I>> replacements, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
protected InventoryReservationRequestType
resolveInventoryReservationRequestType(String type)
protected SkuInventoryFulfillmentType
resolveSkuInventoryFulfillmentType(String value)
Takes a String value and resolves it to an instance ofSkuInventoryFulfillmentType
.List<InventoryTransaction>
returnInventory(SkuInventoryAdjustmentRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Performs theDefaultInventoryTransactionType.RETURNED
InventoryTransactions
to updateSkuInventory
for returned items.I
update(String id, I businessInstance, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
List<I>
updateAll(List<com.broadleafcommerce.data.tracking.core.service.Update<I>> updates, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
com.broadleafcommerce.data.tracking.core.service.BulkPersistenceResponse<I>
updateAllAllowingPartialSuccess(List<com.broadleafcommerce.data.tracking.core.service.Update<I>> updates, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
I
updateSort(com.broadleafcommerce.data.tracking.core.sort.SortPositionRequest sortPositionRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
protected List<com.broadleafcommerce.data.tracking.core.service.BulkPersistenceResponse.PersistenceFailure<I>>
validateAllSkuInventoryModifications(List<com.broadleafcommerce.data.tracking.core.service.Update<I>> changes, List<com.broadleafcommerce.data.tracking.core.service.Update<I>> successfullyValidated, com.broadleafcommerce.data.tracking.core.context.ContextInfo context, boolean useReplaceSemantics)
protected void
validateAllSkuInventoryModificationsAndThrowIfError(List<com.broadleafcommerce.data.tracking.core.service.Update<I>> changes, List<com.broadleafcommerce.data.tracking.core.service.Update<I>> successfullyValidated, com.broadleafcommerce.data.tracking.core.context.ContextInfo context, boolean useReplaceSemantics)
protected Optional<String>
validateExpectedInventoryTransactionsExist(List<SkuInventoryAdjustmentRequestItem> items, List<InventoryTransaction> inventoryTransactions, InventoryTransactionType transactionType)
Validates that all expected inventory transactions exist based on the originalitem list
.protected void
validateSingleSkuInventoryModifications(I current, I changed, boolean useReplaceSemantics)
protected void
validateSkuInventoryModifications(I current, I changed, org.springframework.validation.Errors errors, boolean useReplaceSemantics)
Perform any validations onchanged
with consideration to the current state incurrent
.protected void
validateSufficientAvailableInventory(List<I> availableSkuInventories, Map<String,Integer> totalRequestedQuantitiesBySkuReference, SkuReferenceFieldType skuReferenceFieldType, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService
getRsqlHelper, readAll, readAll, readAll, readAll
-
Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService
convertFromPersistentDomain, convertToPersistentDomain, getHelper, getRepository, getSortPositionStrategy, readAll, readAll, readAll, readAllByContextId, readByContextId, setSortPositionStrategy
-
-
-
-
Constructor Detail
-
DefaultSkuInventoryService
public DefaultSkuInventoryService(SkuInventoryRepository<com.broadleafcommerce.data.tracking.core.Trackable> skuInventoryRepository, InventoryLocationService<InventoryLocation> inventoryLocationService, SkuFieldReferenceTypeUtility skuFieldReferenceTypeUtility, SkuInventoryAdjustmentService<I> skuInventoryAdjustmentService, SkuInventoryAvailabilityStrategy<I> skuInventoryAvailabilityStrategy, StockChangeNotificationService stockChangeNotificationService, SkuInventoryReservationRequestValidator skuInventoryReservationRequestValidator, InventoryTransactionService<InventoryTransaction> inventoryTransactionService, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper, com.broadleafcommerce.data.tracking.core.mapping.DomainMapperManager domainMapperManager)
-
-
Method Detail
-
readAllByName
public org.springframework.data.domain.Page<I> readAllByName(@Nullable String nameQuery, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:SkuInventoryService
Read all Inventory Locations, optionally filtered by name or number.- Specified by:
readAllByName
in interfaceSkuInventoryService<I extends SkuInventory>
- Parameters:
nameQuery
- (optional) the name to filter byfilters
- additional filters to apply in the query, can be nullpage
- the requested page of results from the databasecontext
- context information surrounding sandboxing and multitenant state- Returns:
- all SkuInventory, optionally filtered by name
-
findAllByInventoryLocationContextId
public org.springframework.data.domain.Page<I> findAllByInventoryLocationContextId(String inventoryLocationId, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:SkuInventoryService
Read all Sku Inventories for the specified inventory location id matching the given filters. Read all Inventory Locations,- Specified by:
findAllByInventoryLocationContextId
in interfaceSkuInventoryService<I extends SkuInventory>
- Parameters:
inventoryLocationId
- the inventory location idfilters
- additional filters to apply in the query, can be nullpage
- the requested page of results from the databasecontext
- context information surrounding sandboxing and multitenant state- Returns:
- the Sku Inventories for the specified inventory location id
-
readAllByInventoryLocationId
public Stream<I> readAllByInventoryLocationId(String inventoryLocationId, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:SkuInventoryService
Read all Sku Inventories for the specified inventory location id matching the given filters.- Specified by:
readAllByInventoryLocationId
in interfaceSkuInventoryService<I extends SkuInventory>
- Parameters:
inventoryLocationId
- the inventory location idfilters
- additional filters to apply in the query, can be nullcontext
- context information surrounding sandboxing and multitenant state- Returns:
- the Sku Inventories for the specified inventory location id
-
readByInventoryLocationAndSkuRefFieldValues
public Optional<I> readByInventoryLocationAndSkuRefFieldValues(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)
Description copied from interface:SkuInventoryService
Reads a (unique)SkuInventory
record for a given location, based onSkuRef
fields.- Specified by:
readByInventoryLocationAndSkuRefFieldValues
in interfaceSkuInventoryService<I extends SkuInventory>
- Returns:
-
existsByInventoryLocationAndSkuRefFieldValues
public boolean existsByInventoryLocationAndSkuRefFieldValues(String inventoryLocationId, Optional<String> skuContextId, Optional<String> externalId, Optional<String> skuCode, Optional<String> upc, Optional<String> ean, Optional<String> gtin, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:SkuInventoryService
Determines is aSkuInventory
record exists in a given location, based onSkuRef
fields.- Specified by:
existsByInventoryLocationAndSkuRefFieldValues
in interfaceSkuInventoryService<I extends SkuInventory>
- Returns:
-
createSkuInventoryReservations
public List<InventoryTransaction> createSkuInventoryReservations(@NonNull SkuInventoryReservationRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) throws InventoryUnavailableException
Description copied from interface:SkuInventoryService
Creates HARD or a SOFT Inventory Reservations. This results in the creation of 1 or moreInventoryTransaction
records. A SOFT inventory reservation is a temporary reservation that may be removed or rolled back after a period of time. A SOFT reservation typically results in decrementing quantityAvailable on theSkuInventory
record. These are typically created prior to payment processing. A HARD reservation makes the SOFT reservation permanent. These are typically created after payment processing. If a corresponding SOFT reservation does not exist, then the creation of a HARD reservation will attempt to decrement quantityAvailable as well. In this case, the process is similar to creating a SOFT reservation immediately followed by a HARD reservation.- Specified by:
createSkuInventoryReservations
in interfaceSkuInventoryService<I extends SkuInventory>
- Parameters:
request
-SkuInventoryReservationRequest
to be processedcontextInfo
- Context information around sandbox and multitenant state.- Returns:
- The
InventoryTransactions
resulting from processing therequest
. - Throws:
InventoryUnavailableException
- if inventory cannot be reserved or otherwise decremented
-
getExistingSoftReservationsByReferences
protected Map<String,List<InventoryTransaction>> getExistingSoftReservationsByReferences(SkuInventoryReservationRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
getAlreadyReservedSkuInventories
protected Set<I> getAlreadyReservedSkuInventories(SkuInventoryReservationRequestGroup group, Map<String,List<InventoryTransaction>> existingSoftReservationsByReference, Map<String,Integer> nonReservedRequestedQuantitiesBySkuReference, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Reads theSkuInventory
records for the reservation request items which already have existing soft reservations. Also updatesnonReservedRequestedQuantitiesBySkuReference
to remove items and quantities which have already been fully soft-reserved.- Parameters:
group
- the reservation request group to find already reserved inventories forexistingSoftReservationsByReference
- the existing soft reservation transactions mapped by item reference numbernonReservedRequestedQuantitiesBySkuReference
- all of the requested quantities for each sku reference, to have already-reserved quantities removedcontextInfo
- context information surrounding sandboxing and multitenant state- Returns:
- the
SkuInventory
records for the reservation request which have existing soft reservations
-
getAvailableSkuInventories
protected List<I> getAvailableSkuInventories(SkuInventoryReservationRequestGroup group, SkuReferenceFieldType fieldType, Map<String,Integer> totalRequestedQuantitiesBySkuReference, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
fulfillInventory
public List<InventoryTransaction> fulfillInventory(@NonNull SkuInventoryAdjustmentRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) throws InventoryUnavailableException, InventoryNotReservedException
Description copied from interface:SkuInventoryService
Performs theDefaultInventoryTransactionType.FULFILLED
InventoryTransactions
to updateSkuInventory
for fulfilled items.This transaction decrements the reserved and on-hand inventory for the requested items. This should only be performed after the items have already been
DefaultInventoryTransactionType.HARD_RESERVED
.- Specified by:
fulfillInventory
in interfaceSkuInventoryService<I extends SkuInventory>
- Parameters:
request
- inventory adjustment to be processed as fulfilledcontextInfo
- Context information around sandbox and multitenant state.- Returns:
- The
InventoryTransactions
resulting from processing therequest
. - Throws:
InventoryUnavailableException
- if inventory could not be decrementedInventoryNotReservedException
- if inventory was not already reserved
-
cancelInventory
public List<InventoryTransaction> cancelInventory(@NonNull SkuInventoryAdjustmentRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) throws InventoryUnavailableException, InventoryNotReservedException
Description copied from interface:SkuInventoryService
Performs theDefaultInventoryTransactionType.CANCELLED
InventoryTransactions
to updateSkuInventory
for fulfilled items.This transaction decrements the reserved inventory for the requested items. This should only be performed after the items have already been
DefaultInventoryTransactionType.HARD_RESERVED
.- Specified by:
cancelInventory
in interfaceSkuInventoryService<I extends SkuInventory>
- Parameters:
request
- inventory adjustment to be processed as cancelledcontextInfo
- Context information around sandbox and multitenant state.- Returns:
- The
InventoryTransactions
resulting from processing therequest
. - Throws:
InventoryUnavailableException
- if inventory could not be decrementedInventoryNotReservedException
- if inventory was not already reserved
-
returnInventory
public List<InventoryTransaction> returnInventory(@NonNull SkuInventoryAdjustmentRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:SkuInventoryService
Performs theDefaultInventoryTransactionType.RETURNED
InventoryTransactions
to updateSkuInventory
for returned items.This transaction increments the on-hand inventory for the requested items.
- Specified by:
returnInventory
in interfaceSkuInventoryService<I extends SkuInventory>
- Parameters:
request
- inventory adjustment to be processed as returnedcontextInfo
- Context information around sandbox and multitenant state.- Returns:
- The
InventoryTransactions
resulting from processing therequest
.
-
divideRequestItemsBySkuInventory
protected Map<I,List<SkuInventoryAdjustmentRequestItem>> divideRequestItemsBySkuInventory(@NonNull SkuInventoryAdjustmentRequest request, @NonNull InventoryTransactionType latestExistingTransactionType, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
getInventoryIdsForReferenceNumbersBasedOnExistingTransactions
protected Map<String,String> getInventoryIdsForReferenceNumbersBasedOnExistingTransactions(List<SkuInventoryAdjustmentRequestItem> items, InventoryTransactionType latestExistingTransactionType, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Retrieves theSKU Inventory ID
for the items'reference numbers
based on existing transactions of typelatestExistingTransactionType
.For example, if we are fulfilling inventory for items, we will look up the
DefaultInventoryTransactionType.HARD_RESERVED
transactions for the items'reference numbers
and return a map where the keys are the reference numbers and the values are the corresponding SKU Inventory IDs.- Parameters:
items
- the items to find SKU inventory IDs forlatestExistingTransactionType
- the expected latest existing transaction type, which we will look up to find the correct SKU inventory IDcontextInfo
- context information surrounding sandboxing and multitenant state- Returns:
- a map where the keys are the reference numbers and the values are the corresponding SKU Inventory IDs
- Throws:
InventoryTransactionMissingException
- if an expected inventory transaction does not exist.
-
validateExpectedInventoryTransactionsExist
protected Optional<String> validateExpectedInventoryTransactionsExist(List<SkuInventoryAdjustmentRequestItem> items, List<InventoryTransaction> inventoryTransactions, InventoryTransactionType transactionType)
Validates that all expected inventory transactions exist based on the originalitem list
. If these don't exist, an error string is returned indicating what went wrong.- Parameters:
items
- The inventory adjustment items to check against.inventoryTransactions
- The found inventory adjustments.transactionType
- The transaction type (for error message purposes)- Returns:
- An optional with an error message string if not all expected transactions are found,
else
empty
-
determineSkuRefValue
protected String determineSkuRefValue(SkuReferenceFieldType skuReferenceFieldType, I skuInventory, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
validateSufficientAvailableInventory
protected void validateSufficientAvailableInventory(List<I> availableSkuInventories, Map<String,Integer> totalRequestedQuantitiesBySkuReference, SkuReferenceFieldType skuReferenceFieldType, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) throws InventoryUnavailableException
- Throws:
InventoryUnavailableException
-
readSkuInventoryDetails
public List<I> readSkuInventoryDetails(SkuReferenceFieldType skuRefType, Set<String> skuRefs, InventoryLocation location, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:SkuInventoryService
ReadsSkuInventory
details based on specificSkuRef
details, specified by theSkuReferenceFieldType
for a givenInventoryLocation
.- Specified by:
readSkuInventoryDetails
in interfaceSkuInventoryService<I extends SkuInventory>
- Returns:
-
readAll
public Stream<I> readAll(@NonNull Optional<cz.jirutka.rsql.parser.ast.Node> filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:SkuInventoryService
Generally used for batch export, this allows a caller to query, filter, and stream paged results.- Specified by:
readAll
in interfaceSkuInventoryService<I extends SkuInventory>
- Returns:
-
update
@Transactional("inventoryTransactionManager") public I update(String id, I businessInstance, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
- Specified by:
update
in interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<I extends SkuInventory>
- Overrides:
update
in classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<I extends SkuInventory>
-
updateAll
public List<I> updateAll(@NonNull List<com.broadleafcommerce.data.tracking.core.service.Update<I>> updates, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
- Specified by:
updateAll
in interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<I extends SkuInventory>
- Overrides:
updateAll
in classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<I extends SkuInventory>
-
updateAllAllowingPartialSuccess
public com.broadleafcommerce.data.tracking.core.service.BulkPersistenceResponse<I> updateAllAllowingPartialSuccess(List<com.broadleafcommerce.data.tracking.core.service.Update<I>> updates, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
- Specified by:
updateAllAllowingPartialSuccess
in interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<I extends SkuInventory>
- Overrides:
updateAllAllowingPartialSuccess
in classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<I extends SkuInventory>
-
buildBulkResponseOfFailures
protected com.broadleafcommerce.data.tracking.core.service.BulkPersistenceResponse<I> buildBulkResponseOfFailures(List<com.broadleafcommerce.data.tracking.core.service.BulkPersistenceResponse.PersistenceFailure<I>> validationFailures)
-
updateSort
@Transactional("inventoryTransactionManager") public I updateSort(com.broadleafcommerce.data.tracking.core.sort.SortPositionRequest sortPositionRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
- Specified by:
updateSort
in interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<I extends SkuInventory>
- Overrides:
updateSort
in classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<I extends SkuInventory>
-
replace
@Transactional("inventoryTransactionManager") public I replace(String id, I businessInstance, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
- Specified by:
replace
in interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<I extends SkuInventory>
- Overrides:
replace
in classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<I extends SkuInventory>
-
replaceAll
@Transactional("inventoryTransactionManager") public List<I> replaceAll(List<com.broadleafcommerce.data.tracking.core.service.Update<I>> replacements, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
- Specified by:
replaceAll
in interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<I extends SkuInventory>
- Overrides:
replaceAll
in classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<I extends SkuInventory>
-
replaceAllAllowingPartialSuccess
@Transactional("inventoryTransactionManager") public com.broadleafcommerce.data.tracking.core.service.BulkPersistenceResponse<I> replaceAllAllowingPartialSuccess(List<com.broadleafcommerce.data.tracking.core.service.Update<I>> replacements, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
- Specified by:
replaceAllAllowingPartialSuccess
in interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<I extends SkuInventory>
- Overrides:
replaceAllAllowingPartialSuccess
in classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<I extends SkuInventory>
-
validateAllSkuInventoryModificationsAndThrowIfError
protected void validateAllSkuInventoryModificationsAndThrowIfError(List<com.broadleafcommerce.data.tracking.core.service.Update<I>> changes, List<com.broadleafcommerce.data.tracking.core.service.Update<I>> successfullyValidated, com.broadleafcommerce.data.tracking.core.context.ContextInfo context, boolean useReplaceSemantics)
-
validateAllSkuInventoryModifications
protected List<com.broadleafcommerce.data.tracking.core.service.BulkPersistenceResponse.PersistenceFailure<I>> validateAllSkuInventoryModifications(List<com.broadleafcommerce.data.tracking.core.service.Update<I>> changes, List<com.broadleafcommerce.data.tracking.core.service.Update<I>> successfullyValidated, com.broadleafcommerce.data.tracking.core.context.ContextInfo context, boolean useReplaceSemantics)
-
validateSingleSkuInventoryModifications
protected void validateSingleSkuInventoryModifications(@NonNull I current, @NonNull I changed, boolean useReplaceSemantics)
-
validateSkuInventoryModifications
protected void validateSkuInventoryModifications(@NonNull I current, @NonNull I changed, @NonNull org.springframework.validation.Errors errors, boolean useReplaceSemantics)
Perform any validations onchanged
with consideration to the current state incurrent
.- Parameters:
current
- the entity instance as it exists in the data store nowchanged
- the changed entity instance representing the update/replace that will be appliederrors
- the errors object on which to register errorsuseReplaceSemantics
- whether or not to consider null values inchanged
as changed. If true, null values will be considered as changed. If false, null values will be considered as unchanged. This matters, since in operations likeCrudEntityService.update(String, Object, ContextInfo)
, a null field value will be ignored and not applied to the entity as a change. However, in operations likeCrudEntityService.replace(String, Object, ContextInfo)
, all values (null or not) are applied to the entity as a change. This hint enables proper validation behavior in each of these flows.
-
create
public I create(I businessInstance, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
- Specified by:
create
in interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<I extends SkuInventory>
- Overrides:
create
in classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<I extends SkuInventory>
-
createAll
public List<I> createAll(List<I> businessInstances, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
- Specified by:
createAll
in interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<I extends SkuInventory>
- Overrides:
createAll
in classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<I extends SkuInventory>
-
createAllAllowingPartialSuccess
public com.broadleafcommerce.data.tracking.core.service.BulkPersistenceResponse<I> createAllAllowingPartialSuccess(List<I> businessInstances, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
- Specified by:
createAllAllowingPartialSuccess
in interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<I extends SkuInventory>
- Overrides:
createAllAllowingPartialSuccess
in classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<I extends SkuInventory>
-
delete
public void delete(String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
- Specified by:
delete
in interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<I extends SkuInventory>
- Overrides:
delete
in classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<I extends SkuInventory>
-
resolveInventoryReservationRequestType
protected InventoryReservationRequestType resolveInventoryReservationRequestType(String type)
-
getUpdateComparator
protected Comparator<com.broadleafcommerce.data.tracking.core.service.Update<I>> getUpdateComparator()
Provides aComparator
for sortingUpdate
instances. This is mostly used for updateAll and updateAllAllowingPartialSuccess. The default simply comparesUpdate.getId()
, which is how queries are sorted that apply locks. This is to prevent deadlocking when updating these one at a time (e.g. in anIterator
. This method allows someone to override the comparator, but this will generally be unnecessary.- Returns:
-
getSkuInventoryAvailabilityStrategy
protected SkuInventoryAvailabilityStrategy<I> getSkuInventoryAvailabilityStrategy(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Allows for context-specific selection of a strategy for finding inventory availability for browsing and reservation.- Parameters:
contextInfo
-- Returns:
-
resolveSkuInventoryFulfillmentType
protected SkuInventoryFulfillmentType resolveSkuInventoryFulfillmentType(String value)
Takes a String value and resolves it to an instance ofSkuInventoryFulfillmentType
.- Parameters:
value
-- Returns:
-
getSkuInventoryRepository
@NonNull protected SkuInventoryRepository<com.broadleafcommerce.data.tracking.core.Trackable> getSkuInventoryRepository()
-
getInventoryLocationService
@NonNull protected InventoryLocationService<InventoryLocation> getInventoryLocationService()
-
getSkuInventoryAdjustmentService
@NonNull protected SkuInventoryAdjustmentService<I> getSkuInventoryAdjustmentService()
-
getDomainMapperManager
@NonNull protected com.broadleafcommerce.data.tracking.core.mapping.DomainMapperManager getDomainMapperManager()
-
getSkuFieldReferenceTypeUtility
@NonNull protected SkuFieldReferenceTypeUtility getSkuFieldReferenceTypeUtility()
-
getSkuInventoryReservationRequestValidator
@NonNull protected SkuInventoryReservationRequestValidator getSkuInventoryReservationRequestValidator()
-
getStockChangeNotificationService
@NonNull protected StockChangeNotificationService getStockChangeNotificationService()
-
getInventoryTransactionService
@NonNull protected InventoryTransactionService<InventoryTransaction> getInventoryTransactionService()
-
-