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 int
adjustStrategyQuantity(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.int
adjustStrategyQuantity(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.BigDecimal
adjustUnitPrice(OrderEntryRAO orderEntryRao)
protected java.math.BigDecimal
adjustUnitPrice(OrderEntryRAO orderEntryRao, int quantity)
<T extends AbstractRuleActionRAO>
voidconsumeOrderEntries(RuleActionContext context, java.util.Collection<EntriesSelectionStrategyRPD> strategies, T actionRAO)
Creates newOrderEntryConusmedRAO
s for the given strategies, links them to the givenactionRAO
and 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 newOrderEntryConusmedRAO
s with the given quantity, links it to the givenactionRAO
and reduces available quantity of order entry by given quantity for every Order Entry from the set and using quantity fromdiscountedOrderEntryMap
.OrderEntryConsumedRAO
consumeOrderEntry(OrderEntryRAO orderEntryRAO, int quantity, AbstractRuleActionRAO actionRAO)
Creates a newOrderEntryConusmedRAO
that consumes the given orderEntryRAO with the given quantity and adds the consumed entry to the given actionRAOOrderEntryConsumedRAO
consumeOrderEntry(OrderEntryRAO orderEntryRAO, int quantity, java.math.BigDecimal discountValue, AbstractRuleActionRAO actionRAO)
Creates a newOrderEntryConusmedRAO
that consumes the given orderEntryRAO and adds the consumed entry to the given actionRAOOrderEntryConsumedRAO
consumeOrderEntry(OrderEntryRAO orderEntryRAO, AbstractRuleActionRAO actionRAO)
Creates a newOrderEntryConusmedRAO
that consumes the given orderEntryRAO and adds the consumed entry to the given actionRAOOrderEntryConsumedRAO
createOrderEntryConsumedRAO(OrderEntryRAO orderEntryRAO, int quantity, java.math.BigDecimal discountValue)
Creates new OrderEntryConsumedRAO for given OrderEntryRAO and with given quantity.int
getConsumableQuantity(OrderEntryRAO orderEntryRao)
Calculate the order entry consumable quantityint
getConsumedQuantityForOrderEntry(OrderEntryRAO orderEntryRao)
Return consumed quantity for a given order entryprotected int
getConsumedQuantityForOrderEntry(OrderEntryRAO orderEntryRao, java.util.Set<AbstractRuleActionRAO> actions)
protected CurrencyUtils
getCurrencyUtils()
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 RAOLookupService
getRaoLookupService()
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 SwitchService
getSwitchService()
boolean
hasEnoughQuantity(RuleActionContext context, java.util.Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs)
Checks if allentriesSelectionStrategyRPDs
have enough quantity.boolean
isConsumptionEnabled()
Identifies whether order entry consumption is enabledvoid
mergeOrderEntryConsumed(OrderEntryConsumedRAO consumedTarget, OrderEntryConsumedRAO consumedSource)
Method merges the properties of two instances ofOrderEntryConsumedRAO
if the objects refer to the same order entry number and same ruleprotected void
putEligibleEntryQuantities(java.util.Map<java.lang.Integer,java.lang.Integer> entriesToBeConsumedMap, EntriesSelectionStrategyRPD strategy)
void
setCurrencyUtils(CurrencyUtils currencyUtils)
void
setEntriesSelectionStrategies(java.util.Map<OrderEntrySelectionStrategy,EntriesSelectionStrategy> entriesSelectionStrategies)
void
setPriceAdjustmentStrategy(PriceAdjustmentStrategy<OrderEntryRAO> priceAdjustmentStrategy)
void
setQualifyingEntriesSelectionStrategies(java.util.Map<OrderEntrySelectionStrategy,EntriesSelectionStrategy> qualifyingEntriesSelectionStrategies)
void
setRaoLookupService(RAOLookupService raoLookupService)
void
setSwitchService(SwitchService switchService)
void
trackConsumedProducts(RuleActionContext context)
void
updateActionRAOWithConsumed(AbstractRuleActionRAO actionRAO, OrderEntryConsumedRAO orderEntryConsumedRAO)
Adds given OrderEntryConsumedRAO to the AbstractRuleActionRAO.consumedEntries.
-
-
-
Method Detail
-
isConsumptionEnabled
public boolean isConsumptionEnabled()
Description copied from interface:RAOConsumptionSupport
Identifies whether order entry consumption is enabled- Specified by:
isConsumptionEnabled
in interfaceRAOConsumptionSupport
- Returns:
true
in case consumption is enabled,false
otherwise
-
trackConsumedProducts
public void trackConsumedProducts(RuleActionContext context)
- Specified by:
trackConsumedProducts
in interfaceRAOConsumptionSupport
- Parameters:
context
- instance ofRuleActionContext
-
consumeOrderEntry
public OrderEntryConsumedRAO consumeOrderEntry(OrderEntryRAO orderEntryRAO, int quantity, java.math.BigDecimal discountValue, AbstractRuleActionRAO actionRAO)
Description copied from interface:RAOConsumptionSupport
Creates a newOrderEntryConusmedRAO
that consumes the given orderEntryRAO and adds the consumed entry to the given actionRAO- Specified by:
consumeOrderEntry
in 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:RAOConsumptionSupport
Creates a newOrderEntryConusmedRAO
that consumes the given orderEntryRAO and adds the consumed entry to the given actionRAO- Specified by:
consumeOrderEntry
in 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:RAOConsumptionSupport
Creates a newOrderEntryConusmedRAO
that consumes the given orderEntryRAO with the given quantity and adds the consumed entry to the given actionRAO- Specified by:
consumeOrderEntry
in 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:RAOConsumptionSupport
Creates newOrderEntryConusmedRAO
s for the given strategies, links them to the givenactionRAO
and reduces available quantity of order entry by given quantity for every Order Entry from the set and using quantity fromdiscountedOrderEntryMap
.- Specified by:
consumeOrderEntries
in interfaceRAOConsumptionSupport
- Parameters:
context
- instance ofRuleActionContext
strategies
- the selection strategiesactionRAO
- theAbstractRuleActionRAO
to 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:RAOConsumptionSupport
Creates newOrderEntryConusmedRAO
s with the given quantity, links it to the givenactionRAO
and reduces available quantity of order entry by given quantity for every Order Entry from the set and using quantity fromdiscountedOrderEntryMap
.- Specified by:
consumeOrderEntries
in interfaceRAOConsumptionSupport
- Parameters:
selectedEntries
- Order Entries to be consumedselectedEntriesMap
- Map having orderEntry.entryNumber as keys and Unit Quantity To Be Consumed as valuesactionRAO
- theAbstractRuleActionRAO
to add the newly created consumed entries to
-
getConsumedQuantityForOrderEntry
public int getConsumedQuantityForOrderEntry(OrderEntryRAO orderEntryRao)
Description copied from interface:RAOConsumptionSupport
Return consumed quantity for a given order entry- Specified by:
getConsumedQuantityForOrderEntry
in 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:RAOConsumptionSupport
Gets Order Entry identifiers (orderEntry.entryNumber) and Unit Quantity To Be Consumed for the Order Entries.- Specified by:
getSelectedOrderEntryQuantities
in interfaceRAOConsumptionSupport
strategies
- list ofEntriesSelectionStrategyRPD
to 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:RAOConsumptionSupport
Gets Order Entry set to be discounted as a result of bundle processing.- Specified by:
getSelectedOrderEntryRaos
in interfaceRAOConsumptionSupport
- Parameters:
selectionStrategyRPDs
- list ofEntriesSelectionStrategyRPD
to 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:RAOConsumptionSupport
Creates new OrderEntryConsumedRAO for given OrderEntryRAO and with given quantity.- Specified by:
createOrderEntryConsumedRAO
in 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:RAOConsumptionSupport
Adds given OrderEntryConsumedRAO to the AbstractRuleActionRAO.consumedEntries.- Specified by:
updateActionRAOWithConsumed
in 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:RAOConsumptionSupport
Method merges the properties of two instances ofOrderEntryConsumedRAO
if the objects refer to the same order entry number and same rule- Specified by:
mergeOrderEntryConsumed
in 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:RAOConsumptionSupport
Checks if allentriesSelectionStrategyRPDs
have enough quantity.- Specified by:
hasEnoughQuantity
in interfaceRAOConsumptionSupport
selectionStrategyRPDs
- 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:
getEligibleEntryQuantities
in interfaceRAOConsumptionSupport
-
adjustStrategyQuantity
public int adjustStrategyQuantity(java.util.Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs)
Description copied from interface:RAOConsumptionSupport
Adjusts 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:
adjustStrategyQuantity
in 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:RAOConsumptionSupport
Adjusts 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:
adjustStrategyQuantity
in 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:RAOConsumptionSupport
Calculate the order entry consumable quantity- Specified by:
getConsumableQuantity
in 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)
-
-