cancel
Showing results for 
Search instead for 
Did you mean: 

Rearrange entrynumbers in RAOACtion

Former Member
0 Kudos

Dear,

I have a custom requirement for a promotion to include an order entry next to the entry triggering the promotion. So as an example, the cart has entries A, B, C and the promotion needs to add N next to A, resulting in: A, N, B, C. But it does not seem to work. I base myself on the RuleFreeGiftRAOAction, with as a difference the following extra logic at the end of the RuleEngineCalculationService::addFreeProductsToCart method:

 enter code here// apply sorting if required
 if (entryNumber >= 0) {
     // update all entries following the original one
     cartRao.getEntries().forEach(entry -> {
         if (entry.getEntryNumber() >= entryNumber) {
             entry.setEntryNumber(entry.getEntryNumber() + 1);
         }
     });
 
     // update the current one
     addedOrderEntry.setEntryNumber(entryNumber);
 }

(in which the entryNumber the number is of the line newly included in the cart rao) But the result is an exception (see end of the post). Is rearranging the entries possible at the RAOAction level? What extra actions should be done to make it work (I tried including the modified entry RAO's in the context.updateFacts, but didn't work either).

Thanks!

Exception:

 enter code herjava.lang.RuntimeException: java.lang.NullPointerException
     at org.drools.core.rule.MultiAccumulate.reverse(MultiAccumulate.java:135) ~[drools-core-6.3.0.Final.jar:6.3.0.Final]
     at org.drools.core.phreak.PhreakAccumulateNode.removeMatch(PhreakAccumulateNode.java:805) ~[drools-core-6.3.0.Final.jar:6.3.0.Final]
     at org.drools.core.phreak.PhreakAccumulateNode.doRightDeletes(PhreakAccumulateNode.java:634) ~[drools-core-6.3.0.Final.jar:6.3.0.Final]
     at org.drools.core.phreak.PhreakAccumulateNode.doNode(PhreakAccumulateNode.java:69) ~[drools-core-6.3.0.Final.jar:6.3.0.Final]
     at org.drools.core.phreak.RuleNetworkEvaluator.switchOnDoBetaNode(RuleNetworkEvaluator.java:565) ~[drools-core-6.3.0.Final.jar:6.3.0.Final]
     at org.drools.core.phreak.RuleNetworkEvaluator.evalBetaNode(RuleNetworkEvaluator.java:536) ~[drools-core-6.3.0.Final.jar:6.3.0.Final]
     at org.drools.core.phreak.RuleNetworkEvaluator.evalNode(RuleNetworkEvaluator.java:372) ~[drools-core-6.3.0.Final.jar:6.3.0.Final]
     at org.drools.core.phreak.RuleNetworkEvaluator.innerEval(RuleNetworkEvaluator.java:332) ~[drools-core-6.3.0.Final.jar:6.3.0.Final]
     at org.drools.core.phreak.RuleNetworkEvaluator.evalStackEntry(RuleNetworkEvaluator.java:228) ~[drools-core-6.3.0.Final.jar:6.3.0.Final]
     at org.drools.core.phreak.RuleNetworkEvaluator.outerEval(RuleNetworkEvaluator.java:171) ~[drools-core-6.3.0.Final.jar:6.3.0.Final]
     at org.drools.core.phreak.RuleNetworkEvaluator.evaluateNetwork(RuleNetworkEvaluator.java:123) ~[drools-core-6.3.0.Final.jar:6.3.0.Final]
     at org.drools.core.phreak.RuleExecutor.reEvaluateNetwork(RuleExecutor.java:194) ~[drools-core-6.3.0.Final.jar:6.3.0.Final]
     at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:73) ~[drools-core-6.3.0.Final.jar:6.3.0.Final]
     at org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:978) ~[drools-core-6.3.0.Final.jar:6.3.0.Final]
     at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1292) ~[drools-core-6.3.0.Final.jar:6.3.0.Final]
     at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1294) ~[drools-core-6.3.0.Final.jar:6.3.0.Final]
     at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1281) ~[drools-core-6.3.0.Final.jar:6.3.0.Final]
     at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1270) ~[drools-core-6.3.0.Final.jar:6.3.0.Final]
     at org.drools.core.command.runtime.rule.FireAllRulesCommand.execute(FireAllRulesCommand.java:107) ~[drools-core-6.3.0.Final.jar:6.3.0.Final]
     at org.drools.core.command.runtime.rule.FireAllRulesCommand.execute(FireAllRulesCommand.java:34) ~[drools-core-6.3.0.Final.jar:6.3.0.Final]
     at org.drools.core.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:153) ~[drools-core-6.3.0.Final.jar:6.3.0.Final]
     at org.drools.core.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:69) ~[drools-core-6.3.0.Final.jar:6.3.0.Final]
     at org.drools.core.impl.StatelessKnowledgeSessionImpl.execute(StatelessKnowledgeSessionImpl.java:292) ~[drools-core-6.3.0.Final.jar:6.3.0.Final]
     at de.hybris.platform.ruleengine.impl.DefaultPlatformRuleEngineService.tryExecution(DefaultPlatformRuleEngineService.java:273) ~[ruleengineserver.jar:?]
 e

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Try the bundle promotion .