public class AbstractRuleExecutableSupport extends Object
| Constructor and Description |
|---|
AbstractRuleExecutableSupport() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addMetadataToRao(AbstractRuleActionRAO rao,
RuleActionContext context) |
protected int |
adjustStrategyQuantity(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 BigDecimal |
adjustUnitPrice(OrderEntryRAO orderEntryRao) |
protected 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(String name,
Class<T> type,
Map<String,Object> properties) |
protected Set<OrderEntryConsumedRAO> |
consumeOrderEntries(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 Set<OrderEntryConsumedRAO> |
consumeOrderEntries(Set<OrderEntryRAO> selectedEntries,
Map<Integer,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,
BigDecimal discountValue,
AbstractRuleActionRAO actionRAO) |
protected OrderEntryConsumedRAO |
createOrderEntryConsumedRAO(OrderEntryRAO orderEntryRAO,
int quantity,
BigDecimal discountValue)
Creates new OrderEntryConsumedRAO for given OrderEntryRAO and with given quantity.
|
protected Optional<BigDecimal> |
extractAmountForCurrency(RuleActionContext context,
Object currencyAmount) |
protected <T> Optional<T> |
extractFact(RuleActionContext context,
Predicate<Object> objectFilter) |
protected List<ActionSupplementStrategy> |
getActionSupplementStrategies() |
String |
getBeanName() |
protected ConfigurationService |
getConfigurationService() |
protected Map<OrderEntrySelectionStrategy,EntriesSelectionStrategy> |
getEntriesSelectionStrategies() |
protected Map<String,String> |
getMetaDataFromRule(RuleActionContext context) |
protected String |
getMetaDataFromRule(RuleActionContext context,
String key)
Returns the rule's meta-data for the given key (or
null). |
protected OrderUtils |
getOrderUtils() |
protected RaoUtils |
getRaoUtils() |
protected String |
getRuleCode(RuleActionContext context)
Returns the rule's rule code meta data.
|
protected RuleConfigurationRRD |
getRuleConfigurationRRD(String ruleCode,
RuleActionContext context)
retrieves the RuleConfigurationRRD for the given ruleCode from the given context.
|
protected RuleCurrencyConverterStrategy |
getRuleCurrencyConverterStrategy() |
protected RuleEngineCalculationService |
getRuleEngineCalculationService() |
protected RuleGroupExecutionRRD |
getRuleGroupExecutionRRD(String ruleGroupCode,
RuleActionContext context)
retrieves the RuleGroupExecutionRRD for the given ruleGroupCode from the given context.
|
protected Map<Integer,Integer> |
getSelectedOrderEntryQuantities(Collection<EntriesSelectionStrategyRPD> strategies)
Gets Order Entry identifiers (orderEntry.entryNumber) and Unit Quantity To Be Consumed for the Order Entries.
|
protected Set<OrderEntryRAO> |
getSelectedOrderEntryRaos(Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs,
Map<Integer,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(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,
Map<String,Object> parameters) |
void |
setActionSupplementStrategies(List<ActionSupplementStrategy> actionSupplementStrategies) |
void |
setBeanName(String beanName) |
void |
setConfigurationService(ConfigurationService configurationService) |
void |
setEntriesSelectionStrategies(Map<OrderEntrySelectionStrategy,EntriesSelectionStrategy> entriesSelectionStrategies) |
void |
setOrderUtils(OrderUtils orderUtils) |
void |
setRAOMetaData(RuleActionContext context,
AbstractRuleActionRAO... raos) |
void |
setRaoUtils(RaoUtils raoUtils) |
void |
setRuleCurrencyConverterStrategy(RuleCurrencyConverterStrategy ruleCurrencyConverterStrategy) |
void |
setRuleEngineCalculationService(RuleEngineCalculationService ruleEngineCalculationService) |
protected void |
splitEntriesSelectionStrategies(List<EntriesSelectionStrategyRPD> entriesSelectionStrategyRPDs,
List<EntriesSelectionStrategyRPD> selectionStrategyRPDsForAction,
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 |
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,
String currencyIsoCode) |
protected void |
validateRule(RuleActionContext context)
Validates that the required meta-data is available.
|
protected void |
validateSelectionStrategy(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, Map<String,Object> parameters)
protected KnowledgeHelper checkAndGetRuleContext(RuleActionContext context)
ruleContext is of type KnowledgeHelper (i.e. drools-specific)context - the RuleActionContext instanceKnowledgeHelperprotected <T> T checkArgumentAndGet(String name, Class<T> type, Map<String,Object> properties)
protected void validateRule(RuleActionContext context)
droolsruleengineservices.validate.droolsrule.rulecode to false.context - protected String getRuleCode(RuleActionContext context)
context - the contextprotected String getMetaDataFromRule(RuleActionContext context, String key)
null). Calls toString() on the meta-data
object.context - the RuleActionContext instancekey - the key of the meta-dataprotected Map<String,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 trackRuleGroupExecution(RuleGroupExecutionRRD execution, RuleConfigurationRRD config)
RuleGroupExecutionRRD by adding the config.getRuleCode() to the
execution.getExecutedRules().protected RuleGroupExecutionRRD getRuleGroupExecutionRRD(String ruleGroupCode, RuleActionContext context)
ruleGroupCode - the rule group codecontext - the drools rule contextprotected RuleConfigurationRRD getRuleConfigurationRRD(String ruleCode, RuleActionContext context)
ruleCode - the rule codecontext - the drools rule contextprotected <T> Optional<T> extractFact(RuleActionContext context, Predicate<Object> objectFilter)
protected OrderEntryConsumedRAO consumeOrderEntry(OrderEntryRAO orderEntryRAO, int quantity, 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 Set<OrderEntryConsumedRAO> consumeOrderEntries(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 Set<OrderEntryConsumedRAO> consumeOrderEntries(Set<OrderEntryRAO> selectedEntries, Map<Integer,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 Map<Integer,Integer> getSelectedOrderEntryQuantities(Collection<EntriesSelectionStrategyRPD> strategies)
strategies - list of EntriesSelectionStrategyRPD to pickup units according to the strategiesprotected Set<OrderEntryRAO> getSelectedOrderEntryRaos(Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs, Map<Integer,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, 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 BigDecimal adjustUnitPrice(OrderEntryRAO orderEntryRao)
protected BigDecimal adjustUnitPrice(OrderEntryRAO orderEntryRao, int quantity)
protected boolean hasEnoughQuantity(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(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(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(List<EntriesSelectionStrategyRPD> entriesSelectionStrategyRPDs, List<EntriesSelectionStrategyRPD> selectionStrategyRPDsForAction, List<EntriesSelectionStrategyRPD> selectionStrategyRPDsForTriggering)
protected boolean mergeDiscounts(RuleActionContext context, DiscountRAO discountRao, OrderEntryRAO entry)
protected void validateCurrencyIsoCode(boolean absolute,
String currencyIsoCode)
protected Optional<BigDecimal> extractAmountForCurrency(RuleActionContext context, Object currencyAmount)
public String getBeanName()
public void setBeanName(String beanName)
public void setConfigurationService(ConfigurationService configurationService)
protected ConfigurationService getConfigurationService()
public void setRuleEngineCalculationService(RuleEngineCalculationService ruleEngineCalculationService)
protected RuleEngineCalculationService getRuleEngineCalculationService()
protected Map<OrderEntrySelectionStrategy,EntriesSelectionStrategy> getEntriesSelectionStrategies()
public void setEntriesSelectionStrategies(Map<OrderEntrySelectionStrategy,EntriesSelectionStrategy> entriesSelectionStrategies)
protected RuleCurrencyConverterStrategy getRuleCurrencyConverterStrategy()
public void setRuleCurrencyConverterStrategy(RuleCurrencyConverterStrategy ruleCurrencyConverterStrategy)
protected OrderUtils getOrderUtils()
public void setOrderUtils(OrderUtils orderUtils)
protected List<ActionSupplementStrategy> getActionSupplementStrategies()
public void setActionSupplementStrategies(List<ActionSupplementStrategy> actionSupplementStrategies)
protected RaoUtils getRaoUtils()
public void setRaoUtils(RaoUtils raoUtils)
Copyright © 2017 SAP SE. All Rights Reserved.