[rules-users] Struggling with Rule syntax - please help...

jdepaul jjdepaul at us.ibm.com
Thu Mar 15 16:06:00 EDT 2007


Thank you for an exhaustive reply Edson - this helps a lot.  A couple of
things to clarify and then some follow-up questions for you:

My DAO takes a String name of the lookup table as input and returns a List
of String values for that lookup table name.  Three will be a fairly good
number of common lookup tables: around 650 in all, each table will have a
collection of String values tied to it.  Some tables will have as much as
33,000 String values (only one of them has that many, the rest have 5,10, 20
values at the most).  All these lookup tables will be used in many rules. 
Some rules will reference the Lookup tables, some may not.

>From your description, looks like I should pursue Approach #2 as my best
bet:  I plan on having a rule to retrieve the codes.  Looking at the example
you listed (see below) I understand MOST of it:  first rule is to retrieve
the codes and to assert them in working memory:

>>    List codes = lookupDAO.getLookup( $custCode );  <-- OK
>>    assert( codes );  <-- OK 

I do not understand the line in the next rule below that reads:
>> $list : List()  <-- does this somehow refer to "codes" List above?  

How does this variable $list get assigned to the List of codes asserted in
the rule above - am I missing something in the syntax?  What would be the
syntax to assert more than one List object (List codes, List from_ports,
List  to_ports) into the Working Memory?

The syntax below that reads:  >> ( $list.containts($sc) ||
$list.containts($dc) || $list.containts($pc) << - that helps me a lot - I
just need to know how to define different $lists and assign them to
different set of codes ($codes_list, $fromPorts_list, $toPorts_list, etc)
and I'll be on my way.

Thanks,
James


Edson Tirelli-3 wrote:
> 
> 
> ...   What are the "elements" in your list? Strings?
> 
> #2 ...  If you expect your list to have a lot of objects, or if you expect
> to 
> use the same list in more than one rule, you can improve performance by 
> doing a rule to retrieve and assert the list of codes, based on whatever 
> criteria you need (customer code for instance in the bellow example):
> 
> rule "retrieving the list"
> when  
>     Customer( $custCode : customer_code )
> then
>     List codes = lookupDAO.getLookup( $custCode );  <-- OK
>     assert( codes );  <-- OK
> end
> 
> rule "doing something"
> when
>     Customer( $custCode : customer_code )  <--ok
>     $list : List()  <-- Don't understand...  How is the $list variable
> here linked back to the "List codes" in the rule above?
>     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
> 

-- 
View this message in context: http://www.nabble.com/Struggling-with-Rule-syntax---please-help...-tf3408727.html#a9502475
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list