public class AbstractRuleExecutableSupport extends java.lang.Object implements RAOAction
| Constructor and Description |
|---|
AbstractRuleExecutableSupport() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addMetadataToRao(AbstractRuleActionRAO rao,
RuleActionContext context) |
protected 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) |
protected boolean |
allowedByRuntimeConfiguration(RuleActionContext context)
query method to allow for rule execution by
RuleConfigurationRRD |
protected KnowledgeHelper |
checkAndGetRuleContext(RuleActionContext context)
Checks that the given
ruleContext is of type KnowledgeHelper (i.e. |
protected <T extends AbstractRuleActionRAO> |
consumeOrderEntries(RuleActionContext context,
java.util.Collection<EntriesSelectionStrategyRPD> strategies,
T actionRAO)
Creates new
OrderEntryConusmedRAOs for the given strategies, links them to the given actionRAO and
reduces available quantity of order entry by given quantity for every Order Entry from the set and using quantity
from discountedOrderEntryMap. |
protected java.util.Set<OrderEntryConsumedRAO> |
consumeOrderEntries(java.util.Set<OrderEntryRAO> selectedEntries,
java.util.Map<java.lang.Integer,java.lang.Integer> selectedEntriesMap,
AbstractRuleActionRAO actionRAO)
Creates new
OrderEntryConusmedRAOs with the given quantity, links it to the given actionRAO and
reduces available quantity of order entry by given quantity for every Order Entry from the set and using quantity
from discountedOrderEntryMap. |
protected OrderEntryConsumedRAO |
consumeOrderEntry(OrderEntryRAO orderEntryRAO,
AbstractRuleActionRAO actionRAO)
Creates a new
OrderEntryConusmedRAO that consumes the given orderEntryRAO and adds the consumed entry to
the given actionRAO |
protected OrderEntryConsumedRAO |
consumeOrderEntry(OrderEntryRAO orderEntryRAO,
int quantity,
AbstractRuleActionRAO actionRAO)
Creates a new
OrderEntryConusmedRAO that consumes the given orderEntryRAO with the given quantity
and adds the consumed entry to the given actionRAO |
protected OrderEntryConsumedRAO |
consumeOrderEntry(OrderEntryRAO orderEntryRAO,
int quantity,
java.math.BigDecimal discountValue,
AbstractRuleActionRAO actionRAO) |
protected OrderEntryConsumedRAO |
createOrderEntryConsumedRAO(OrderEntryRAO orderEntryRAO,
int quantity,
java.math.BigDecimal discountValue)
Creates new OrderEntryConsumedRAO for given OrderEntryRAO and with given quantity.
|
protected java.util.Optional<java.math.BigDecimal> |
extractAmountForCurrency(RuleActionContext context,
java.lang.Object currencyAmount) |
protected <T> java.util.Optional<T> |
extractFact(RuleActionContext context,
java.util.function.Predicate<java.lang.Object> objectFilter)
Deprecated.
since 6.6. Non type-safe implementation
|
protected java.util.function.Predicate<RuleGroupExecutionRRD> |
filterByRuleGroup(RuleConfigurationRRD config) |
protected java.util.List<ActionSupplementStrategy> |
getActionSupplementStrategies() |
java.lang.String |
getBeanName() |
protected ConfigurationService |
getConfigurationService() |
protected int |
getConsumableQuantity(OrderEntryRAO orderEntryRao)
Calculate the order entry consumable quantity
|
protected int |
getConsumableQuantityStackable(OrderEntryRAO orderEntryRao)
Deprecated.
since 6.7
|
protected CurrencyUtils |
getCurrencyUtils() |
protected java.util.Map<java.lang.Integer,java.lang.Integer> |
getEligibleEntryQuantities(java.util.Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs) |
protected java.util.Map<OrderEntrySelectionStrategy,EntriesSelectionStrategy> |
getEntriesSelectionStrategies() |
protected java.util.Map<java.lang.String,java.lang.String> |
getMetaDataFromRule(RuleActionContext context) |
protected java.lang.String |
getMetaDataFromRule(RuleActionContext context,
java.lang.String key)
Returns the rule's meta-data for the given key (or
null). |
protected RaoUtils |
getRaoUtils() |
protected java.lang.String |
getRuleCode(RuleActionContext context)
Returns the rule's rule code meta data.
|
protected RuleConfigurationRRD |
getRuleConfigurationRRD(java.lang.String ruleCode,
RuleActionContext context)
retrieves the RuleConfigurationRRD for the given ruleCode from the given context.
|
protected java.util.function.Predicate<RuleConfigurationRRD> |
getRuleConfigurationRRDFilter(java.lang.String ruleCode) |
protected RuleEngineCalculationService |
getRuleEngineCalculationService() |
protected RuleGroupExecutionRRD |
getRuleGroupExecutionRRD(java.lang.String ruleGroupCode,
RuleActionContext context)
retrieves the RuleGroupExecutionRRD for the given ruleGroupCode from the given context.
|
protected java.util.function.Predicate<RuleGroupExecutionRRD> |
getRuleGroupExecutionRRDFilter(java.lang.String ruleGroupCode) |
protected 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.
|
protected 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 java.util.Set<OrderEntryRAO> |
getSelectedOrderEntryRaosStackable(java.util.Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs,
java.util.Map<java.lang.Integer,java.lang.Integer> selectedOrderEntryMap)
Deprecated.
since 6.7
|
protected boolean |
hasEnoughQuantity(RuleActionContext context,
java.util.Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs)
Checks if all
entriesSelectionStrategyRPDs have enough quantity. |
protected <T> java.util.Optional<T> |
lookupRAOByType(java.lang.Class<T> raoType,
RuleActionContext context,
java.util.function.Predicate<T>... raoFilters) |
protected <T> java.util.List<T> |
lookupRAOObjectsByType(java.lang.Class<T> raoType,
RuleActionContext context,
java.util.function.Predicate<T>... raoFilters) |
protected boolean |
mergeDiscounts(RuleActionContext context,
DiscountRAO discountRao,
OrderEntryRAO entry) |
protected void |
mergeOrderEntryConsumed(OrderEntryConsumedRAO consumedTarget,
OrderEntryConsumedRAO consumedSource)
Method merges the properties of two instances of
OrderEntryConsumedRAO if the objects refer to the same order entry
number and same rule |
void |
performAction(RuleActionContext context)
perform action on RAO objects
|
void |
performAction(RuleActionContext context,
java.util.Map<java.lang.String,java.lang.Object> parameters)
Deprecated.
since 6.6 Use the method w/o 'parameters' argument instead.
RuleActionContext should
encapsulate this information. |
protected boolean |
performActionInternal(RuleActionContext context)
template method called inside of
performAction(RuleActionContext, Map) |
protected void |
postProcessAction(AbstractRuleActionRAO actionRao,
RuleActionContext context) |
protected void |
putEligibleEntryQuantities(java.util.Map<java.lang.Integer,java.lang.Integer> entriesToBeConsumedMap,
EntriesSelectionStrategyRPD strategy) |
void |
setActionSupplementStrategies(java.util.List<ActionSupplementStrategy> actionSupplementStrategies) |
void |
setBeanName(java.lang.String beanName) |
void |
setConfigurationService(ConfigurationService configurationService) |
void |
setCurrencyUtils(CurrencyUtils currencyUtils) |
void |
setEntriesSelectionStrategies(java.util.Map<OrderEntrySelectionStrategy,EntriesSelectionStrategy> entriesSelectionStrategies) |
void |
setRAOMetaData(RuleActionContext context,
AbstractRuleActionRAO... raos) |
void |
setRaoUtils(RaoUtils raoUtils) |
void |
setRuleEngineCalculationService(RuleEngineCalculationService ruleEngineCalculationService) |
protected void |
splitEntriesSelectionStrategies(java.util.List<EntriesSelectionStrategyRPD> entriesSelectionStrategyRPDs,
java.util.List<EntriesSelectionStrategyRPD> selectionStrategyRPDsForAction,
java.util.List<EntriesSelectionStrategyRPD> selectionStrategyRPDsForTriggering) |
protected void |
trackActionExecution(RuleActionContext context) |
protected void |
trackConsumedProducts(RuleActionContext context) |
protected void |
trackRuleExecution(RuleActionContext context)
Deprecated.
since 18.08 no longer used
|
protected void |
trackRuleGroupCode(java.lang.String ruleGroupCode,
RuleActionContext context,
RuleConfigurationRRD config)
Deprecated.
since 18.08 no longer used
|
protected void |
trackRuleGroupExecution(RuleGroupExecutionRRD execution,
RuleConfigurationRRD config)
Deprecated.
since 18.08 no longer used
|
protected void |
trackRuleGroupExecutions(RuleActionContext context)
Deprecated.
since 18.08 no longer used
|
protected void |
updateActionRAOWithConsumed(AbstractRuleActionRAO actionRAO,
OrderEntryConsumedRAO orderEntryConsumedRAO)
Adds given OrderEntryConsumedRAO to the AbstractRuleActionRAO.consumedEntries.
|
protected void |
updateOrderConsumedQuantity(OrderConsumedRAO orderConsumedRAO,
RuleActionContext context)
Deprecated.
since 6.7
|
protected void |
validateCurrencyIsoCode(boolean absolute,
java.lang.String currencyIsoCode) |
protected void |
validateParameters(java.util.Map<java.lang.String,java.lang.Object> parameters) |
protected void |
validateRule(RuleActionContext context)
Validates that the required meta-data is available.
|
protected void |
validateSelectionStrategy(java.util.Collection<EntriesSelectionStrategyRPD> strategies,
RuleActionContext context)
Validates
entriesSelectionStrategyRPDs checking if the collection is not empty, if orderEntries list of
each entry of entriesSelectionStrategyRPDs is not empty and all the orderEntries are from the same Order. |
@Deprecated public void performAction(RuleActionContext context, java.util.Map<java.lang.String,java.lang.Object> parameters)
RuleActionContext should
encapsulate this information.RAOActionperformAction in interface RAOActioncontext - - instance of RuleActionContextparameters - - map of named objects, creating the execution context for an actionpublic void performAction(RuleActionContext context)
RAOActionperformAction in interface RAOActioncontext - - instance of RuleActionContextprotected void validateParameters(java.util.Map<java.lang.String,java.lang.Object> parameters)
protected boolean performActionInternal(RuleActionContext context)
performAction(RuleActionContext, Map)context - the contextprotected void postProcessAction(AbstractRuleActionRAO actionRao, RuleActionContext context)
protected void trackActionExecution(RuleActionContext context)
protected void trackConsumedProducts(RuleActionContext context)
@Deprecated protected void updateOrderConsumedQuantity(OrderConsumedRAO orderConsumedRAO, RuleActionContext context)
protected KnowledgeHelper checkAndGetRuleContext(RuleActionContext context)
ruleContext is of type KnowledgeHelper (i.e. drools-specific)context - the RuleActionContext instanceKnowledgeHelperprotected void validateRule(RuleActionContext context)
droolsruleengineservices.validate.droolsrule.rulecode to false.context - instance of RuleActionContextprotected java.lang.String getRuleCode(RuleActionContext context)
context - the contextprotected java.lang.String getMetaDataFromRule(RuleActionContext context, java.lang.String key)
null). Calls toString() on the meta-data
object.context - the RuleActionContext instancekey - the key of the meta-dataprotected boolean allowedByRuntimeConfiguration(RuleActionContext context)
RuleConfigurationRRDcontext - instance of RuleActionContextprotected java.util.function.Predicate<RuleGroupExecutionRRD> filterByRuleGroup(RuleConfigurationRRD config)
protected java.util.Map<java.lang.String,java.lang.String> getMetaDataFromRule(RuleActionContext context)
public void setRAOMetaData(RuleActionContext context, AbstractRuleActionRAO... raos)
protected void addMetadataToRao(AbstractRuleActionRAO rao, RuleActionContext context)
@Deprecated protected void trackRuleExecution(RuleActionContext context)
@Deprecated protected void trackRuleGroupExecutions(RuleActionContext context)
@Deprecated
protected void trackRuleGroupCode(java.lang.String ruleGroupCode,
RuleActionContext context,
RuleConfigurationRRD config)
@Deprecated protected void trackRuleGroupExecution(RuleGroupExecutionRRD execution, RuleConfigurationRRD config)
protected RuleGroupExecutionRRD getRuleGroupExecutionRRD(java.lang.String ruleGroupCode, RuleActionContext context)
ruleGroupCode - the rule group codecontext - the drools rule contextprotected java.util.function.Predicate<RuleGroupExecutionRRD> getRuleGroupExecutionRRDFilter(java.lang.String ruleGroupCode)
protected <T> java.util.Optional<T> lookupRAOByType(java.lang.Class<T> raoType,
RuleActionContext context,
java.util.function.Predicate<T>... raoFilters)
protected <T> java.util.List<T> lookupRAOObjectsByType(java.lang.Class<T> raoType,
RuleActionContext context,
java.util.function.Predicate<T>... raoFilters)
protected RuleConfigurationRRD getRuleConfigurationRRD(java.lang.String ruleCode, RuleActionContext context)
ruleCode - the rule codecontext - the drools rule contextprotected java.util.function.Predicate<RuleConfigurationRRD> getRuleConfigurationRRDFilter(java.lang.String ruleCode)
@Deprecated protected <T> java.util.Optional<T> extractFact(RuleActionContext context, java.util.function.Predicate<java.lang.Object> objectFilter)
protected OrderEntryConsumedRAO consumeOrderEntry(OrderEntryRAO orderEntryRAO, int quantity, java.math.BigDecimal discountValue, AbstractRuleActionRAO actionRAO)
orderEntryRAO - the order entry to consumeactionRAO - the action rao to add the consumed entry toquantity - the quantity to consumediscountValue - the discount this order entry consumption gaveprotected OrderEntryConsumedRAO consumeOrderEntry(OrderEntryRAO orderEntryRAO, AbstractRuleActionRAO actionRAO)
OrderEntryConusmedRAO that consumes the given orderEntryRAO and adds the consumed entry to
the given actionRAOorderEntryRAO - the order entry to consumeactionRAO - the action rao to add the consumed entry toprotected OrderEntryConsumedRAO consumeOrderEntry(OrderEntryRAO orderEntryRAO, int quantity, AbstractRuleActionRAO actionRAO)
OrderEntryConusmedRAO that consumes the given orderEntryRAO with the given quantity
and adds the consumed entry to the given actionRAOorderEntryRAO - the order entry to consumequantity - the quantity to consumeactionRAO - the action rao to add the consumed entry toprotected <T extends AbstractRuleActionRAO> void consumeOrderEntries(RuleActionContext context, java.util.Collection<EntriesSelectionStrategyRPD> strategies, T actionRAO)
OrderEntryConusmedRAOs for the given strategies, links them to the given actionRAO and
reduces available quantity of order entry by given quantity for every Order Entry from the set and using quantity
from discountedOrderEntryMap.context - instance of RuleActionContextstrategies - the selection strategiesactionRAO - the AbstractRuleActionRAO to add the newly created consumed entries toprotected java.util.Set<OrderEntryConsumedRAO> consumeOrderEntries(java.util.Set<OrderEntryRAO> selectedEntries, java.util.Map<java.lang.Integer,java.lang.Integer> selectedEntriesMap, AbstractRuleActionRAO actionRAO)
OrderEntryConusmedRAOs with the given quantity, links it to the given actionRAO and
reduces available quantity of order entry by given quantity for every Order Entry from the set and using quantity
from discountedOrderEntryMap.selectedEntries - Order Entries to be consumedselectedEntriesMap - Map having orderEntry.entryNumber as keys and Unit Quantity To Be Consumed as valuesactionRAO - the AbstractRuleActionRAO to add the newly created consumed entries toprotected java.util.Map<java.lang.Integer,java.lang.Integer> getSelectedOrderEntryQuantities(RuleActionContext context, java.util.Collection<EntriesSelectionStrategyRPD> strategies)
strategies - list of EntriesSelectionStrategyRPD to pickup units according to the strategiesprotected java.util.Set<OrderEntryRAO> getSelectedOrderEntryRaos(java.util.Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs, java.util.Map<java.lang.Integer,java.lang.Integer> selectedOrderEntryMap)
selectionStrategyRPDs - list of EntriesSelectionStrategyRPD to pickup units according to the strategiesselectedOrderEntryMap - Map having orderEntry.entryNumber as keys and Unit Quantity To Be Consumed as values@Deprecated protected java.util.Set<OrderEntryRAO> getSelectedOrderEntryRaosStackable(java.util.Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs, java.util.Map<java.lang.Integer,java.lang.Integer> selectedOrderEntryMap)
selectionStrategyRPDs - list of EntriesSelectionStrategyRPD to pickup units according to the strategiesselectedOrderEntryMap - Map having orderEntry.entryNumber as keys and Unit Quantity To Be Consumed as valuesprotected OrderEntryConsumedRAO createOrderEntryConsumedRAO(OrderEntryRAO orderEntryRAO, int quantity, java.math.BigDecimal discountValue)
orderEntryRAO - OrderEntryRAO to create consumed entry forquantity - Consumed quantitydiscountValue - the discount this order entry consumption gaveprotected void updateActionRAOWithConsumed(AbstractRuleActionRAO actionRAO, OrderEntryConsumedRAO orderEntryConsumedRAO)
actionRAO - AbstractRuleActionRAO to be updatedorderEntryConsumedRAO - to be added to the AbstractRuleActionRAOprotected void mergeOrderEntryConsumed(OrderEntryConsumedRAO consumedTarget, OrderEntryConsumedRAO consumedSource)
OrderEntryConsumedRAO if the objects refer to the same order entry
number and same ruleconsumedTarget - where to merge the data toconsumedSource - where to merge the data fromprotected java.math.BigDecimal adjustUnitPrice(OrderEntryRAO orderEntryRao)
protected java.math.BigDecimal adjustUnitPrice(OrderEntryRAO orderEntryRao, int quantity)
protected boolean hasEnoughQuantity(RuleActionContext context, java.util.Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs)
entriesSelectionStrategyRPDs have enough quantity.selectionStrategyRPDs - List of EntriesSelectionStrategyRPD to checkprotected java.util.Map<java.lang.Integer,java.lang.Integer> getEligibleEntryQuantities(java.util.Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs)
protected void putEligibleEntryQuantities(java.util.Map<java.lang.Integer,java.lang.Integer> entriesToBeConsumedMap,
EntriesSelectionStrategyRPD strategy)
protected int getConsumableQuantity(OrderEntryRAO orderEntryRao)
orderEntryRao - instance of OrderEntryRAO@Deprecated protected int getConsumableQuantityStackable(OrderEntryRAO orderEntryRao)
orderEntryRao - instance of OrderEntryRAOprotected int adjustStrategyQuantity(java.util.Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs, int maxCount)
selectionStrategyRPDs - list of EntriesSelectionStrategyRPD to be updatedmaxCount - when maxCount is greater than 0, this parameter acts as an absolute maximum for the multiple.protected void validateSelectionStrategy(java.util.Collection<EntriesSelectionStrategyRPD> strategies, RuleActionContext context)
entriesSelectionStrategyRPDs checking if the collection is not empty, if orderEntries list of
each entry of entriesSelectionStrategyRPDs is not empty and all the orderEntries are from the same Order.strategies - collection of EntriesSelectionStrategyRPD to check.context - the RuleActionContext instanceprotected void splitEntriesSelectionStrategies(java.util.List<EntriesSelectionStrategyRPD> entriesSelectionStrategyRPDs, java.util.List<EntriesSelectionStrategyRPD> selectionStrategyRPDsForAction, java.util.List<EntriesSelectionStrategyRPD> selectionStrategyRPDsForTriggering)
protected boolean mergeDiscounts(RuleActionContext context, DiscountRAO discountRao, OrderEntryRAO entry)
protected void validateCurrencyIsoCode(boolean absolute,
java.lang.String currencyIsoCode)
protected java.util.Optional<java.math.BigDecimal> extractAmountForCurrency(RuleActionContext context, java.lang.Object currencyAmount)
public java.lang.String getBeanName()
public void setBeanName(java.lang.String beanName)
public void setConfigurationService(ConfigurationService configurationService)
protected ConfigurationService getConfigurationService()
public void setRuleEngineCalculationService(RuleEngineCalculationService ruleEngineCalculationService)
protected RuleEngineCalculationService getRuleEngineCalculationService()
protected java.util.Map<OrderEntrySelectionStrategy,EntriesSelectionStrategy> getEntriesSelectionStrategies()
public void setEntriesSelectionStrategies(java.util.Map<OrderEntrySelectionStrategy,EntriesSelectionStrategy> entriesSelectionStrategies)
protected CurrencyUtils getCurrencyUtils()
public void setCurrencyUtils(CurrencyUtils currencyUtils)
protected java.util.List<ActionSupplementStrategy> getActionSupplementStrategies()
public void setActionSupplementStrategies(java.util.List<ActionSupplementStrategy> actionSupplementStrategies)
protected RaoUtils getRaoUtils()
public void setRaoUtils(RaoUtils raoUtils)
Copyright © 2018 SAP SE. All Rights Reserved.