Class AbstractRuleExecutableSupport

    • Constructor Detail

      • AbstractRuleExecutableSupport

        public AbstractRuleExecutableSupport()
    • Method Detail

      • performAction

        public void performAction​(RuleActionContext context)
        Description copied from interface: RAOAction
        perform action on RAO objects
        Specified by:
        performAction in interface RAOAction
        Parameters:
        context - - instance of RuleActionContext
      • validateParameters

        protected void validateParameters​(java.util.Map<java.lang.String,​java.lang.Object> parameters)
      • performActionInternal

        protected boolean performActionInternal​(RuleActionContext context)
        template method called inside of performAction(RuleActionContext)
        Parameters:
        context - the context
        Returns:
        true if the action was performed successfully, otherwise false
      • trackActionExecution

        protected void trackActionExecution​(RuleActionContext context)
      • checkAndGetRuleContext

        protected org.drools.core.spi.KnowledgeHelper checkAndGetRuleContext​(RuleActionContext context)
        Checks that the given ruleContext is of type KnowledgeHelper (i.e. drools-specific)
        Parameters:
        context - the RuleActionContext instance
        Returns:
        the KnowledgeHelper
      • validateRule

        protected void validateRule​(RuleActionContext context)
        Validates that the required meta-data is available. Validation can be disabled by setting the property droolsruleengineservices.validate.droolsrule.rulecode to false.
        Parameters:
        context - instance of RuleActionContext
      • getRuleCode

        protected java.lang.String getRuleCode​(RuleActionContext context)
        Returns the rule's rule code meta data.
        Parameters:
        context - the context
        Returns:
        the rule's rule code (or null, if none is found)
      • getMetaDataFromRule

        protected java.lang.String getMetaDataFromRule​(RuleActionContext context,
                                                       java.lang.String key)
        Returns the rule's meta-data for the given key (or null). Calls toString() on the meta-data object.
        Parameters:
        context - the RuleActionContext instance
        key - the key of the meta-data
        Returns:
        the string representation of the meta-data (or null)
      • allowedByRuntimeConfiguration

        protected boolean allowedByRuntimeConfiguration​(RuleActionContext context)
        query method to allow for rule execution by RuleConfigurationRRD
        Parameters:
        context - instance of RuleActionContext
        Returns:
        true if the execution is allowed
      • getMetaDataFromRule

        protected java.util.Map<java.lang.String,​java.lang.String> getMetaDataFromRule​(RuleActionContext context)
      • trackRuleExecution

        @Deprecated(since="1808",
                    forRemoval=true)
        protected void trackRuleExecution​(RuleActionContext context)
        Deprecated, for removal: This API element is subject to removal in a future version.
        since 18.08 no longer used
      • trackRuleGroupExecutions

        @Deprecated(since="1808",
                    forRemoval=true)
        protected void trackRuleGroupExecutions​(RuleActionContext context)
        Deprecated, for removal: This API element is subject to removal in a future version.
        since 18.08 no longer used
      • trackRuleGroupCode

        @Deprecated(since="1808",
                    forRemoval=true)
        protected void trackRuleGroupCode​(java.lang.String ruleGroupCode,
                                          RuleActionContext context,
                                          RuleConfigurationRRD config)
        Deprecated, for removal: This API element is subject to removal in a future version.
        since 18.08 no longer used
      • trackRuleGroupExecution

        @Deprecated(since="1808",
                    forRemoval=true)
        protected void trackRuleGroupExecution​(RuleGroupExecutionRRD execution,
                                               RuleConfigurationRRD config)
        Deprecated, for removal: This API element is subject to removal in a future version.
        since 18.08 no longer used
      • getRuleGroupExecutionRRD

        protected RuleGroupExecutionRRD getRuleGroupExecutionRRD​(java.lang.String ruleGroupCode,
                                                                 RuleActionContext context)
        retrieves the RuleGroupExecutionRRD for the given ruleGroupCode from the given context.
        Parameters:
        ruleGroupCode - the rule group code
        context - the drools rule context
        Returns:
        the matching RuleGroupExecutionRRD or null if none can be found
      • getRuleGroupExecutionRRDFilter

        protected java.util.function.Predicate<RuleGroupExecutionRRD> getRuleGroupExecutionRRDFilter​(java.lang.String ruleGroupCode)
      • getRuleConfigurationRRD

        protected RuleConfigurationRRD getRuleConfigurationRRD​(java.lang.String ruleCode,
                                                               RuleActionContext context)
        retrieves the RuleConfigurationRRD for the given ruleCode from the given context.
        Parameters:
        ruleCode - the rule code
        context - the drools rule context
        Returns:
        the RuleConfigurationRRD or null if none (or more than one) are found
      • getRuleConfigurationRRDFilter

        protected java.util.function.Predicate<RuleConfigurationRRD> getRuleConfigurationRRDFilter​(java.lang.String ruleCode)
      • skipErrorLogging

        @Deprecated(since="1905",
                    forRemoval=true)
        protected <T> boolean skipErrorLogging​(java.lang.Class<T> raoType)
        Deprecated, for removal: This API element is subject to removal in a future version.
        since 1905
      • consumeOrderEntry

        @Deprecated(since="1905",
                    forRemoval=true)
        protected OrderEntryConsumedRAO consumeOrderEntry​(OrderEntryRAO orderEntryRAO,
                                                          int quantity,
                                                          AbstractRuleActionRAO actionRAO)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Creates a new OrderEntryConusmedRAO that consumes the given orderEntryRAO with the given quantity and adds the consumed entry to the given actionRAO
        Parameters:
        orderEntryRAO - the order entry to consume
        quantity - the quantity to consume
        actionRAO - the action rao to add the consumed entry to
        Returns:
        the newly created consumed entry
      • consumeOrderEntries

        @Deprecated(since="1905",
                    forRemoval=true)
        protected java.util.Set<OrderEntryConsumedRAO> consumeOrderEntries​(java.util.Set<OrderEntryRAO> selectedEntries,
                                                                           java.util.Map<java.lang.Integer,​java.lang.Integer> selectedEntriesMap,
                                                                           AbstractRuleActionRAO actionRAO)
        Deprecated, for removal: This API element is subject to removal in a future version.
        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.
        Parameters:
        selectedEntries - Order Entries to be consumed
        selectedEntriesMap - Map having orderEntry.entryNumber as keys and Unit Quantity To Be Consumed as values
        actionRAO - the AbstractRuleActionRAO to add the newly created consumed entries to
      • getSelectedOrderEntryRaos

        @Deprecated(since="1905",
                    forRemoval=true)
        protected java.util.Set<OrderEntryRAO> getSelectedOrderEntryRaos​(java.util.Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs,
                                                                         java.util.Map<java.lang.Integer,​java.lang.Integer> selectedOrderEntryMap)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Gets Order Entry set to be discounted as a result of bundle processing.
        Parameters:
        selectionStrategyRPDs - list of EntriesSelectionStrategyRPD to pickup units according to the strategies
        selectedOrderEntryMap - Map having orderEntry.entryNumber as keys and Unit Quantity To Be Consumed as values
      • createOrderEntryConsumedRAO

        @Deprecated(since="1905",
                    forRemoval=true)
        protected OrderEntryConsumedRAO createOrderEntryConsumedRAO​(OrderEntryRAO orderEntryRAO,
                                                                    int quantity,
                                                                    java.math.BigDecimal discountValue)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Creates new OrderEntryConsumedRAO for given OrderEntryRAO and with given quantity.
        Parameters:
        orderEntryRAO - OrderEntryRAO to create consumed entry for
        quantity - Consumed quantity
        discountValue - the discount this order entry consumption gave
        Returns:
        created OrderEntryConsumedRAO
      • adjustUnitPrice

        @Deprecated(since="1905",
                    forRemoval=true)
        protected java.math.BigDecimal adjustUnitPrice​(OrderEntryRAO orderEntryRao)
        Deprecated, for removal: This API element is subject to removal in a future version.
        since 1905
      • adjustUnitPrice

        @Deprecated(since="1905",
                    forRemoval=true)
        protected java.math.BigDecimal adjustUnitPrice​(OrderEntryRAO orderEntryRao,
                                                       int quantity)
        Deprecated, for removal: This API element is subject to removal in a future version.
      • hasEnoughQuantity

        @Deprecated(since="1905",
                    forRemoval=true)
        protected boolean hasEnoughQuantity​(RuleActionContext context,
                                            java.util.Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Checks if all entriesSelectionStrategyRPDs have enough quantity.
        Parameters:
        selectionStrategyRPDs - List of EntriesSelectionStrategyRPD to check
        Returns:
        true if all entries selection strategies have enough quantity. false if at least one doesn't have.
      • getConsumableQuantity

        @Deprecated(since="1905",
                    forRemoval=true)
        protected int getConsumableQuantity​(OrderEntryRAO orderEntryRao)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Calculate the order entry consumable quantity
        Parameters:
        orderEntryRao - instance of OrderEntryRAO
        Returns:
        number of units available for consumption
      • adjustStrategyQuantity

        @Deprecated(since="1905",
                    forRemoval=true)
        protected int adjustStrategyQuantity​(java.util.Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs,
                                             int maxCount)
        Deprecated, for removal: This API element is subject to removal in a future version.
        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.
        Parameters:
        selectionStrategyRPDs - list of EntriesSelectionStrategyRPD to be updated
        maxCount - 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
      • validateSelectionStrategy

        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.
        Parameters:
        strategies - collection of EntriesSelectionStrategyRPD to check.
        context - the RuleActionContext instance
      • validateCurrencyIsoCode

        protected void validateCurrencyIsoCode​(boolean absolute,
                                               java.lang.String currencyIsoCode)
      • extractAmountForCurrency

        protected java.util.Optional<java.math.BigDecimal> extractAmountForCurrency​(RuleActionContext context,
                                                                                    java.lang.Object currencyAmount)
      • getBeanName

        public java.lang.String getBeanName()
      • setBeanName

        public void setBeanName​(java.lang.String beanName)
        Specified by:
        setBeanName in interface org.springframework.beans.factory.BeanNameAware
      • setConfigurationService

        public void setConfigurationService​(ConfigurationService configurationService)
      • setRuleEngineCalculationService

        public void setRuleEngineCalculationService​(RuleEngineCalculationService ruleEngineCalculationService)
      • setCurrencyUtils

        public void setCurrencyUtils​(CurrencyUtils currencyUtils)
      • setActionSupplementStrategies

        public void setActionSupplementStrategies​(java.util.List<ActionSupplementStrategy> actionSupplementStrategies)
      • getRaoUtils

        protected RaoUtils getRaoUtils()
      • setRaoUtils

        public void setRaoUtils​(RaoUtils raoUtils)
      • setConsumptionSupport

        public void setConsumptionSupport​(RAOConsumptionSupport consumptionSupport)
      • setRaoLookupService

        public void setRaoLookupService​(RAOLookupService raoLookupService)
      • isConsumptionEnabled

        @Deprecated(since="1905",
                    forRemoval=true)
        protected boolean isConsumptionEnabled()
        Deprecated, for removal: This API element is subject to removal in a future version.
      • setConsumptionEnabled

        @Deprecated(since="1905",
                    forRemoval=true)
        public void setConsumptionEnabled​(boolean consumptionEnabled)
        Deprecated, for removal: This API element is subject to removal in a future version.
        since 1905
      • getEntriesSelectionStrategies

        @Deprecated(since="1905",
                    forRemoval=true)
        protected java.util.Map<OrderEntrySelectionStrategy,​EntriesSelectionStrategy> getEntriesSelectionStrategies()
        Deprecated, for removal: This API element is subject to removal in a future version.
        since 1905
      • setEntriesSelectionStrategies

        @Deprecated(since="1905",
                    forRemoval=true)
        public void setEntriesSelectionStrategies​(java.util.Map<OrderEntrySelectionStrategy,​EntriesSelectionStrategy> entriesSelectionStrategies)
        Deprecated, for removal: This API element is subject to removal in a future version.
        since 1905