0

I have a scenario in Drools. I have some set of rules. For Example :

In Rule 1: I am setting ProductName in the fact pojo that comes from session after some condition. In Rule 2: I am calculating grade value i.e. X1,X2,X3,X4. So for each grade I have single rule to calculate.

The Fact pojo that is coming from User may ask to calculate any grade value. However, say user asked for X4, then all the grade value from X1 to X3 should also be calculated.

What I did is that whenever any rule is executed; in then condition I am updating a fact that is holding a grade value property and in the last one single rule is written that will check for matching of the grade that is incoming from Pojo and executed rule grade.

However, it is not stopping on the particuler grade and executing all the grade value.

Please suggest some way.

========Edit=======

Rule Calculate X when seq == true then calculate X;

Rule Calculate x1 when seq == true then calculate X1; Rule Calculate x2 when seq == true then calculate X2;

Say if I asked to calculate X2, then rule x and x1 should also be calculated. If x1 then rule x and x1 should only execute.

Thanks Kumar Shorav

Kumar
  • 955
  • 5
  • 20
  • 50
  • This is somewhat unclear. First, you say "*all the grade value from X1 to X3 should also be calculated*". But then ("However,...") it seems that you want to stop after some rule executes. - Anyway, this cannot be resolved without some code showing what you have (then we see what happens) and a (somewhat clearer) description of what really should happen in the rules. – laune Oct 12 '14 at 08:27
  • @laune Please see the edit. Thanks Kumar Shorav – Kumar Oct 12 '14 at 10:56
  • Is it very expensive to calculate all in any case? It may be easier to do all calculations rather than implement some complex logic that excludes one or more rules depending on some input. – laune Oct 12 '14 at 15:33

0 Answers0