Class DefaultStockLevelSelectionStrategy
- java.lang.Object
-
- de.hybris.platform.warehousing.stock.strategies.impl.DefaultStockLevelSelectionStrategy
-
- All Implemented Interfaces:
StockLevelSelectionStrategy
public class DefaultStockLevelSelectionStrategy extends java.lang.Object implements StockLevelSelectionStrategy
The default implementation ofStockLevelSelectionStrategy
-
-
Constructor Summary
Constructors Constructor Description DefaultStockLevelSelectionStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected longaddToStockMap(java.util.Map<StockLevelModel,java.lang.Long> stockMap, StockLevelModel stockLevel, long quantityLeft, java.lang.Long quantityAvailable)AddsStockLevelModeland quantity to the Map depending on the quantity left and quantity available.protected java.util.List<StockLevelModel>filterAsnCancelledStockLevels(java.util.Collection<StockLevelModel> stockLevels)Removes theStockLevelModel(s), which belong to cancelledAdvancedShippingNoticeModelprotected voidfinalizeStockMap(java.util.Map<StockLevelModel,java.lang.Long> stockMap, long quantityLeft)If there's still any quantity left, the first entry of the passed Stock map will be increased by this amount.protected CommerceAvailabilityCalculationStrategygetCommerceStockLevelCalculationStrategy()java.util.Map<StockLevelModel,java.lang.Long>getStockLevelsForAllocation(java.util.Collection<StockLevelModel> stockLevels, java.lang.Long quantityToAllocate)Sorts and splits theStockLevelModeland returns a Map ofStockLevelModelto fulfill the quantity passed.java.util.Map<StockLevelModel,java.lang.Long>getStockLevelsForCancellation(java.util.Collection<AllocationEventModel> allocationEvents, java.lang.Long quantityToCancel)Extracts the stock levels out of the listAllocationEventModel.voidsetCommerceStockLevelCalculationStrategy(CommerceAvailabilityCalculationStrategy commerceStockLevelCalculationStrategy)
-
-
-
Method Detail
-
getStockLevelsForAllocation
public java.util.Map<StockLevelModel,java.lang.Long> getStockLevelsForAllocation(java.util.Collection<StockLevelModel> stockLevels, java.lang.Long quantityToAllocate)
Description copied from interface:StockLevelSelectionStrategySorts and splits theStockLevelModeland returns a Map ofStockLevelModelto fulfill the quantity passed.- Specified by:
getStockLevelsForAllocationin interfaceStockLevelSelectionStrategy- Parameters:
stockLevels- collection of stock level modelquantityToAllocate- total quantity to be allocated- Returns:
- a map of
StockLevelModeland quantity to be allocated per stock level
-
getStockLevelsForCancellation
public java.util.Map<StockLevelModel,java.lang.Long> getStockLevelsForCancellation(java.util.Collection<AllocationEventModel> allocationEvents, java.lang.Long quantityToCancel)
Description copied from interface:StockLevelSelectionStrategyExtracts the stock levels out of the listAllocationEventModel. Sorts, splits and returns a Map ofStockLevelModelto fulfill the quantity passed.- Specified by:
getStockLevelsForCancellationin interfaceStockLevelSelectionStrategy- Parameters:
allocationEvents- collection of allocation eventsquantityToCancel- total quantity to be cancelled- Returns:
- a map of
StockLevelModela the quantity to cancel for this stock level.
-
addToStockMap
protected long addToStockMap(java.util.Map<StockLevelModel,java.lang.Long> stockMap, StockLevelModel stockLevel, long quantityLeft, java.lang.Long quantityAvailable)
AddsStockLevelModeland quantity to the Map depending on the quantity left and quantity available. Returns the quantity that was not able to be fulfilled by the passedStockLevelModel- Parameters:
stockMap- theStockLevelModelmap to append the stock passedstockLevel- theStockLevelModelquantityLeft- the quantity left to be added to the mapquantityAvailable- the quantity available in the passedStockLevelModel- Returns:
- the quantity left.
-
finalizeStockMap
protected void finalizeStockMap(java.util.Map<StockLevelModel,java.lang.Long> stockMap, long quantityLeft)
If there's still any quantity left, the first entry of the passed Stock map will be increased by this amount.- Parameters:
stockMap- theStockLevelModelto quantity mapquantityLeft- the quantity left to fulfill
-
filterAsnCancelledStockLevels
protected java.util.List<StockLevelModel> filterAsnCancelledStockLevels(java.util.Collection<StockLevelModel> stockLevels)
Removes theStockLevelModel(s), which belong to cancelledAdvancedShippingNoticeModel- Parameters:
stockLevels- the given collection ofStockLevelModel- Returns:
- the filtered list of
StockLevelModel(s) or null if the filtered list is empty
-
getCommerceStockLevelCalculationStrategy
protected CommerceAvailabilityCalculationStrategy getCommerceStockLevelCalculationStrategy()
-
setCommerceStockLevelCalculationStrategy
public void setCommerceStockLevelCalculationStrategy(CommerceAvailabilityCalculationStrategy commerceStockLevelCalculationStrategy)
-
-