Are you sure that it is only the variable name that differs? I see you
use an extra condition in your second rule:
id.spiProgram not in (null, " ", "", $spiP )
You are testing for a single space here, while in the first rule you are
not.
I'm asking because drools does not make any "processing" on variable
names... it does not matter if you call them xyz, banana or apple. Also, the
"$" as you probably know is a valid variable name identifier and so, drools
also does not care about it.
If you are positive that the variable name is the only difference, I ask
you please to isolate a self contained test case that we can reproduce in
order to fix whatever is happening there. In your example rule above, there
is only one gotcha, but that should not cause any problem: since you are
using a nested access ("id.spiProgram"), the actual constraint is delegated
to MVEL for resolution, but again, mvel uses the variables injected by
drools to resolve the constraint and drools makes no change on variable
names.
[]s
Edson
2008/6/16 Mike D <mike.dalaker(a)kewill.com>:
Just wondering if anyone else has come across this:
I have a rule that has a variable with the same name as the element and
when
used in a "not in", the rule does not fire properly.
rule "0620 Fail Invalid SPI Primary"
when
exists ValidationControl(validationNo == 620)
CiLines($ciNo : ciNo, $ciLineNo : ciLineNo, $countryOrigin :
countryOrigin)
Country(country == $countryOrigin, canadianProvince not in
("Y","L"))
CiTariffClass(id.ciNo == $ciNo, id.ciLineNo == $ciLineNo,
$spiPrimary : spiPrimary not in
(null,"","W","Z","Y","N"), $tariffNo :
tariffNo,
spiPrimary0_1 not in ("P","A","E"),
$tariffLineNo :
tariffLineNo)
ShipmentHeader($dateEntry : dateEntry)
TariffClass(id.tariffNo == $tariffNo, dateTariffEffective <=
$dateEntry,
dateTariffExpiration >= $dateEntry,
$dateTariffEffective :
dateTariffEffective)
TariffValidSpi(id.tariffNo == $tariffNo,
id.dateTariffEffective ==
$dateTariffEffective)
spiProgram1_1 not in ("*","+"), id.spiProgram
not
in (null, "",
$spiPrimary))
$status : ValidationPassFailStatus()
then
ValidationData $data = new ValidationData(620);
$data.setCiNo($ciNo);
$data.setCiLine($ciLineNo);
$data.setTariffLineNo($tariffLineNo);
$data.setTariffNo($tariffNo);
$data.setAdditionalInfo("SPI Primary: "+$spiPrimary);
$status.fail($data);
end
whereas, if I change the rule to:
rule "0620 Fail Invalid SPI Primary"
when
exists ValidationControl(validationNo == 620)
CiLines($ciNo : ciNo, $ciLineNo : ciLineNo, $countryOrigin :
countryOrigin)
Country(country == $countryOrigin, canadianProvince not in
("Y","L"))
CiTariffClass(id.ciNo == $ciNo, id.ciLineNo == $ciLineNo,
$spiP : spiPrimary not in
(null,"","W","Z","Y","N"),
$tariffNo :
tariffNo,
spiPrimary0_1 not in ("P","A","E"),
$tariffLineNo :
tariffLineNo)
ShipmentHeader($dateEntry : dateEntry)
TariffClass(id.tariffNo == $tariffNo, dateTariffEffective <=
$dateEntry,
dateTariffExpiration >= $dateEntry,
$dateTariffEffective :
dateTariffEffective)
TariffValidSpi(id.tariffNo == $tariffNo,
id.dateTariffEffective ==
$dateTariffEffective)
spiProgram1_1 not in ("*","+"), id.spiProgram
not
in (null, " ", "",
$spiP))
$status : ValidationPassFailStatus()
then
ValidationData $data = new ValidationData(620);
$data.setCiNo($ciNo);
$data.setCiLine($ciLineNo);
$data.setTariffLineNo($tariffLineNo);
$data.setTariffNo($tariffNo);
$data.setAdditionalInfo("SPI Primary: "+$spiP);
$status.fail($data);
end
it works as it should. I found this when hardcoding the value it was
looking for and it passed.
--
View this message in context:
http://www.nabble.com/%22not-in%22-error-tp17867925p17867925.html
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
--
Edson Tirelli
JBoss Drools Core Development
Office: +55 11 3529-6000
Mobile: +55 11 9287-5646
JBoss, a division of Red Hat @