[rules-users] Help -- Conditional Logic in DRL

Scott Reed sreed at avacoda.com
Mon Jun 15 23:19:16 EDT 2009


Looks like 5 rules with a global flag might work:

global boolean flag = false;

rule "name1"
when
  (condition1 == true )
  (flag == false)
then
  consequence1();
  flag = true;
end

...

rule "name5"
when
  (condition5 == true )
  (flag == false)
then
  consequence5();
  flag = true;
end

Does that work for you?

Vishy [6/15/2009 11:06 PM] wrote:
> Hi All,
>
> I am new to drools...and am trying to figure out as to how I can
> represent the following logic in a DRL file.
>
> if (condition1) {
>
>   if (condition2) {
>
>   } else if (condition3) {
>
>   } else if (condition 4) {
>
>   } else if (condition 5) {
>
>   }
>
> }
>
> In DSL, a typical rule is represented as follows:
>
> rule "name"
>
> when
>   condition is true
> then
>   consequence
>
> end
>
> How can I represent the above mentioned if - else logic in DSL? Or is
> it not possible?
>
> If it is not, can you please suggest any alternative?
>
> Thanks much!!
> _______________________________________________
> 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