[rules-users] Struggling with Rule syntax - please help...
Anstis, Michael (M.)
manstis1 at ford.com
Thu Mar 22 10:36:13 EDT 2007
Hi James,
You can't use a bound object as the list against which "contains"
operates.
Something like this should work, where getLookupValues() returns an
ArrayList by calling LookupTableDOM with name="MILT.CUSTO".
rule "This rule does NOT work"
when
$gateIN : GATE_IN( CUSTOMER_REFERENCE_NUMBER == "HX", $sh_code :
SH_CODE, lookupValues contains $sh_code )
then
// do something...
End
With kind regards,
Mike
-----Original Message-----
From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of jdepaul
Sent: 22 March 2007 13:04
To: rules-users at lists.jboss.org
Subject: Re: [rules-users] Struggling with Rule syntax - please help...
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...-tf340
8727.html#a9611859
Sent from the drools - user mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
More information about the rules-users
mailing list