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@lists.jboss.org [mailto:rules-dev-bounces@lists.jboss.org] On
Behalf Of David Sinclair
Sent: Wednesday, November 12, 2008 8:50 AM
To: m_dilipkumar2006@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@yahoo.co.in>
wrote:
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
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.
_______________________________________________
rules-dev mailing list
rules-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev