Hi Guarav,<br><br>I might not be understanding your problem, but think you might be making the problem more complicated than it needs to be. Could you try something like the following:<br><br>$ruleToChoose : RoutingRule (listPriceFrom <= $tssListPrice, listPriceTo > $tssListPrice<br>
&& discountPriceFrom <= $tssDisc, discountPriceTo > $tssDisc,<br> nonStdTerm =="TSS", $nodeOfRule : nodeOfRule) from $tssRoutingRuleList<br>
<br>not RoutingRule (listPriceFrom <= $tssListPrice, listPriceTo
> $tssListPrice<br>
, discountPriceFrom <=
$tssDisc, discountPriceTo > $tssDisc,<br>
nonStdTerm =="TSS", nodeOfRule > $nodeOfRule) from
$tssRoutingRuleList<br><br>Note that this logic states:<br> Assign to $ruleToChoose a RoutingRule that satisfies our conditions when there is no other RoutingRule that also satisfies our conditions but has a higher nodeOfRule value.<br>
<br>Also note that I removed you "&&" operators and replaced them with "," (comma).<br><br>Let me know if I have misunderstood your problem.<br><br>Hope it helps!<br><br>Enda<br><br><div class="gmail_quote">
On Thu, Mar 11, 2010 at 5:47 PM, Gaurav <span dir="ltr"><<a href="mailto:gaurav.goyal123@gmail.com">gaurav.goyal123@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
Hi All,<br>
<br>
I have aother question on drools.<br>
There can le level1 to level6 present in a rule and we need to pick always<br>
the highest level rule which satisfied list price and discount comdition.<br>
<br>
Following code is giving me expected results but do we have any better way<br>
to implement the same. Can I avoid last 2 iternations and combine it to<br>
first one iteration.<br>
<br>
RoutingRule.java<br>
----------------<br>
private String level1 = "";<br>
private String level2 = "";<br>
private String level3 = "";<br>
private String level4 = "";<br>
private String level5 = "";<br>
private String level6 = "";<br>
private String serviceSalesPath = "";<br>
private String productSalesPath = "";<br>
private String nonStdTerm = "";<br>
private String currency = "";<br>
private double listPriceFrom = Double.MAX_VALUE ;<br>
private double listPriceTo = Double.MAX_VALUE ;<br>
private double discountPriceFrom = 100;<br>
private double discountPriceTo = 100 ;<br>
private double nodeOfRule =0;<br>
<br>
Rule<br>
-----<br>
<br>
$selectedTSSRulesWithOutHier : ArrayList()<br>
from collect ($routingRule : RoutingRule(currency == $curr<br>
&& (<br>
listPriceFrom <= $tssListPrice && listPriceTo > $tssListPrice<br>
&& discountPriceFrom <= $tssDisc && discountPriceTo > $tssDisc &&<br>
nonStdTerm =="TSS" )<br>
)<br>
from $tssRoutingRuleList)<br>
<br>
$lowestNodeTSS : Double(intValue > 0)<br>
from accumulate ( RoutingRule($nodeOfRule : nodeOfRule)<br>
from $selectedTSSRulesWithOutHier, max($nodeOfRule))<br>
<br>
$lowestNodeTSSRule : ArrayList()<br>
from collect( $ruleObj : RoutingRule( eval(nodeOfRule == $lowestNodeTSS) )<br>
from $selectedTSSRulesWithOutHier )<br>
<br>
Many thanks in advance,<br>
Gaurav<br>
<font color="#888888">--<br>
View this message in context: <a href="http://n3.nabble.com/Better-way-to-find-rule-with-max-value-tp442484p442484.html" target="_blank">http://n3.nabble.com/Better-way-to-find-rule-with-max-value-tp442484p442484.html</a><br>
Sent from the Drools - User mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Enda J Diggins<br>