[rules-dev] Regarding Nested Rules in Drools 4.0.7

Michael Rhoden mrhoden at franklinamerican.com
Wed Nov 12 10:03:40 EST 2008


I'm not sure you can nest rules, you are thinking too procedural, but you
can extend conditions/lhs from other rules. Here is an example from the
test case in the drools source "extend_rule_test.drl" that may help you.

 

rule "test rule 1"

    enabled false

    when

        c: Cheese( type == "stilton" )

    then

            list.add( new String ("rule 1") );        

end 

 

rule "test rule 2" extends "test rule 1"

    enabled false

    when

        Cheese( price <= 6.00) from c

    then

            list.add( new String ("rule 2") );       

end 

 

rule "test rule 3" extends "test rule 2"

    when

        Cheese( price > 1.00 ) from c

    then

            list.add( new String ("rule 3") );         

end

 

Rule 1 & 2 are disabled, but rule 3 in the rete network will have all 3
LHS (conditions). So the above would render.

 

rule "test rule 3"

    when

c: Cheese( type == "stilton" )

Cheese( price <= 6.00) from c

Cheese( price > 1.00 ) from c

then

            list.add( new String ("rule 3") );         

end

 

This was modeled more after how a programming language would have one
class extend another, but it only inherits the LHS.

 

-Michael

 

P.S. I believe this is available only in trunk at this time, but will be
out with the next 5.x release.

 

 

From: rules-dev-bounces at lists.jboss.org
[mailto:rules-dev-bounces at lists.jboss.org] On Behalf Of David Sinclair
Sent: Wednesday, November 12, 2008 8:50 AM
To: m_dilipkumar2006 at yahoo.co.in; Rules Dev List
Subject: Re: [rules-dev] Regarding Nested Rules in Drools 4.0.7

 

I think u are thinking about this in the wrong sense. You don't want to
call another rule. You can assert a fact that will cause that other rule
to fire.

On Wed, Nov 12, 2008 at 9:45 AM, M.DILIP KUMAR
<m_dilipkumar2006 at yahoo.co.in> wrote:



Hi All,

    I got many idea by using this group. Now i want one clarification
regarding Nested rule.

 

If any one having sample code for nested Rule means Pls send reply along
this mail.

 

Acutally i want rule like 

Rule : "nested Rule"

 When 

       #Condition is true

 Then 
     CALL another RULE ...!!!!

      Here i want pass some argument to that nested rule

  is it possible ? 

End

 

Help me regarding this and send sample code if possible please

 

Defeat yourself today!

____________________________ 

    Error! Filename not specified.DILIP  KUMAR.M

 

  _____  

Add more friends to your messenger and enjoy! Invite them now.
<http://in.rd.yahoo.com/tagline_messenger_6/*http:/messenger.yahoo.com/inv
ite/> 
_______________________________________________
rules-dev mailing list
rules-dev at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-dev/attachments/20081112/646485a6/attachment.html 


More information about the rules-dev mailing list