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
Fields Modifier and Type Field Description protected static Set<String>DEFAULT_FREEABLE_TYPESprotected static intDEFAULT_PAGE_SIZE
-
Constructor Summary
Constructors Constructor Description DefaultFreeSoftInventoryJobService(InventoryTransactionService<InventoryTransaction> inventoryTransactionService, SkuInventoryAdjustmentService<SkuInventory> adjustmentService, org.springframework.core.env.Environment environment)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfreeSoftInventory(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>getAdjustmentService()protected org.springframework.core.env.EnvironmentgetEnvironment()protected Set<String>getFreeableTransactionTypes()Gets the inventory transaction types that should be considered for freeing inventory.protected InventoryTransactionService<InventoryTransaction>getInventoryTransactionService()protected InstantgetMaxCreatedDate(Duration minReservationAge)Get the maximum created date to consider for inventory transactions that should be freed.protected intgetPageSize()Gets the page size to use for freeing inventory.protected org.springframework.data.domain.PageablegetStartPageable()Gets the starting pageable to be used for freeing inventory.
-
-
-
Field Detail
-
DEFAULT_PAGE_SIZE
protected static final int DEFAULT_PAGE_SIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultFreeSoftInventoryJobService
public DefaultFreeSoftInventoryJobService(InventoryTransactionService<InventoryTransaction> inventoryTransactionService, SkuInventoryAdjustmentService<SkuInventory> adjustmentService, org.springframework.core.env.Environment environment)
-
-
Method Detail
-
freeSoftInventory
public void freeSoftInventory(Duration minReservationAge, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:FreeSoftInventoryJobServiceFrees 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:
freeSoftInventoryin 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
protected Instant getMaxCreatedDate(Duration minReservationAge)
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
protected Set<String> getFreeableTransactionTypes()
Gets the inventory transaction types that should be considered for freeing inventory.- Returns:
- a set of inventory transaction types
-
getInventoryTransactionService
protected InventoryTransactionService<InventoryTransaction> getInventoryTransactionService()
-
getAdjustmentService
protected SkuInventoryAdjustmentService<SkuInventory> getAdjustmentService()
-
getEnvironment
protected org.springframework.core.env.Environment getEnvironment()
-
-