Please help with 'contains' keyword syntax. I have the following code in
place - I'm wondering why this rule does NOT parse properly?!
I assert GATE_IN object - that's my primary fact. I also assert a
supporting fact called a LookupTableDOM into working memory, which contains
String name and ArrayList values. I want my rule to fire when
CUSTOMER_REFERENCE_NUMBER == "HX" and GATE_IN.SH_CODE exists in the List of
values from LookupTableDOM - what am I doing wrong here:
// This does NOT work
1 rule "This rule does NOT work"
2 when
3
4 // values variable is an ArrayList containing String elements...
5 LookupTableDOM( $name : name == "MILT.CUSTO", $MiltVals : values );
6
7 $gateIN : GATE_IN( CUSTOMER_REFERENCE_NUMBER == "HX",
8 $sh_code : SH_CODE,
9 $MiltVals contains $sh_code ) <-- what's wrong with
this line???
10 //$MiltVals.contains($sh_code) ) <-- this did
not work either...
11 then
12 // do something...
13end
This code was built based on the example you offered below - I just can't
make the syntax work. Please help.
James
Edson Tirelli-3 wrote:
rule "retrieving the list"
when
Customer( $custCode : customer_code )
then
List codes = lookupDAO.getLookup( $custCode );
assert( codes );
end
rule "doing something"
when
Customer( $custCode : customer_code )
$list : List()
SHIPMENT_MOVE(customer_code == $custCode, $sc : ship_code,
$dc : deliver_code, $pc : port_code,
( $list.containts($sc) ||
$list.containts($dc) || $list.containts($pc) ) )
then
// do something
end
If your DAO returns a specific class, like the one mentioned in one
of your examples bellow (LookupTableResults) and it is not a collections
implementation, you can even do things like:
when
SHIPMENT_MOVE(customer_code == "abc", $sc : ship_code,
$dc : deliver_code, $pc : port_code
)
LookupTableResult( elements contains $sc | contains $dc | contains
$pc ) from lookupDAO.getLookup(...)
)
then
// consequence
end
--
View this message in context:
http://www.nabble.com/Struggling-with-Rule-syntax---please-help...-tf3408...
Sent from the drools - user mailing list archive at
Nabble.com.