<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Not easily no, the conditions are always evaluated first before any
ruiles are firing. The only way is to use some sort of semaphore that
is the first pattern in the rule, which would stop the rest of the rule
from being evaluated.<br>
<br>
Mark<br>
Yv RamaRao wrote:
<blockquote cite="mid:622021.74076.qm@web94508.mail.in2.yahoo.com"
 type="cite">
  <style type="text/css"><!-- DIV {margin:0px;} --></style>
  <div
 style="font-family: times new roman,new york,times,serif; font-size: 12pt;">
  <div>
  <div><font face="Arial" size="2">Hi all,</font></div>
  <div>&nbsp;</div>
  <div><font face="Arial" size="2">I has a problem in executing the
drool code.&nbsp;I have 2 rules&nbsp;with a condition and an action.<br>
The order of execution is <br>
  <br>
  </font>executeCondition1<br>
executeCondition2<br>
executeAction2()<br>
executeAction1()<br>
  <br>
but to fullfill my requirements i need the sequence to be executed as <br>
executeCondition1<br>
executeAction1()<br>
executeCondition2<br>
executeAction2()<br>
  <br>
Is there any to get way to execute the sequence as above. Kindly suggest<br>
  <br>
Here is Drool Code and Implementation Java Code<br>
  <font face="Arial" size="2"><br>
  <br>
Sample.drl<br>
========<br>
  </font></div>
  <div>package com.sample<br>
import com.sample.DroolsTest.MyDeligate;<br>
rule "Rule1"<br>
&nbsp;&nbsp; &nbsp;salience 2<br>
&nbsp;&nbsp; &nbsp;when<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;delegate: MyDeligate()<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;eval(delegate.executeCondition1());<br>
&nbsp;&nbsp; &nbsp;then <br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;delegate.executeAction1();<br>
end<br>
  <br>
rule "Rule2"<br>
&nbsp;&nbsp; &nbsp;salience 1<br>
&nbsp;&nbsp; &nbsp;when<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;delegate: MyDeligate()<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;eval(delegate.executeCondition2());<br>
&nbsp;&nbsp; &nbsp;then <br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;delegate.executeAction2();<br>
end<br>
  <br>
  </div>
&nbsp;DroolTest.java<br>
===========<br>
  <br>
package com.sample;<br>
  <br>
import java.io.InputStreamReader;<br>
import java.io.Reader;<br>
import org.drools.RuleBase;<br>
import org.drools.RuleBaseFactory;<br>
import org.drools.WorkingMemory;<br>
import org.drools.compiler.PackageBuilder;<br>
import org.drools.rule.Package;<br>
  <br>
public class DroolsTest {<br>
  <br>
&nbsp;&nbsp;&nbsp; public static final void main(String[] args) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RuleBase ruleBase = readRule();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WorkingMemory workingMemory = ruleBase.newWorkingMemory();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyDeligate delegate = new MyDeligate();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; workingMemory.assertObject(delegate);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; workingMemory.fireAllRules();&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } catch (Throwable t) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; t.printStackTrace();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }<br>
  <br>
&nbsp;&nbsp;&nbsp; private static RuleBase readRule() throws Exception <br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Reader source = new InputStreamReader(
DroolsTest.class.getResourceAsStream( "/Sample.drl" ) );<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; PackageBuilder builder = new PackageBuilder();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; builder.addPackageFromDrl( source );<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Package pkg = builder.getPackage();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; RuleBase ruleBase = RuleBaseFactory.newRuleBase();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ruleBase.addPackage( pkg );<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return ruleBase;<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; public static class MyDeligate <br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; public boolean executeCondition1()<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println("Executed Condition1");<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return true;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; public boolean executeCondition2()<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println("Executed Condition2");<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return true;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; public boolean executeCondition3()<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println("Executed Condition3");<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return true;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; public boolean executeAction1()<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println("Executed Action1");<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return true;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; public boolean executeAction2()<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println("Executed Action2");<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return true;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; public boolean executeAction3()<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println("Executed Action3");<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return true;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }<br>
}<br>
  <br>
Regards<br>
Ramarao</div>
  </div>
  <br>
<!--1-->
  <hr size="1"> Download prohibited? No problem. <a
 moz-do-not-send="true"
 href="http://in.rd.yahoo.com/tagline_webmessenger_1/*http://in.messenger.yahoo.com/webmessengerpromo.php">CHAT</a>
from any browser, without download.
  <pre wrap="">
<hr size="4" width="90%">
_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a>
  </pre>
</blockquote>
<br>
</body>
</html>