My name is Oana Nicolae and I'm new in JBoss Rules community. I'm interested on Drools and I've read your e-mails with interest.
I don't know yet very well Drools, but I've remarked the mail sent by Karim (14.10.06) . I know he has found a solution for this problem but, I also want to make a remark, and to offer him an alternative to the way he has build the two JBoss rules: if stocks are evaluated by their stockPrice(s), the two rules must have the stockPrice(s) distinct intervals such as : (0,100) on first rule and (- inf , 0] on second rule, without no common value.So the two rules may look like this:
rule "Stock Price Low Enough"Cheers,
when
stockOffer : StockOffer( recommendPurchase == null, stockPrice <
100, stockPrice>0 )
then
stockOffer.setRecommendPurchase(StockOffer.YES);
end
-------------------------------------------------
rule "Stock Price Not Negative"
when
stockOffer : StockOffer( stockPrice <= 0 )
then
stockOffer.setRecommendPurchase(StockOffer.NO);
end
Oana
Karim Ratib <[EMAIL PROTECTED]> wrote:
I've ported the ONJava.com article "Give Your Business Logic a Framework with Drools" ( http://www.onjava.com/pub/a/onjava/2005/08/03/drools.html ) to JBoss Rules 3.0.4. More specifically, I translated the XML rules into DRL. I encountered an unexpected error that I need help with, so let me quickly explain the problem domain: Stocks are evaluated for purchase based on their price. Here are the 2 rules of interest:
rule "Stock Price Low Enough"
when
stockOffer : StockOffer( recommendPurchase == null, stockPrice < 100 )
then
stockOffer.setRecommendPurchase(StockOffer.YES);
end
rule "Stock Price Not Negative"
when
stockOffer : StockOffer( stockPrice < 0 )
then
stockOffer.setRecommendPurchase(StockOffer.NO);
end
When I run the rules on a StockOffer with stockPrice = -22, Drools answers with YES, which is not what I expect. I then added negative salience to rule #1 to force rule #2 to be evaluated first, and rule #1 should not even be invoked since recommendPurchase will not be null by then. But still, rule #1 was invoked and the result was set to YES.
Can anybody help me debug this situation?
TIA,
Karim
Get your email and more, right on the new Yahoo.com