public class AbstractRuleExecutableSupport
extends java.lang.Object
| 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 KnowledgeHelper |
checkAndGetRuleContext(RuleActionContext context)
Checks that the given
ruleContext is of type KnowledgeHelper (i.e. |
protected <T> T |
checkArgumentAndGet(java.lang.String name,
java.lang.Class<T> type,
java.util.Map<java.lang.String,java.lang.Object> properties) |
protected java.util.Set<OrderEntryConsumedRAO> |
consumeOrderEntries(java.util.Collection<EntriesSelectionStrategyRPD> strategies,
AbstractRuleActionRAO 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,
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) |
protected java.util.List<ActionSupplementStrategy> |
getActionSupplementStrategies() |
java.lang.String |
getBeanName() |
protected ConfigurationService |
getConfigurationService() |
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 OrderUtils |
getOrderUtils() |
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 RuleCurrencyConverterStrategy |
getRuleCurrencyConverterStrategy()
Deprecated.
|
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.Map<java.lang.Integer,java.lang.Integer> |
getSelectedOrderEntryQuantities(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 boolean |
hasEnoughQuantity(EntriesSelectionStrategyRPD entriesSelectionStrategyRPD)
Checks in total quantity of all entries in the selection strategy is enough for the quantity to consume.
|
protected boolean |
hasEnoughQuantity(java.util.List<EntriesSelectionStrategyRPD> entriesSelectionStrategyRPDs)
Checks if all
entriesSelectionStrategyRPDs have enough quantity. |
protected boolean |
mergeDiscounts(RuleActionContext context,
DiscountRAO discountRao,
OrderEntryRAO entry) |
protected void |
postProcessAction(AbstractRuleActionRAO actionRao,
RuleActionContext context,
java.util.Map<java.lang.String,java.lang.Object> parameters) |
void |
setActionSupplementStrategies(java.util.List<ActionSupplementStrategy> actionSupplementStrategies) |
void |
setBeanName(java.lang.String beanName) |
void |
setConfigurationService(ConfigurationService configurationService) |
void |
setEntriesSelectionStrategies(java.util.Map<OrderEntrySelectionStrategy,EntriesSelectionStrategy> entriesSelectionStrategies) |
void |
setOrderUtils(OrderUtils orderUtils) |
void |
setRAOMetaData(RuleActionContext context,
AbstractRuleActionRAO... raos) |
void |
setRaoUtils(RaoUtils raoUtils) |
void |
setRuleCurrencyConverterStrategy(RuleCurrencyConverterStrategy ruleCurrencyConverterStrategy)
Deprecated.
|
void |
setRuleEngineCalculationService(RuleEngineCalculationService ruleEngineCalculationService) |
protected void |
splitEntriesSelectionStrategies(java.util.List<EntriesSelectionStrategyRPD> entriesSelectionStrategyRPDs,
java.util.List<EntriesSelectionStrategyRPD> selectionStrategyRPDsForAction,
java.util.List<EntriesSelectionStrategyRPD> selectionStrategyRPDsForTriggering) |
protected void |
trackRuleExecution(RuleActionContext context)
Tracks this rule's execution by incrementing the
RuleConfigurationRRD.getCurrentRuns() for the currently
executing rule. |
protected void |
trackRuleGroupCode(java.lang.String ruleGroupCode,
RuleActionContext context,
RuleConfigurationRRD config) |
protected void |
trackRuleGroupExecution(RuleGroupExecutionRRD execution,
RuleConfigurationRRD config)
Updates the given
RuleGroupExecutionRRD by adding the config.getRuleCode() to the
execution.getExecutedRules(). |
protected void |
trackRuleGroupExecutions(RuleActionContext context)
Adds this rule's execution to all RuleGroupExecutionRRD for each of this rule's defined ruleGroups.
|
protected void |
updateActionRAOWithConsumed(AbstractRuleActionRAO actionRAO,
OrderEntryConsumedRAO orderEntryConsumedRAO)
Adds given OrderEntryConsumedRAO to the AbstractRuleActionRAO.consumedEntries.
|
protected void |
validateCurrencyIsoCode(boolean absolute,
java.lang.String currencyIsoCode) |
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. |
protected void postProcessAction(AbstractRuleActionRAO actionRao, RuleActionContext context, java.util.Map<java.lang.String,java.lang.Object> parameters)
protected KnowledgeHelper checkAndGetRuleContext(RuleActionContext context)
ruleContext is of type KnowledgeHelper (i.e. drools-specific)context - the RuleActionContext instanceKnowledgeHelperprotected <T> T checkArgumentAndGet(java.lang.String name,
java.lang.Class<T> type,
java.util.Map<java.lang.String,java.lang.Object> properties)
protected void validateRule(RuleActionContext context)
droolsruleengineservices.validate.droolsrule.rulecode to false.context - protected 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 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)
protected void trackRuleExecution(RuleActionContext context)
RuleConfigurationRRD.getCurrentRuns() for the currently
executing rule.context - the drools specific contextprotected void trackRuleGroupExecutions(RuleActionContext context)
context - the drools specific rule contextprotected void trackRuleGroupCode(java.lang.String ruleGroupCode,
RuleActionContext context,
RuleConfigurationRRD config)
protected void trackRuleGroupExecution(RuleGroupExecutionRRD execution, RuleConfigurationRRD config)
RuleGroupExecutionRRD by adding the config.getRuleCode() to the
execution.getExecutedRules().protected RuleGroupExecutionRRD getRuleGroupExecutionRRD(java.lang.String ruleGroupCode, RuleActionContext context)
ruleGroupCode - the rule group codecontext - the drools rule contextprotected RuleConfigurationRRD getRuleConfigurationRRD(java.lang.String ruleCode, RuleActionContext context)
ruleCode - the rule codecontext - the drools rule contextprotected <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 java.util.Set<OrderEntryConsumedRAO> consumeOrderEntries(java.util.Collection<EntriesSelectionStrategyRPD> strategies, AbstractRuleActionRAO 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.strategies - the selection strategiesactionRAO - the actionRAO 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 actionRAO to add the newly created consumed entries toprotected java.util.Map<java.lang.Integer,java.lang.Integer> getSelectedOrderEntryQuantities(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 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 java.math.BigDecimal adjustUnitPrice(OrderEntryRAO orderEntryRao)
protected java.math.BigDecimal adjustUnitPrice(OrderEntryRAO orderEntryRao, int quantity)
protected boolean hasEnoughQuantity(java.util.List<EntriesSelectionStrategyRPD> entriesSelectionStrategyRPDs)
entriesSelectionStrategyRPDs have enough quantity.entriesSelectionStrategyRPDs - List of EntriesSelectionStrategyRPD to checkprotected boolean hasEnoughQuantity(EntriesSelectionStrategyRPD entriesSelectionStrategyRPD)
entriesSelectionStrategyRPD - EntriesSelectionStrategyRPD to check the quantity forprotected 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)
@Deprecated protected RuleCurrencyConverterStrategy getRuleCurrencyConverterStrategy()
@Deprecated public void setRuleCurrencyConverterStrategy(RuleCurrencyConverterStrategy ruleCurrencyConverterStrategy)
protected OrderUtils getOrderUtils()
public void setOrderUtils(OrderUtils orderUtils)
protected java.util.List<ActionSupplementStrategy> getActionSupplementStrategies()
public void setActionSupplementStrategies(java.util.List<ActionSupplementStrategy> actionSupplementStrategies)
protected RaoUtils getRaoUtils()
public void setRaoUtils(RaoUtils raoUtils)
Copyright © 2017 SAP SE. All Rights Reserved.