<!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">
class instances are globals, classes themselves aren't.<br>
<br>
Mark<br>
Smitha Bhat wrote:
<blockquote cite="mid:704245.71238.qm@web60316.mail.yahoo.com"
 type="cite">
  <div>Hi Krishnan,</div>
  <div>I need the class itself to be global as I might have to access
other functions of it as I go along in the effort. </div>
  <div>I cannot seem to be able to call the methods of this global
class. I have also added a snippet of the code.</div>
  <div>&nbsp;</div>
  <div>Thanks</div>
  <div>&nbsp;Smitha</div>
  <div>Here is my drl</div>
  <div>&nbsp;</div>
  <div>&nbsp;</div>
  <div>drl=</div>
  <font size="1"> </font>
  <div><font size="1">package test.tools.rulesengine</font></div>
  <font size="1"> </font>
  <div><font size="1">import test.tools.rulesengine.Utilities;</font></div>
  <font size="1"> </font>
  <div><font size="1">global test.tools.rulesengine.Utilities util;</font></div>
  <font size="1"> </font>
  <div><font size="1">rule "Rule1"</font></div>
  <font size="1"> </font>
  <div><font size="1">when</font></div>
  <font size="1"> </font>
  <div><font size="1">$Position1 : PosReport()</font></div>
  <font size="1"> </font>
  <div><font size="1">eval($Position1.getName() == "POS_0_1")</font></div>
  <font size="1"> </font>
  <div><font size="1">then</font></div>
  <font size="1"> </font><font size="1"> </font>
  <div><font size="1">util.setColor($Position1, "red");</font></div>
  <font size="1"> </font>
  <div><font size="1">end</font></div>
  <font size="1"> </font>
  <div><font size="1">&nbsp;</font></div>
  <font size="1"> </font>
  <div>&nbsp;</div>
  <div>&nbsp;</div>
  <div>try {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;builder.addPackageFromDrl(new StringReader( drl) );<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(firstCall){<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; ruleBase = RuleBaseFactory.newRuleBase();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;ruleBase.addPackage( builder.getPackage() );<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;workingMemory = ruleBase.newWorkingMemory();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;Utilities util = new Utilities();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;workingMemory.setGlobal("util", util);</div>
  <div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;firstCall = false;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;}else<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;ruleBase.addPackage( builder.getPackage() );<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//workingMemory = ruleBase.newWorkingMemory();<br>
&nbsp;&nbsp;&nbsp;&nbsp;} catch (DroolsParserException e1) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// TODO Auto-generated catch block<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e1.printStackTrace();<br>
&nbsp;&nbsp;&nbsp;&nbsp;} catch (IOException e1) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// TODO Auto-generated catch block<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e1.printStackTrace();<br>
&nbsp;&nbsp;&nbsp;&nbsp;} catch (Exception e1) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// TODO Auto-generated catch block<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e1.printStackTrace();<br>
&nbsp;&nbsp;&nbsp;&nbsp;}</div>
  <div><br>
  <br>
  <b><i>Krishnan <a class="moz-txt-link-rfc2396E" href="mailto:krishiyer@gmail.com">&lt;krishiyer@gmail.com&gt;</a></i></b> wrote:</div>
  <blockquote class="replbq"
 style="border-left: 2px solid rgb(16, 16, 255); padding-left: 5px; margin-left: 5px;"><br>
Hi Smitha, <br>
    <br>
They way I understand, in the then clause you would like to call a
static function from some class. So, then you can add that to the
import and access it directly. It does not have to be global. However,
if for some reason you do need to add it as a global,, let me know. <br>
    <br>
send that when part of the rule again. <br>
    <br>
-Krishnan. <br>
    <br>
    <div><span class="gmail_quote">On 6/18/07, <b
 class="gmail_sendername">Smitha Bhat</b> &lt;<a moz-do-not-send="true"
 href="mailto:bhat_smitha@yahoo.com">bhat_smitha@yahoo.com </a>&gt;
wrote:</span>
    <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
      <div>Hi Krishnan,</div>
      <div>I need the functionality of being able to call methods of a
global class in the 'then' piece of the drl. I had defined the drl file
as: </div>
      <div>&nbsp;</div>
      <div>package test.tools.rulesengine</div>
      <div>import test.tools.rulesengine.Utilities;</div>
      <div>global test.tools.rulesengine.Utilities util;</div>
      <div>&nbsp;</div>
      <div>rule "Rule1"................. </div>
      <div>&nbsp;</div>
      <div>When I debug the 'when' piece, I see that the method to
check the name is being called, but tfter that, the global util's class
method is not called. Any pointers would be helpful.</div>
      <div>&nbsp;</div>
      <div>Thanks,</div>
      <div>Smitha
      <div><span class="e" id="q_1133f559e249ad7d_1"><br>
      <br>
      <b><i>Krishnan &lt;<a moz-do-not-send="true"
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="mailto:krishiyer@gmail.com" target="_blank"> krishiyer@gmail.com</a>&gt;</i></b>
wrote:</span></div>
      </div>
      <blockquote
 style="border-left: 2px solid rgb(16, 16, 255); padding-left: 5px; margin-left: 5px;">
        <div><span class="e" id="q_1133f559e249ad7d_3">Hi Smitha, <br>
        <br>
