Hi Guarav,
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:
$ruleToChoose : RoutingRule (listPriceFrom <= $tssListPrice, listPriceTo >
$tssListPrice
&& discountPriceFrom <= $tssDisc,
discountPriceTo > $tssDisc,
nonStdTerm =="TSS", $nodeOfRule :
nodeOfRule) from $tssRoutingRuleList
not RoutingRule (listPriceFrom <= $tssListPrice, listPriceTo > $tssListPrice
, discountPriceFrom <= $tssDisc,
discountPriceTo > $tssDisc,
nonStdTerm =="TSS", nodeOfRule >
$nodeOfRule) from $tssRoutingRuleList
Note that this logic states:
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.
Also note that I removed you "&&" operators and replaced them with
","
(comma).
Let me know if I have misunderstood your problem.
Hope it helps!
Enda
On Thu, Mar 11, 2010 at 5:47 PM, Gaurav <gaurav.goyal123(a)gmail.com> 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
--
View this message in context:
http://n3.nabble.com/Better-way-to-find-rule-with-max-value-tp442484p4424...
Sent from the Drools - User mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Enda J Diggins