Class DefaultRAOConsumptionSupport
java.lang.Object
de.hybris.platform.ruleengineservices.rule.evaluation.actions.impl.DefaultRAOConsumptionSupport
- All Implemented Interfaces:
RAOConsumptionSupport
Default implementation of
RAOConsumptionSupport-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanadjustMultiplierValid(RuleActionContext context, Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs, int adjustMultiplier) intadjustStrategyQuantity(Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs) Adjusts the quantity fields of EntriesSelectionStrategyRPD such that the maximum possible number of entries will be consumed by the action.intadjustStrategyQuantity(Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs, int maxCount) Adjusts the quantity fields of EntriesSelectionStrategyRPD such that the maximum possible number of entries will be consumed by the action.intadjustStrategyQuantity(Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs, RuleActionContext context) Adjusts the quantity fields of EntriesSelectionStrategyRPD such that the maximum possible number of entries will be consumed by the action.intadjustStrategyQuantity(Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs, RuleActionContext context, int maxCount) Adjusts the quantity fields of EntriesSelectionStrategyRPD such that the maximum possible number of entries will be consumed by the action.protected BigDecimaladjustUnitPrice(OrderEntryRAO orderEntryRao) protected BigDecimaladjustUnitPrice(OrderEntryRAO orderEntryRao, int quantity) <T extends AbstractRuleActionRAO>
voidconsumeOrderEntries(RuleActionContext context, Collection<EntriesSelectionStrategyRPD> strategies, T actionRAO) Creates newOrderEntryConusmedRAOs for the given strategies, links them to the givenactionRAOand reduces available quantity of order entry by given quantity for every Order Entry from the set and using quantity fromdiscountedOrderEntryMap.consumeOrderEntries(Set<OrderEntryRAO> selectedEntries, Map<Integer, Integer> selectedEntriesMap, AbstractRuleActionRAO actionRAO) Creates newOrderEntryConusmedRAOs with the given quantity, links it to the givenactionRAOand reduces available quantity of order entry by given quantity for every Order Entry from the set and using quantity fromdiscountedOrderEntryMap.consumeOrderEntry(OrderEntryRAO orderEntryRAO, int quantity, AbstractRuleActionRAO actionRAO) Creates a newOrderEntryConusmedRAOthat consumes the given orderEntryRAO with the given quantity and adds the consumed entry to the given actionRAOconsumeOrderEntry(OrderEntryRAO orderEntryRAO, int quantity, BigDecimal discountValue, AbstractRuleActionRAO actionRAO) Creates a newOrderEntryConusmedRAOthat consumes the given orderEntryRAO and adds the consumed entry to the given actionRAOconsumeOrderEntry(OrderEntryRAO orderEntryRAO, AbstractRuleActionRAO actionRAO) Creates a newOrderEntryConusmedRAOthat consumes the given orderEntryRAO and adds the consumed entry to the given actionRAOcreateOrderEntryConsumedRAO(OrderEntryRAO orderEntryRAO, int quantity, BigDecimal discountValue) Creates new OrderEntryConsumedRAO for given OrderEntryRAO and with given quantity.protected intintgetConsumableQuantity(OrderEntryRAO orderEntryRao) Calculate the order entry consumable quantitygetConsumedOrderEntryInfoForOrderEntry(OrderEntryRAO orderEntryRao) Calculate the order entry discount infosprotected Set<OrderEntryConsumedRAO>getConsumedOrderEntryInfoForOrderEntry(OrderEntryRAO orderEntryRAO, Set<AbstractRuleActionRAO> actions) intgetConsumedQuantityForOrderEntry(OrderEntryRAO orderEntryRao) Return consumed quantity for a given order entryprotected intgetConsumedQuantityForOrderEntry(OrderEntryRAO orderEntryRao, Set<AbstractRuleActionRAO> actions) protected CurrencyUtilsgetEligibleEntryQuantities(Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs) protected PriceAdjustmentStrategy<OrderEntryRAO>protected RAOLookupServicegetSelectedOrderEntryQuantities(RuleActionContext context, Collection<EntriesSelectionStrategyRPD> strategies) Gets Order Entry identifiers (orderEntry.entryNumber) and Unit Quantity To Be Consumed for the Order Entries.getSelectedOrderEntryRaos(Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs, Map<Integer, Integer> selectedOrderEntryMap) Gets Order Entry set to be discounted as a result of bundle processing.protected SwitchServicebooleanhasEnoughQuantity(RuleActionContext context, Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs) Checks if allentriesSelectionStrategyRPDshave enough quantity.protected booleanhasEnoughQuantity(Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs) booleanIdentifies whether order entry consumption is enabledvoidmergeOrderEntryConsumed(OrderEntryConsumedRAO consumedTarget, OrderEntryConsumedRAO consumedSource) Method merges the properties of two instances ofOrderEntryConsumedRAOif the objects refer to the same order entry number and same ruleprotected voidputEligibleEntryQuantities(Map<Integer, Integer> entriesToBeConsumedMap, EntriesSelectionStrategyRPD strategy) Deprecated, for removal: This API element is subject to removal in a future version.since 2205, Please use putEligibleEntryQuantities(entryQuantities, entriesToBeConsumedMap, strategy)protected voidputEligibleEntryQuantities(Map<Integer, Integer> entryQuantities, Map<Integer, Integer> entriesToBeConsumedMap, EntriesSelectionStrategyRPD strategy) protected EntriesSelectionStrategyRPDsaveSourceRPDWithAdjustMultiplierAsNew(EntriesSelectionStrategyRPD source, int adjustMultiplier) voidsetCurrencyUtils(CurrencyUtils currencyUtils) voidsetEntriesSelectionStrategies(Map<OrderEntrySelectionStrategy, EntriesSelectionStrategy> entriesSelectionStrategies) voidsetPriceAdjustmentStrategy(PriceAdjustmentStrategy<OrderEntryRAO> priceAdjustmentStrategy) voidsetQualifyingEntriesSelectionStrategies(Map<OrderEntrySelectionStrategy, EntriesSelectionStrategy> qualifyingEntriesSelectionStrategies) voidsetRaoLookupService(RAOLookupService raoLookupService) voidsetSwitchService(SwitchService switchService) voidtrackConsumedProducts(RuleActionContext context) voidupdateActionRAOWithConsumed(AbstractRuleActionRAO actionRAO, OrderEntryConsumedRAO orderEntryConsumedRAO) Adds given OrderEntryConsumedRAO to the AbstractRuleActionRAO.consumedEntries.
-
Constructor Details
-
DefaultRAOConsumptionSupport
public DefaultRAOConsumptionSupport()
-
-
Method Details
-
isConsumptionEnabled
public boolean isConsumptionEnabled()Description copied from interface:RAOConsumptionSupportIdentifies whether order entry consumption is enabled- Specified by:
isConsumptionEnabledin interfaceRAOConsumptionSupport- Returns:
truein case consumption is enabled,falseotherwise
-
trackConsumedProducts
- Specified by:
trackConsumedProductsin interfaceRAOConsumptionSupport- Parameters:
context- instance ofRuleActionContext
-
consumeOrderEntry
public OrderEntryConsumedRAO consumeOrderEntry(OrderEntryRAO orderEntryRAO, int quantity, BigDecimal discountValue, AbstractRuleActionRAO actionRAO) Description copied from interface:RAOConsumptionSupportCreates a newOrderEntryConusmedRAOthat consumes the given orderEntryRAO and adds the consumed entry to the given actionRAO- Specified by:
consumeOrderEntryin interfaceRAOConsumptionSupport- Parameters:
orderEntryRAO- the order entry to consumequantity- the quantity to consumediscountValue- the discount this order entry consumption gaveactionRAO- the action rao to add the consumed entry to- Returns:
- the newly created consumed entry
-
consumeOrderEntry
public OrderEntryConsumedRAO consumeOrderEntry(OrderEntryRAO orderEntryRAO, AbstractRuleActionRAO actionRAO) Description copied from interface:RAOConsumptionSupportCreates a newOrderEntryConusmedRAOthat consumes the given orderEntryRAO and adds the consumed entry to the given actionRAO- Specified by:
consumeOrderEntryin interfaceRAOConsumptionSupport- Parameters:
orderEntryRAO- the order entry to consumeactionRAO- the action rao to add the consumed entry to- Returns:
- the newly created consumed entry
-
consumeOrderEntry
public OrderEntryConsumedRAO consumeOrderEntry(OrderEntryRAO orderEntryRAO, int quantity, AbstractRuleActionRAO actionRAO) Description copied from interface:RAOConsumptionSupportCreates a newOrderEntryConusmedRAOthat consumes the given orderEntryRAO with the given quantity and adds the consumed entry to the given actionRAO- Specified by:
consumeOrderEntryin interfaceRAOConsumptionSupport- Parameters:
orderEntryRAO- the order entry to consumequantity- the quantity to consumeactionRAO- the action rao to add the consumed entry to- Returns:
- the newly created consumed entry
-
consumeOrderEntries
public <T extends AbstractRuleActionRAO> void consumeOrderEntries(RuleActionContext context, Collection<EntriesSelectionStrategyRPD> strategies, T actionRAO) Description copied from interface:RAOConsumptionSupportCreates newOrderEntryConusmedRAOs for the given strategies, links them to the givenactionRAOand reduces available quantity of order entry by given quantity for every Order Entry from the set and using quantity fromdiscountedOrderEntryMap.- Specified by:
consumeOrderEntriesin interfaceRAOConsumptionSupport- Parameters:
context- instance ofRuleActionContextstrategies- the selection strategiesactionRAO- theAbstractRuleActionRAOto add the newly created consumed entries to
-
consumeOrderEntries
public Set<OrderEntryConsumedRAO> consumeOrderEntries(Set<OrderEntryRAO> selectedEntries, Map<Integer, Integer> selectedEntriesMap, AbstractRuleActionRAO actionRAO) Description copied from interface:RAOConsumptionSupportCreates newOrderEntryConusmedRAOs with the given quantity, links it to the givenactionRAOand reduces available quantity of order entry by given quantity for every Order Entry from the set and using quantity fromdiscountedOrderEntryMap.- Specified by:
consumeOrderEntriesin interfaceRAOConsumptionSupport- Parameters:
selectedEntries- Order Entries to be consumedselectedEntriesMap- Map having orderEntry.entryNumber as keys and Unit Quantity To Be Consumed as valuesactionRAO- theAbstractRuleActionRAOto add the newly created consumed entries to
-
getConsumedQuantityForOrderEntry
Description copied from interface:RAOConsumptionSupportReturn consumed quantity for a given order entry- Specified by:
getConsumedQuantityForOrderEntryin interfaceRAOConsumptionSupport- Parameters:
orderEntryRao- Cart order entry- Returns:
- consumed quantity
-
getSelectedOrderEntryQuantities
public Map<Integer,Integer> getSelectedOrderEntryQuantities(RuleActionContext context, Collection<EntriesSelectionStrategyRPD> strategies) Description copied from interface:RAOConsumptionSupportGets Order Entry identifiers (orderEntry.entryNumber) and Unit Quantity To Be Consumed for the Order Entries.- Specified by:
getSelectedOrderEntryQuantitiesin interfaceRAOConsumptionSupportstrategies- list ofEntriesSelectionStrategyRPDto pickup units according to the strategies- Returns:
- Map having orderEntry.entryNumber as keys and Unit Quantity To Be Consumed as values
-
getSelectedOrderEntryRaos
public Set<OrderEntryRAO> getSelectedOrderEntryRaos(Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs, Map<Integer, Integer> selectedOrderEntryMap) Description copied from interface:RAOConsumptionSupportGets Order Entry set to be discounted as a result of bundle processing.- Specified by:
getSelectedOrderEntryRaosin interfaceRAOConsumptionSupport- Parameters:
selectionStrategyRPDs- list ofEntriesSelectionStrategyRPDto pickup units according to the strategiesselectedOrderEntryMap- Map having orderEntry.entryNumber as keys and Unit Quantity To Be Consumed as values
-
createOrderEntryConsumedRAO
public OrderEntryConsumedRAO createOrderEntryConsumedRAO(OrderEntryRAO orderEntryRAO, int quantity, BigDecimal discountValue) Description copied from interface:RAOConsumptionSupportCreates new OrderEntryConsumedRAO for given OrderEntryRAO and with given quantity.- Specified by:
createOrderEntryConsumedRAOin interfaceRAOConsumptionSupport- Parameters:
orderEntryRAO- OrderEntryRAO to create consumed entry forquantity- Consumed quantitydiscountValue- the discount this order entry consumption gave- Returns:
- created OrderEntryConsumedRAO
-
updateActionRAOWithConsumed
public void updateActionRAOWithConsumed(AbstractRuleActionRAO actionRAO, OrderEntryConsumedRAO orderEntryConsumedRAO) Description copied from interface:RAOConsumptionSupportAdds given OrderEntryConsumedRAO to the AbstractRuleActionRAO.consumedEntries.- Specified by:
updateActionRAOWithConsumedin interfaceRAOConsumptionSupport- Parameters:
actionRAO- AbstractRuleActionRAO to be updatedorderEntryConsumedRAO- to be added to the AbstractRuleActionRAO
-
mergeOrderEntryConsumed
public void mergeOrderEntryConsumed(OrderEntryConsumedRAO consumedTarget, OrderEntryConsumedRAO consumedSource) Description copied from interface:RAOConsumptionSupportMethod merges the properties of two instances ofOrderEntryConsumedRAOif the objects refer to the same order entry number and same rule- Specified by:
mergeOrderEntryConsumedin interfaceRAOConsumptionSupport- Parameters:
consumedTarget- where to merge the data toconsumedSource- where to merge the data from
-
hasEnoughQuantity
public boolean hasEnoughQuantity(RuleActionContext context, Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs) Description copied from interface:RAOConsumptionSupportChecks if allentriesSelectionStrategyRPDshave enough quantity.- Specified by:
hasEnoughQuantityin interfaceRAOConsumptionSupportselectionStrategyRPDs- List of EntriesSelectionStrategyRPD to check- Returns:
- true if all entries selection strategies have enough quantity. false if at least one doesn't have.
-
hasEnoughQuantity
-
getEligibleEntryQuantities
public Map<Integer,Integer> getEligibleEntryQuantities(Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs) - Specified by:
getEligibleEntryQuantitiesin interfaceRAOConsumptionSupport
-
adjustStrategyQuantity
Description copied from interface:RAOConsumptionSupportAdjusts the quantity fields of EntriesSelectionStrategyRPD such that the maximum possible number of entries will be consumed by the action. This is done by finding the highest integer multiple that the strategy.quantity can be multiplied by that there is sufficient quantity in the associated OrderEntryRAO object. This figure is then multiplied by the original quantity of the selection strategy.- Specified by:
adjustStrategyQuantityin interfaceRAOConsumptionSupport- Parameters:
selectionStrategyRPDs- list of EntriesSelectionStrategyRPD to be updated- Returns:
- The multiple count used to scale the quantity fields of the strategy objects
-
adjustStrategyQuantity
public int adjustStrategyQuantity(Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs, int maxCount) Description copied from interface:RAOConsumptionSupportAdjusts the quantity fields of EntriesSelectionStrategyRPD such that the maximum possible number of entries will be consumed by the action. This is done by finding the highest integer multiple that the strategy.quantity can be multiplied by that there is sufficient quantity in the associated OrderEntryRAO object. This figure is then multiplied by the original quantity of the selection strategy.- Specified by:
adjustStrategyQuantityin interfaceRAOConsumptionSupport- Parameters:
selectionStrategyRPDs- list of EntriesSelectionStrategyRPD to be updatedmaxCount- when maxCount is greater than 0, this parameter acts as an absolute maximum for the multiple.- Returns:
- The multiple count used to scale the quantity fields of the strategy objects
-
adjustStrategyQuantity
public int adjustStrategyQuantity(Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs, RuleActionContext context) Description copied from interface:RAOConsumptionSupportAdjusts the quantity fields of EntriesSelectionStrategyRPD such that the maximum possible number of entries will be consumed by the action. This is done by finding the highest integer multiple that the strategy.quantity can be multiplied by that there is sufficient quantity in the associated OrderEntryRAO object. This figure is then multiplied by the original quantity of the selection strategy.- Specified by:
adjustStrategyQuantityin interfaceRAOConsumptionSupport- Parameters:
selectionStrategyRPDs- list of EntriesSelectionStrategyRPD to be updatedcontext- instance ofRuleActionContext- Returns:
- The multiple count used to scale the quantity fields of the strategy objects
-
adjustStrategyQuantity
public int adjustStrategyQuantity(Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs, RuleActionContext context, int maxCount) Description copied from interface:RAOConsumptionSupportAdjusts the quantity fields of EntriesSelectionStrategyRPD such that the maximum possible number of entries will be consumed by the action. This is done by finding the highest integer multiple that the strategy.quantity can be multiplied by that there is sufficient quantity in the associated OrderEntryRAO object. This figure is then multiplied by the original quantity of the selection strategy.- Specified by:
adjustStrategyQuantityin interfaceRAOConsumptionSupport- Parameters:
selectionStrategyRPDs- list of EntriesSelectionStrategyRPD to be updatedcontext- instance ofRuleActionContextmaxCount- when maxCount is greater than 0, this parameter acts as an absolute maximum for the multiple.- Returns:
- The multiple count used to scale the quantity fields of the strategy objects
-
getAdjustMultiplierForStrategyRPD
-
adjustMultiplierValid
protected boolean adjustMultiplierValid(RuleActionContext context, Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs, int adjustMultiplier) -
saveSourceRPDWithAdjustMultiplierAsNew
protected EntriesSelectionStrategyRPD saveSourceRPDWithAdjustMultiplierAsNew(EntriesSelectionStrategyRPD source, int adjustMultiplier) -
getConsumableQuantity
Description copied from interface:RAOConsumptionSupportCalculate the order entry consumable quantity- Specified by:
getConsumableQuantityin interfaceRAOConsumptionSupport- Parameters:
orderEntryRao- instance ofOrderEntryRAO- Returns:
- number of units available for consumption
-
getConsumedOrderEntryInfoForOrderEntry
public Set<OrderEntryConsumedRAO> getConsumedOrderEntryInfoForOrderEntry(OrderEntryRAO orderEntryRao) Description copied from interface:RAOConsumptionSupportCalculate the order entry discount infos- Specified by:
getConsumedOrderEntryInfoForOrderEntryin interfaceRAOConsumptionSupport- Parameters:
orderEntryRao- instance ofOrderEntryRAO- Returns:
- The order entry discount infos
-
getConsumedOrderEntryInfoForOrderEntry
protected Set<OrderEntryConsumedRAO> getConsumedOrderEntryInfoForOrderEntry(OrderEntryRAO orderEntryRAO, Set<AbstractRuleActionRAO> actions) -
putEligibleEntryQuantities
@Deprecated(since="2205", forRemoval=true) protected void putEligibleEntryQuantities(Map<Integer, Integer> entriesToBeConsumedMap, EntriesSelectionStrategyRPD strategy) Deprecated, for removal: This API element is subject to removal in a future version.since 2205, Please use putEligibleEntryQuantities(entryQuantities, entriesToBeConsumedMap, strategy)- Parameters:
entriesToBeConsumedMap- entries need to consume, merge the result into this mapstrategy- StrategyRPD for a container
-
putEligibleEntryQuantities
-
adjustUnitPrice
-
adjustUnitPrice
-
getConsumedQuantityForOrderEntry
protected int getConsumedQuantityForOrderEntry(OrderEntryRAO orderEntryRao, Set<AbstractRuleActionRAO> actions) -
getRaoLookupService
-
setRaoLookupService
-
getEntriesSelectionStrategies
-
setEntriesSelectionStrategies
public void setEntriesSelectionStrategies(Map<OrderEntrySelectionStrategy, EntriesSelectionStrategy> entriesSelectionStrategies) -
getQualifyingEntriesSelectionStrategies
protected Map<OrderEntrySelectionStrategy,EntriesSelectionStrategy> getQualifyingEntriesSelectionStrategies() -
setQualifyingEntriesSelectionStrategies
public void setQualifyingEntriesSelectionStrategies(Map<OrderEntrySelectionStrategy, EntriesSelectionStrategy> qualifyingEntriesSelectionStrategies) -
getCurrencyUtils
-
setCurrencyUtils
-
getSwitchService
-
setSwitchService
-
getPriceAdjustmentStrategy
-
setPriceAdjustmentStrategy
public void setPriceAdjustmentStrategy(PriceAdjustmentStrategy<OrderEntryRAO> priceAdjustmentStrategy)
-