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

Rahul Phadnis rahul.phadnis at fatspaniel.com
Fri Mar 2 12:55:07 EST 2007


Previously Edson had suggested using the "from" CE. 
Here is the example from his previous posting

rule "Device not working (condition id = 4)"
  when
    alertDefinition : AlertDefinition (conditionID==
4, eid : entityID)
    Power( value < 1000 ) from dao.getPower( eid )
    Temperature( deviceTemp > 50, ambTemp > 40 ) from 
dao.getTemperature(eid)
  then
    log("Triggered Device not working  alert for "+
eid);
end

The "from" CE (conditional expression) is not
available  in the current released jboss rules version
(3.0.5) and you probably have to use the nightly build
to use it.

-Rahul


--- "Anstis, Michael (M.)" <manstis1 at ford.com> wrote:

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




More information about the rules-users mailing list