The answer to both questions is basically the same: use the "this" reference.
rule CheckValidBinNumber
when
$br:BillingRecord(cardNo!=null || cardNo!="")
$valid: Boolean(this == false) from checkValidity($br.cardNo)
then
error(BillingRecordHelper.BIN_NO_INVALID_ERROR,log);
end
rule AssignMerchantNumber
when
$br:BillingRecord(merchantNo==null || merchantNo=="")
$mno:String(this != "") from getMerchantNo($br.billingActionCd,
$br.cardType,
$br.salesSourceTypeCode, $br.posId)
then
modify($br){setMerchantNo($mno);}
info(BillingRecordHelper.MERCHANT_NO_ASSIGNED_INFO,log);
end
--- On Sun, 11/15/09, ABRA2 <rabarna(a)archstone.in> wrote:
From: ABRA2 <rabarna(a)archstone.in>
Subject: Re: [rules-users] Help me improve my rules performance.
To: rules-users(a)lists.jboss.org
Date: Sunday, November 15, 2009, 11:13 PM
Thanks a lot. Your suggestions has helped me improve
my rule's performance.
I have two more rule i need help with.
1. How do i check for condition of boolean variable without
using eval like
in the case below?
rule CheckValidBinNumber
when
$br:BillingRecord(cardNo!=null ||
cardNo!="")
$valid: Boolean() from
checkValidity($br.cardNo)
eval(!($valid))
then
error(BillingRecordHelper.BIN_NO_INVALID_ERROR,log);
end
2. How do i check if the value of variable created in when
part without
using eval? getMerchantNo is a function defined in the .drl
file. If i dont
use the condition eval($mno!="") then my rules gets fired
in an infinte loop
because there is one more rule which sets the value of
billingActionCd in
BillingRecord in working memory and it also triggers this
rule.
rule AssignMerchantNumber
when
$br:BillingRecord(merchantNo==null ||
merchantNo=="")
$mno:String() from
getMerchantNo($br.billingActionCd, $br.cardType,
$br.salesSourceTypeCode, $br.posId)
eval($mno!="")
then
modify($br){setMerchantNo($mno);}
info(BillingRecordHelper.MERCHANT_NO_ASSIGNED_INFO,log);
end
I really appreciate your timely help for improving my
rules.
thanks
ABRA2
--
View this message in context:
http://old.nabble.com/Help-me-improve-my-rules-performance.-tp26261345p26...
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