[rules-users] missing parameters in the fact object

Anstis, Michael (M.) manstis1 at ford.com
Wed Feb 6 04:18:49 EST 2008


Facts are simply POJO's so you can only achieve in a rule that you could in
Java.
 
I assume (given the presumably simplified example below) that you have a
super class Shape and subclasses Rectangle and Cube that extend Shape.
 
Therefore I think your separate "twodimensional" and "threedimensional"
rules should reference the subclasses and not the super class (as a call to
Shape.getVolume() would fail in Java).
 
I don't think Drools performs subclass conversion on LHS patterns!?!?!


  _____  

From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Jai Vasanth
Sent: 06 February 2008 00:14
To: Rules Users List
Subject: [rules-users] missing parameters in the fact object


Hi,

  I am using agenda groups to  pick sets of rules to fire based on an
attribute value. The presence or absence of other attributes  is dependent
on the value of this attribute based on which I select  a particular agenda
group.

Here is an example

rule "ABC"
  when  
    Shape( type = "rectangle" )
  then 
    drools.setFocus("twodimensional")
end


rule "PQR"
  when  
    Shape( type = "cube" )
  then 
    drools.setFocus("threedimensional")
end

rule "area threshold"
agenda-group "twodimensional"
  when  
    Shape( area > 20 )
  then  
    System.out.println ("large object" );
end
 
rule "volume threshold"
agenda-group "threedimensional"
  when  
    Shape( volume > 20 )
  then  
    System.out.println ("large object" );
end
  

Suppose if my shape object is a rectangle, then it wouldnt have the volume
attribute. In this case when we try to run these rules it would throw a
NoSuchElementException.

Is there a way to avoid this? Agenda groups help us fire the RHSs
conditionally, Is there a way by which I can conditionally fire LHS of
certain sets of rules ?


Thanks 


Jai 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20080206/1abf9e86/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 4159 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20080206/1abf9e86/attachment.bin 


More information about the rules-users mailing list