[rules-users] Rules with Lookup Tables...

jdepaul jjdepaul at us.ibm.com
Thu Mar 1 14:34:43 EST 2007


I need to evaluate a set of Rules with some of the operators comparing values
from Facts against a changing Lookup Table - for instance:

Some Partners may have several lookup tables defined like this:

NISSAN has partner_ids = {2222, 4444, 5555, 66666} and port_locations =
{ABC, EFG, GEE, FDD...}  - these values are stored in the database and need
to be evaluated at run-time.

I suppose one way I could do this is to write a rule like this (sorry,
syntax probably off a bit)...:

rule "partner and port match"
  when
    $shipment: Shipment(customerName== "NISSAN", partnerID== "2222"
                                 || customerName=="NISSAN",
partnerID=="3333"
                                 || customerName=="NISSAN",
parternID=="4444")

                                 || customerName=="NISSAN",
portLocation=="ABC"
                                 || customerName=="NISSAN",
portLocation=="EFG"
                                 || customerName=="NISSAN",
partLocation=="FDD")
  then
    System.out.println("Found the right one!");
end

Trouble is that the values in these lookup tables change frequently, so I
would like to create a rule that references a lookup table that does a DB
lookup to evaluate the values at run-time - something like this:

rule "partner and port with lookup-table" 
  when
    $shipment: Shipment(customerName== "NISSAN", partnerID in $(partner_ids
) )  <-- db lookup here

                                 || customerName=="NISSAN", portLocation in
$(port_locations))  <-- db lookup here
  then
    System.out.println("Found the right one!");
end


I know this is probably a stretch in this case - just wondering if anyone
else was able to solve such a problem?!  If so, how - 

Thanks,
James

-- 
View this message in context: http://www.nabble.com/Rules-with-Lookup-Tables...-tf3329159.html#a9256825
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list