Try using dynamic salience, it allows you to specify an MVEL expression
that returns an integer value for the salience. The expression can use
any bound declaration at the point of activation.
Mark
On 11/03/2010 17:47, Gaurav wrote:
Hi All,
I have aother question on drools.
There can le level1 to level6 present in a rule and we need to pick always
the highest level rule which satisfied list price and discount comdition.
Following code is giving me expected results but do we have any better way
to implement the same. Can I avoid last 2 iternations and combine it to
first one iteration.
RoutingRule.java
----------------
private String level1 = "";
private String level2 = "";
private String level3 = "";
private String level4 = "";
private String level5 = "";
private String level6 = "";
private String serviceSalesPath = "";
private String productSalesPath = "";
private String nonStdTerm = "";
private String currency = "";
private double listPriceFrom = Double.MAX_VALUE ;
private double listPriceTo = Double.MAX_VALUE ;
private double discountPriceFrom = 100;
private double discountPriceTo = 100 ;
private double nodeOfRule =0;
Rule
-----
$selectedTSSRulesWithOutHier : ArrayList()
from collect ($routingRule : RoutingRule(currency == $curr
&& (
listPriceFrom<= $tssListPrice&& listPriceTo> $tssListPrice
&& discountPriceFrom<= $tssDisc&& discountPriceTo>
$tssDisc&&
nonStdTerm =="TSS" )
)
from $tssRoutingRuleList)
$lowestNodeTSS : Double(intValue> 0)
from accumulate ( RoutingRule($nodeOfRule : nodeOfRule)
from $selectedTSSRulesWithOutHier, max($nodeOfRule))
$lowestNodeTSSRule : ArrayList()
from collect( $ruleObj : RoutingRule( eval(nodeOfRule == $lowestNodeTSS) )
from $selectedTSSRulesWithOutHier )
Many thanks in advance,
Gaurav