Class DefaultFreeSoftInventoryJobService
java.lang.Object
com.broadleafcommerce.inventory.job.freeinventory.service.DefaultFreeSoftInventoryJobService
- All Implemented Interfaces:
FreeSoftInventoryJobService
public class DefaultFreeSoftInventoryJobService
extends Object
implements FreeSoftInventoryJobService
Default implementation of a free soft inventory job service.
- Author:
- Jacob Mitash
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final int
-
Constructor Summary
ConstructorDescriptionDefaultFreeSoftInventoryJobService
(InventoryTransactionService<InventoryTransaction> inventoryTransactionService, SkuInventoryAdjustmentService<SkuInventory> adjustmentService, org.springframework.core.env.Environment environment) -
Method Summary
Modifier and TypeMethodDescriptionvoid
freeSoftInventory
(Duration minReservationAge, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Frees soft inventory reservations that are older than the minimum reservation duration.protected SkuInventoryAdjustmentService<SkuInventory>
protected org.springframework.core.env.Environment
Gets the inventory transaction types that should be considered for freeing inventory.protected InventoryTransactionService<InventoryTransaction>
protected Instant
getMaxCreatedDate
(Duration minReservationAge) Get the maximum created date to consider for inventory transactions that should be freed.protected int
Gets the page size to use for freeing inventory.protected org.springframework.data.domain.Pageable
Gets the starting pageable to be used for freeing inventory.
-
Field Details
-
DEFAULT_PAGE_SIZE
protected static final int DEFAULT_PAGE_SIZE- See Also:
-
DEFAULT_FREEABLE_TYPES
-
-
Constructor Details
-
DefaultFreeSoftInventoryJobService
public DefaultFreeSoftInventoryJobService(InventoryTransactionService<InventoryTransaction> inventoryTransactionService, SkuInventoryAdjustmentService<SkuInventory> adjustmentService, org.springframework.core.env.Environment environment)
-
-
Method Details
-
freeSoftInventory
public void freeSoftInventory(Duration minReservationAge, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:FreeSoftInventoryJobService
Frees soft inventory reservations that are older than the minimum reservation duration.The minimum reservation duration is an expression of the minimum age a soft inventory reservation must be in order to be freed. For example, if the duration was 5 minutes and the time was 17:27, soft inventory reservations created before 17:22 would be freed (assuming they weren't converted to a different type of reservation).
- Specified by:
freeSoftInventory
in interfaceFreeSoftInventoryJobService
- Parameters:
minReservationAge
- the minimum age a reservation should exist before being a candidate for being freedcontext
- the context to free soft inventory in
-
getMaxCreatedDate
Get the maximum created date to consider for inventory transactions that should be freed.- Parameters:
minReservationAge
- the minimum age the inventory transaction should be to be freed.- Returns:
- the maximum date
-
getStartPageable
protected org.springframework.data.domain.Pageable getStartPageable()Gets the starting pageable to be used for freeing inventory.- Returns:
- the starting pageable
-
getPageSize
protected int getPageSize()Gets the page size to use for freeing inventory.- Returns:
- the page size
-
getFreeableTransactionTypes
Gets the inventory transaction types that should be considered for freeing inventory.- Returns:
- a set of inventory transaction types
-
getInventoryTransactionService
-
getAdjustmentService
-
getEnvironment
protected org.springframework.core.env.Environment getEnvironment()
-