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

Francisco Brum francisco.brum at link.pt
Fri Mar 2 05:50:27 EST 2007


I also need to make a rule with a lookup tables, and I have found that the new version of rules support 'from'.

 

The syntaxe it's something like:


'from'


*	http://jira.jboss.com/jira/browse/JBRULES-341 

'from' allows the engine to reason over data not inside the engine, this can be used with global variables to interact with data providing services, such as hibernate. MVEL provides the scripting language capabilities for this, any previously bound variable can be used in the MVEL expression. The following example shows a hibernate named query with some dummy properties that returns a list of Restaurants. Restaurant() is a standard pattern, and can have its own field constraint and bindings like any other pattern. 

    $r : Restaurant( $postCode ) from hbSession.getNamedQuery( "some query" ).setProperties( [ key1 : value2, key2 : value ] ).list()

 

I haven't tried it yet, and I have some questions also. But go ahead! :-)

__________________________________

Francisco Brum - francisco.brum at link.pt

Link Consulting - http://www.link.pt/

Tel.: 213 100 031

Av. Duque D'Ávila, 23 4º Esq.

1000-138 Lisboa

 

-----Original Message-----
From: rules-users-bounces at lists.jboss.org [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Anstis, Michael (M.)
Sent: sexta-feira, 2 de Março de 2007 9:16
To: Rules Users List
Subject: RE: [rules-users] Rules with Lookup Tables...

 

I don't have the syntax at hand but Edson has previously posted about

using "from" in similar circumstances.

 

This would allow you to access a lookup table on a database as part of

the LHS of a rule.

 

-----Original Message-----

From: rules-users-bounces at lists.jboss.org

[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of jdepaul

Sent: 01 March 2007 19:35

To: rules-users at lists.jboss.org

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

 

 

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#a925682

5

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

 

_______________________________________________

rules-users mailing list

rules-users at lists.jboss.org

https://lists.jboss.org/mailman/listinfo/rules-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070302/bd8fd9c8/attachment.html 


More information about the rules-users mailing list