Class DefaultRAOConsumptionSupport
- java.lang.Object
-
- de.hybris.platform.ruleengineservices.rule.evaluation.actions.impl.DefaultRAOConsumptionSupport
-
- All Implemented Interfaces:
RAOConsumptionSupport
public class DefaultRAOConsumptionSupport extends java.lang.Object implements RAOConsumptionSupport
Default implementation ofRAOConsumptionSupport
-
-
Constructor Summary
Constructors Constructor Description DefaultRAOConsumptionSupport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intadjustStrategyQuantity(java.util.Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs)Adjusts the quantity fields of EntriesSelectionStrategyRPD such that the maximum possible number of entries will be consumed by the action.intadjustStrategyQuantity(java.util.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.protected java.math.BigDecimaladjustUnitPrice(OrderEntryRAO orderEntryRao)protected java.math.BigDecimaladjustUnitPrice(OrderEntryRAO orderEntryRao, int quantity)<T extends AbstractRuleActionRAO>
voidconsumeOrderEntries(RuleActionContext context, java.util.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.java.util.Set<OrderEntryConsumedRAO>consumeOrderEntries(java.util.Set<OrderEntryRAO> selectedEntries, java.util.Map<java.lang.Integer,java.lang.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.OrderEntryConsumedRAOconsumeOrderEntry(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 actionRAOOrderEntryConsumedRAOconsumeOrderEntry(OrderEntryRAO orderEntryRAO, int quantity, java.math.BigDecimal discountValue, AbstractRuleActionRAO actionRAO)Creates a newOrderEntryConusmedRAOthat consumes the given orderEntryRAO and adds the consumed entry to the given actionRAOOrderEntryConsumedRAOconsumeOrderEntry(OrderEntryRAO orderEntryRAO, AbstractRuleActionRAO actionRAO)Creates a newOrderEntryConusmedRAOthat consumes the given orderEntryRAO and adds the consumed entry to the given actionRAOOrderEntryConsumedRAOcreateOrderEntryConsumedRAO(OrderEntryRAO orderEntryRAO, int quantity, java.math.BigDecimal discountValue)Creates new OrderEntryConsumedRAO for given OrderEntryRAO and with given quantity.intgetConsumableQuantity(OrderEntryRAO orderEntryRao)Calculate the order entry consumable quantityintgetConsumedQuantityForOrderEntry(OrderEntryRAO orderEntryRao)Return consumed quantity for a given order entryprotected intgetConsumedQuantityForOrderEntry(OrderEntryRAO orderEntryRao, java.util.Set<AbstractRuleActionRAO> actions)protected CurrencyUtilsgetCurrencyUtils()java.util.Map<java.lang.Integer,java.lang.Integer>getEligibleEntryQuantities(java.util.Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs)protected java.util.Map<OrderEntrySelectionStrategy,EntriesSelectionStrategy>getEntriesSelectionStrategies()protected PriceAdjustmentStrategy<OrderEntryRAO>getPriceAdjustmentStrategy()protected java.util.Map<OrderEntrySelectionStrategy,EntriesSelectionStrategy>getQualifyingEntriesSelectionStrategies()protected RAOLookupServicegetRaoLookupService()java.util.Map<java.lang.Integer,java.lang.Integer>getSelectedOrderEntryQuantities(RuleActionContext context, java.util.Collection<EntriesSelectionStrategyRPD> strategies)Gets Order Entry identifiers (orderEntry.entryNumber) and Unit Quantity To Be Consumed for the Order Entries.java.util.Set<OrderEntryRAO>getSelectedOrderEntryRaos(java.util.Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs, java.util.Map<java.lang.Integer,java.lang.Integer> selectedOrderEntryMap)Gets Order Entry set to be discounted as a result of bundle processing.protected SwitchServicegetSwitchService()booleanhasEnoughQuantity(RuleActionContext context, java.util.Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs)Checks if allentriesSelectionStrategyRPDshave enough quantity.booleanisConsumptionEnabled()Identifies 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(java.util.Map<java.lang.Integer,java.lang.Integer> entriesToBeConsumedMap, EntriesSelectionStrategyRPD strategy)voidsetCurrencyUtils(CurrencyUtils currencyUtils)voidsetEntriesSelectionStrategies(java.util.Map<OrderEntrySelectionStrategy,EntriesSelectionStrategy> entriesSelectionStrategies)voidsetPriceAdjustmentStrategy(PriceAdjustmentStrategy<OrderEntryRAO> priceAdjustmentStrategy)voidsetQualifyingEntriesSelectionStrategies(java.util.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.
-
-
-
Method Detail
-
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
public void trackConsumedProducts(RuleActionContext context)
- Specified by:
trackConsumedProductsin interfaceRAOConsumptionSupport- Parameters:
context- instance ofRuleActionContext
-
consumeOrderEntry
public OrderEntryConsumedRAO consumeOrderEntry(OrderEntryRAO orderEntryRAO, int quantity, java.math.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, java.util.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 java.util.Set<OrderEntryConsumedRAO> consumeOrderEntries(java.util.Set<OrderEntryRAO> selectedEntries, java.util.Map<java.lang.Integer,java.lang.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
public int getConsumedQuantityForOrderEntry(OrderEntryRAO orderEntryRao)
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 java.util.Map<java.lang.Integer,java.lang.Integer> getSelectedOrderEntryQuantities(RuleActionContext context, java.util.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 java.util.Set<OrderEntryRAO> getSelectedOrderEntryRaos(java.util.Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs, java.util.Map<java.lang.Integer,java.lang.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, java.math.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, java.util.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.
-
getEligibleEntryQuantities
public java.util.Map<java.lang.Integer,java.lang.Integer> getEligibleEntryQuantities(java.util.Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs)
- Specified by:
getEligibleEntryQuantitiesin interfaceRAOConsumptionSupport
-
adjustStrategyQuantity
public int adjustStrategyQuantity(java.util.Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs)
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(java.util.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
-
getConsumableQuantity
public int getConsumableQuantity(OrderEntryRAO orderEntryRao)
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
-
putEligibleEntryQuantities
protected void putEligibleEntryQuantities(java.util.Map<java.lang.Integer,java.lang.Integer> entriesToBeConsumedMap, EntriesSelectionStrategyRPD strategy)
-
adjustUnitPrice
protected java.math.BigDecimal adjustUnitPrice(OrderEntryRAO orderEntryRao)
-
adjustUnitPrice
protected java.math.BigDecimal adjustUnitPrice(OrderEntryRAO orderEntryRao, int quantity)
-
getConsumedQuantityForOrderEntry
protected int getConsumedQuantityForOrderEntry(OrderEntryRAO orderEntryRao, java.util.Set<AbstractRuleActionRAO> actions)
-
getRaoLookupService
protected RAOLookupService getRaoLookupService()
-
setRaoLookupService
public void setRaoLookupService(RAOLookupService raoLookupService)
-
getEntriesSelectionStrategies
protected java.util.Map<OrderEntrySelectionStrategy,EntriesSelectionStrategy> getEntriesSelectionStrategies()
-
setEntriesSelectionStrategies
public void setEntriesSelectionStrategies(java.util.Map<OrderEntrySelectionStrategy,EntriesSelectionStrategy> entriesSelectionStrategies)
-
getQualifyingEntriesSelectionStrategies
protected java.util.Map<OrderEntrySelectionStrategy,EntriesSelectionStrategy> getQualifyingEntriesSelectionStrategies()
-
setQualifyingEntriesSelectionStrategies
public void setQualifyingEntriesSelectionStrategies(java.util.Map<OrderEntrySelectionStrategy,EntriesSelectionStrategy> qualifyingEntriesSelectionStrategies)
-
getCurrencyUtils
protected CurrencyUtils getCurrencyUtils()
-
setCurrencyUtils
public void setCurrencyUtils(CurrencyUtils currencyUtils)
-
getSwitchService
protected SwitchService getSwitchService()
-
setSwitchService
public void setSwitchService(SwitchService switchService)
-
getPriceAdjustmentStrategy
protected PriceAdjustmentStrategy<OrderEntryRAO> getPriceAdjustmentStrategy()
-
setPriceAdjustmentStrategy
public void setPriceAdjustmentStrategy(PriceAdjustmentStrategy<OrderEntryRAO> priceAdjustmentStrategy)
-
-