[rules-users] factorize rules

2012-09-20 Thread John Dujon
Hello,

I am trying to make my rules more readable and wonder wether or not we can
factorize rules for a particular ruleflow-group. As an example, I would
like to convert this:

// begin rules
rule Rule 1
 ruleflow-group work
when
  condition 0
  condition1
then
  doSomething();

rule Rule 2
 ruleflow-group work
when
  condition0
  condition2
then
  doSomethingElse();

// end rules

to the following

// begin rules

pre_conditions_for_rules
  ruleflow-group work
  condition0

rule Rule 1
 ruleflow-group work
when
  condition1
then
  doSomething();
end

rule Rule 2
 ruleflow-group work
when
  condition2
then
  doSomethingElse();
end

// end rules


Thank you for your time. I apologize in advance if that does not make
sense, as I am new to drools

John
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] factorize rules

2012-09-20 Thread Wolfgang Laun
@dev: When will extends for rules be documented in the proper place?

@John: There is a feature doing just that:

rule pre_conditions_for_rules
when
   condition0
then end

rule Rule 1 extends pre_conditions_for_rules
   ruleflow-group work
when
  //...

-W

On 20/09/2012, John Dujon johndu...@gmail.com wrote:
 Hello,

 I am trying to make my rules more readable and wonder wether or not we can
 factorize rules for a particular ruleflow-group. As an example, I would
 like to convert this:

 // begin rules
 rule Rule 1
  ruleflow-group work
 when
   condition 0
   condition1
 then
   doSomething();

 rule Rule 2
  ruleflow-group work
 when
   condition0
   condition2
 then
   doSomethingElse();

 // end rules

 to the following

 // begin rules

 pre_conditions_for_rules
   ruleflow-group work
   condition0

 rule Rule 1
  ruleflow-group work
 when
   condition1
 then
   doSomething();
 end

 rule Rule 2
  ruleflow-group work
 when
   condition2
 then
   doSomethingElse();
 end

 // end rules


 Thank you for your time. I apologize in advance if that does not make
 sense, as I am new to drools

 John

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users