Rewrite the rule as follows :- <br>
        <br>
        <div><font size="2">rule "Rule1"</font></div>
        <div><font size="2">when</font></div>
        <div><font size="2">$Position1 : Position ( name matches
"POS-RPT_0_1" ) <br>
then <br>
        </font></div>
        <div><font size="2">$Position.setColor("red");<br>
        </font>
        <div><font size="2">end</font></div>
        <br>
Note : You had something called util, unless it is a global, it will
not work. <br>
        </div>
        <br>
-Krishnan. <br>
        <br>
        <div><span class="gmail_quote">On 6/18/07, <b
 class="gmail_sendername">Smitha Bhat</b> &lt;<a moz-do-not-send="true"
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="mailto:bhat_smitha@yahoo.com" target="_blank">
bhat_smitha@yahoo.com</a>&gt; wrote:</span>
        <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
          <div>Hi,</div>
          <div>I am new to JBoss rules. I have a .drl as given below: </div>
          <div>&nbsp;</div>
          <div><font size="2">rule "Rule1"</font></div>
          <div><font size="2">when </font></div>
          <div><font size="2">$Position1 : Position()</font></div>
          <div><font size="2">eval($Position1.getName() contains
"POS-RPT_0_1")</font></div>
          <div><font size="2">then</font></div>
          <div><font size="2">util.setColor($Position1, "red");</font></div>
          <div><font size="2">end</font></div>
          <div>&nbsp;</div>
          <div><font size="2">Before firing the rules, I assert my
object as </font></div>
          <div>&nbsp;</div>
          <div><font size="2">posIn = new Position(name,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;id,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;symbolCode,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lonDouble,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;latDouble,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elevDouble,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reportDate,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this);<br>
&nbsp;&nbsp;&nbsp;&nbsp;workingMemory.assertObject ( posIn );<br>
&nbsp;&nbsp;&nbsp;&nbsp;workingMemory.fireAllRules(); </font></div>
          <div>&nbsp;</div>
          <div><font size="2">I get the following error.</font></div>
          <div>&nbsp;</div>
          <font size="2"><font color="#ff0000" size="2">
          <div>org.drools.rule.InvalidRulePackage: Rule Compilation
error The left-hand side of an assignment must be a variable Syntax
error on token "contains", invalid AssignmentOperator </div>
          </font></font>
          <div><font size="2"><font color="#ff0000" size="2">at
org.drools.rule.Package.checkValidity(Unknown Source)</font></font></div>
          <div><font size="2"><font color="#ff0000" size="2">at
org.drools.common.AbstractRuleBase.addPackage(Unknown Source)</font></font></div>
          <div>&nbsp;</div>
          <div><font size="2"><font color="#ff0000" size="2">What is
wrong with my drl? I have a Utilities class that I have defined as
global. </font></font></div>
          <div>&nbsp;</div>
          <div><font size="2"><font color="#ff0000" size="2">Thanks</font></font></div>
          <font size="2"><font color="#ff0000" size="2"><span>
          <div>&nbsp;</div>
          </span></font></font><span>
          <hr size="1"> Looking for a deal? <a moz-do-not-send="true"
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="http://us.rd.yahoo.com/evt=47094/*http://farechase.yahoo.com/;_ylc=X3oDMTFicDJoNDllBF9TAzk3NDA3NTg5BHBvcwMxMwRzZWMDZ3JvdXBzBHNsawNlbWFpbC1uY20-"
 target="_blank">Find great prices on flights and hotels</a> with
Yahoo! FareChase. </span><br>
_______________________________________________<br>
rules-users mailing list<br>
          <a moz-do-not-send="true"
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
          <a moz-do-not-send="true"
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="https://lists.jboss.org/mailman/listinfo/rules-users"
 target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users </a><br>
          <br>
        </blockquote>
        </div>
        <br>
        <br clear="all">
        <br>
-- <br>
Sivaramakrishna Iyer Krishnan (Anand) <br>
        <br>
Never assume the obvious is true. <br>
        </span></div>
- William Safire _______________________________________________ <span
 class="q"><br>
rules-users mailing list<br>
        <a moz-do-not-send="true"
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
        <a moz-do-not-send="true"
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="https://lists.jboss.org/mailman/listinfo/rules-users"
 target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
        </span></blockquote>
      <span class="ad"><br>
      <hr size="1"> Need a vacation? <a moz-do-not-send="true"
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="http://us.rd.yahoo.com/evt=48256/*http://travel.yahoo.com/;_ylc=X3oDMTFhN2hucjlpBF9TAzk3NDA3NTg5BHBvcwM1BHNlYwNncm91cHMEc2xrA2VtYWlsLW5jbQ--"
 target="_blank">Get great deals to amazing places </a>on Yahoo!
Travel. </span><br>
_______________________________________________<br>
rules-users mailing list<br>
      <a moz-do-not-send="true"
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
      <a moz-do-not-send="true"
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="https://lists.jboss.org/mailman/listinfo/rules-users"
 target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users </a><br>
      <br>
    </blockquote>
    </div>
    <br>
    <br clear="all">
    <br>
-- <br>
Sivaramakrishna Iyer Krishnan (Anand) <br>
    <br>
Never assume the obvious is true. <br>
- William Safire _______________________________________________<br>
rules-users mailing list<br>
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
  </blockquote>
  <br>
  <p> </p>
  <hr size="1">Get the Yahoo! toolbar and <a moz-do-not-send="true"
 href="http://us.rd.yahoo.com/evt=48225/*http://new.toolbar.yahoo.com/toolbar/features/mail/index.php">be
alerted to new email </a>wherever you're surfing.
  <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>