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 adjusting SkuInventory. This is not a typical CRUD service because it involves multiple access to repositories in a single JPA transaction.
Author:
Kelly Tisdell (ktisdell)
  • Constructor Details

  • Method Details

    • 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 interface SkuInventoryService<I extends SkuInventory>
      Parameters:
      nameQuery - (optional) the name to filter by
      filters - additional filters to apply in the query, can be null
      page - the requested page of results from the database
      context - 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 interface SkuInventoryService<I extends SkuInventory>
      Parameters:
      inventoryLocationId - the inventory location id
      filters - additional filters to apply in the query, can be null
      page - the requested page of results from the database
      context - 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 interface SkuInventoryService<I extends SkuInventory>
      Parameters:
      inventoryLocationId - the inventory location id
      filters - additional filters to apply in the query, can be null
      context - context information surrounding sandboxing and multitenant state
      Returns:
      the Sku Inventories for the specified inventory location id
    • deleteAllByInventoryLocationId

      public void deleteAllByInventoryLocationId(String inventoryLocationId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: SkuInventoryService
      Deletes all the SkuInventory for the specified inventory location id
      Specified by:
      deleteAllByInventoryLocationId in interface SkuInventoryService<I extends SkuInventory>
      Parameters:
      inventoryLocationId - the inventory location id
      contextInfo - context information surrounding sandboxing and multitenant state
    • 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 on SkuRef fields.
      Specified by:
      readByInventoryLocationAndSkuRefFieldValues in interface SkuInventoryService<I extends SkuInventory>
      Returns:
    • readByInventoryLocationAndSkuRefFieldValuesAndNotSerialized

      public Optional<I> readByInventoryLocationAndSkuRefFieldValuesAndNotSerialized(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) non-serialized SkuInventory record for a given location, based on SkuRef fields.

      Typically used for the validation to ensure that the parent of serialized inventories do not have duplicate sku reference.

      Specified by:
      readByInventoryLocationAndSkuRefFieldValuesAndNotSerialized in interface SkuInventoryService<I extends SkuInventory>
    • 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 a SkuInventory record exists in a given location, based on SkuRef fields.
      Specified by:
      existsByInventoryLocationAndSkuRefFieldValues in interface SkuInventoryService<I extends SkuInventory>
      Returns:
    • readByParentSkuInventoryIdAndSerializationValue

      public Optional<I> readByParentSkuInventoryIdAndSerializationValue(@NonNull @NonNull String parentSkuInventoryId, @NonNull @NonNull String serializationValue, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: SkuInventoryService
      Reads a (unique) SkuInventory record for a parent sku inventory id and serialization value.
      Specified by:
      readByParentSkuInventoryIdAndSerializationValue in interface SkuInventoryService<I extends SkuInventory>
      Parameters:
      parentSkuInventoryId - the parent sku inventory id
      serializationValue - the serialization value
      context - context information surrounding sandboxing and multitenant state
      Returns:
      a (unique) SkuInventory record for a given parent sku inventory id and serialization value.
    • existsByParentSkuInventoryId

      public boolean existsByParentSkuInventoryId(@NonNull @NonNull String parentSkuInventoryId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: SkuInventoryService
      Determines if any SkuInventory records exist with the given SkuInventory.getParentSkuInventoryId().
      Specified by:
      existsByParentSkuInventoryId in interface SkuInventoryService<I extends SkuInventory>
      Parameters:
      parentSkuInventoryId - the parent sku inventory id to filter by
      context - context information surrounding sandboxing and multitenant state
      Returns:
      true if any SkuInventory records exist with the given SkuInventory.getParentSkuInventoryId(), otherwise false
    • 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 more InventoryTransaction 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 the SkuInventory 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 interface SkuInventoryService<I extends SkuInventory>
      Parameters:
      request - SkuInventoryReservationRequest to be processed
      contextInfo - Context information around sandbox and multitenant state.
      Returns:
      The InventoryTransactions resulting from processing the request.
      Throws:
      InventoryUnavailableException - if inventory cannot be reserved or otherwise decremented
    • releaseSkuInventoryReservations

      public ReleaseSkuInventoryReservationResponse releaseSkuInventoryReservations(@NonNull @NonNull ReleaseSkuInventoryReservationRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: SkuInventoryService
      Releases inventory reservations based on the given ReleaseSkuInventoryReservationRequest.

      By default, it only releases the soft reservations

      Specified by:
      releaseSkuInventoryReservations in interface SkuInventoryService<I extends SkuInventory>
      Parameters:
      request - the ReleaseSkuInventoryReservationRequest containing details about the release
      contextInfo - context information around sandbox and multitenant state
      Returns:
      a ReleaseSkuInventoryReservationResponse represents the result
    • buildReleaseReservationResponse

      protected ReleaseSkuInventoryReservationResponse buildReleaseReservationResponse(@NonNull @NonNull ReleaseSkuInventoryReservationRequest releaseRequest, @NonNull @NonNull List<InventoryTransaction> reservationsFound, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Builds a ReleaseSkuInventoryReservationResponse representing the result of releasing reservations.

      By default it just returns a new ReleaseSkuInventoryReservationResponse containing nothing, serves as a hookpoint for customization.

      Parameters:
      releaseRequest - the original ReleaseSkuInventoryReservationRequest
      reservationsFound - the InventoryTransactions that were found and released
      contextInfo - the context around sandboxing and multitenant state
      Returns:
      a ReleaseSkuInventoryReservationResponse representing the result of releasing reservations
    • 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 the SkuInventory records for the reservation request items which already have existing soft reservations. Also updates nonReservedRequestedQuantitiesBySkuReference to remove items and quantities which have already been fully soft-reserved.
      Parameters:
      group - the reservation request group to find already reserved inventories for
      existingSoftReservationsByReference - the existing soft reservation transactions mapped by item reference number
      nonReservedRequestedQuantitiesBySkuReference - all of the requested quantities for each sku reference, to have already-reserved quantities removed
      contextInfo - 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 the DefaultInventoryTransactionType.FULFILLED InventoryTransactions to update SkuInventory 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 interface SkuInventoryService<I extends SkuInventory>
      Parameters:
      request - inventory adjustment to be processed as fulfilled
      contextInfo - Context information around sandbox and multitenant state.
      Returns:
      The InventoryTransactions resulting from processing the request.
      Throws:
      InventoryUnavailableException - if inventory could not be decremented
      InventoryNotReservedException - 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 the DefaultInventoryTransactionType.CANCELLED InventoryTransactions to update SkuInventory 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 interface SkuInventoryService<I extends SkuInventory>
      Parameters:
      request - inventory adjustment to be processed as cancelled
      contextInfo - Context information around sandbox and multitenant state.
      Returns:
      The InventoryTransactions resulting from processing the request.
      Throws:
      InventoryUnavailableException - if inventory could not be decremented
      InventoryNotReservedException - 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 the DefaultInventoryTransactionType.RETURNED InventoryTransactions to update SkuInventory for returned items.

      This transaction increments the on-hand inventory for the requested items.

      Specified by:
      returnInventory in interface SkuInventoryService<I extends SkuInventory>
      Parameters:
      request - inventory adjustment to be processed as returned
      contextInfo - Context information around sandbox and multitenant state.
      Returns:
      The InventoryTransactions resulting from processing the request.
    • divideRequestItemsBySkuInventory

      protected Map<I,List<SkuInventoryAdjustmentRequestItem>> divideRequestItemsBySkuInventory(@NonNull SkuInventoryAdjustmentRequest request, @NonNull InventoryTransactionType latestExistingTransactionType, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • getInventoryIdsForReferenceNumbersBasedOnExistingTransactions

      protected org.springframework.util.MultiValueMap<String,String> getInventoryIdsForReferenceNumbersBasedOnExistingTransactions(List<SkuInventoryAdjustmentRequestItem> items, InventoryTransactionType latestExistingTransactionType, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Retrieves the SKU Inventory ID for the items' reference numbers based on existing transactions of type latestExistingTransactionType.

      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 for
      latestExistingTransactionType - the expected latest existing transaction type, which we will look up to find the correct SKU inventory ID
      contextInfo - 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 original item 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
    • determineExpectedReservationCount

      protected int determineExpectedReservationCount(SkuInventoryAdjustmentRequestItem item)
    • isSerialized

      protected boolean isSerialized(String skuReferenceValue)
      Determines whether the item being adjusted has a serialized sku inventory object
      Parameters:
      skuReferenceValue - the sku value of the item
      Returns:
      whether the item being adjusted has a serialized sku inventory object
    • determineSkuRefValue

      protected String determineSkuRefValue(SkuReferenceFieldType skuReferenceFieldType, I skuInventory, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • buildSerializedSku

      protected String buildSerializedSku(String skuRef, SkuInventory skuInventory)
    • 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
      Reads SkuInventory details based on specific SkuRef details, specified by the SkuReferenceFieldType for a given InventoryLocation.
      Specified by:
      readSkuInventoryDetails in interface SkuInventoryService<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 interface SkuInventoryService<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 interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<I extends SkuInventory>
      Overrides:
      update in class com.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 interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<I extends SkuInventory>
      Overrides:
      updateAll in class com.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 interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<I extends SkuInventory>
      Overrides:
      updateAllAllowingPartialSuccess in class com.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 interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<I extends SkuInventory>
      Overrides:
      updateSort in class com.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 interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<I extends SkuInventory>
      Overrides:
      replace in class com.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 interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<I extends SkuInventory>
      Overrides:
      replaceAll in class com.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 interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<I extends SkuInventory>
      Overrides:
      replaceAllAllowingPartialSuccess in class com.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 on changed with consideration to the current state in current.
      Parameters:
      current - the entity instance as it exists in the data store now
      changed - the changed entity instance representing the update/replace that will be applied
      errors - the errors object on which to register errors
      useReplaceSemantics - whether or not to consider null values in changed 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 like CrudEntityService.update(String, Object, ContextInfo), a null field value will be ignored and not applied to the entity as a change. However, in operations like CrudEntityService.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 interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<I extends SkuInventory>
      Overrides:
      create in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<I extends SkuInventory>
    • updateSerializedInventorySkuRefBasedOnParent

      protected I updateSerializedInventorySkuRefBasedOnParent(@NonNull I businessInstance, @NonNull I parent)
      Updates the SkuInventory.getSkuRef() of a serialized inventory based on its parent.
    • createAll

      public List<I> createAll(List<I> businessInstances, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Specified by:
      createAll in interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<I extends SkuInventory>
      Overrides:
      createAll in class com.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 interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<I extends SkuInventory>
      Overrides:
      createAllAllowingPartialSuccess in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<I extends SkuInventory>
    • postProcessSkuInventoryCreation

      protected void postProcessSkuInventoryCreation(@NonNull I created, @NonNull @NonNull Optional<I> maybeParent, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Perform any additional handling after a SkuInventory has been created.

      By default, it and notifies stock change.

      Parameters:
      created - the created SkuInventory
      contextInfo - context information surrounding sandboxing and multitenant state
    • updateParentHasChildrenFlag

      protected void updateParentHasChildrenFlag(@NonNull I inventory, @NonNull @NonNull Optional<I> maybeParent, boolean hasChildrenFlagToSet, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Sets the SkuInventory.hasChildren() flag for the parent if the given SkuInventory is serialized.
      Parameters:
      inventory - the SkuInventory to update the parent for
      maybeParent - the optional of already-fetched parent SkuInventory
      hasChildrenFlagToSet - the SkuInventory.hasChildren() flag to set
      contextInfo - context information surrounding sandboxing and multitenant state
    • updateHasChildrenFlagIfSerializedInventoryExists

      protected void updateHasChildrenFlagIfSerializedInventoryExists(@NonNull I inventory, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Sets the SkuInventory.hasChildren() flag if a child inventory exists.
      Parameters:
      inventory - the SkuInventory to check and update the flag for
      contextInfo - context information surrounding sandboxing and multitenant state
    • notifyStockChangeForCreate

      protected void notifyStockChangeForCreate(@NonNull I created, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Notifies stock change after creating a SkuInventory.
      Parameters:
      created - the created SkuInventory
      contextInfo - context information surrounding sandboxing and multitenant state
    • delete

      public void delete(String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Specified by:
      delete in interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<I extends SkuInventory>
      Overrides:
      delete in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<I extends SkuInventory>
    • validateHasNoChildrenBeforeDeletion

      protected void validateHasNoChildrenBeforeDeletion(@NonNull I toDelete, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Validates that the SkuInventory being deleted has no children.
      Parameters:
      toDelete - the SkuInventory being deleted
      contextInfo - context information surrounding sandboxing and multitenant state
      Throws:
      UnsupportedOperationException - if there are still child inventories
    • postProcessSkuInventoryDeletion

      protected void postProcessSkuInventoryDeletion(@NonNull I deleted, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Perform any additional handling after a SkuInventory has been deleted.
      Parameters:
      deleted - the deleted SkuInventory
      contextInfo - context information surrounding sandboxing and multitenant state
    • notifyStockChangeForDelete

      protected void notifyStockChangeForDelete(@NonNull I deleted, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Notifies stock change after deleting a SkuInventory.
      Parameters:
      deleted - the deleted SkuInventory
      contextInfo - context information surrounding sandboxing and multitenant state
    • resolveInventoryReservationRequestType

      protected InventoryReservationRequestType resolveInventoryReservationRequestType(String type)
    • getUpdateComparator

      protected Comparator<com.broadleafcommerce.data.tracking.core.service.Update<I>> getUpdateComparator()
      Provides a Comparator for sorting Update instances. This is mostly used for updateAll and updateAllAllowingPartialSuccess. The default simply compares Update.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 an Iterator. 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 of SkuInventoryFulfillmentType.
      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()
    • getTypeFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
    • setTypeFactory

      @Autowired public void setTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory)