On 10 August 2011 17:14, Sumeet Karawal <span dir="ltr">&lt;<a href="mailto:sumeet.karawal@tcs.com">sumeet.karawal@tcs.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
<br>
package rules.person<br>
<br>
import com.person.Age<br>
Import com.person.Classification<br>
<br>
rule &quot;Check_person.option1&quot;<br>
<br>
when<br>
<br>
$age : com.person.Age()<br>
$classification : com.person.Classification()<br></blockquote><div><br>If you import, you can use just &quot;Age&quot; and &quot;Classification&quot;.<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<br>
eval ($age.getClassification(&quot;16&quot;))<br></blockquote><div><br>This is not correct since the return value of Age.getClassification is not a boolean.<br><br>As you present this code, it doesn&#39;t make any sense. The condition is a join of an Age object and a Classification object and the argument of getClassification(&quot;16&quot;) is a literal.<br>
<br>Providing an object to collect results is one reasonable way of doing it.<br><br>-W<br><br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<br>
then<br>
<br>
modify ($classification) {$classification.setResult(&#39;&quot;Teenager&quot;; }<br>
<br>
end<br>
<br>
rule &quot;Check_person.option2&quot;<br>
<br>
when<br>
<br>
$age : com.person.Age()<br>
$classification : com.person.Classification()<br>
<br>
eval ($age.getClassification(&quot;40&quot;))<br>
<br>
then<br>
<br>
modify ($classification) {$classification.setResult(&#39;&quot;Adult&quot;; }<br>
<br>
end<br>
<br>
<br>
Application Class :<br>
<br>
public class Age<br>
{<br>
        public string getClassification(String name) {<br>
                &lt;Logic of the application&gt;<br>
                return str;<br>
        }<br>
}<br>
<br>
public class Classification<br>
{<br>
        public void setResult(String name) {<br>
                &lt;Logic of the application&gt;<br>
<br>
        }<br>
}<br>
<br>
<br>
<br>
Queries :<br>
<br>
   Please let me know if I am using the &#39;when&#39; part correctly.<br>
   And please check for the use of the object &#39;classification&#39; in my<br>
   application (as return value to the application)<br>
<div class="im"><br>
<br>
<br>
<br>
Thanks &amp; Regards,<br>
Sumeet Karawal<br>
Mailto: <a href="mailto:sumeet.karawal@tcs.com">sumeet.karawal@tcs.com</a><br>
<br>
<br>
<br>
</div>  From:       Wolfgang Laun &lt;<a href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</a>&gt;<br>
<br>
  To:         Rules Users List &lt;<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>&gt;<br>
<br>
  Date:       08/10/2011 03:03 PM<br>
<br>
  Subject:    Re: [rules-users] Calling a method in when part<br>
<br>
  Sent by:    <a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a><br>
<div><div></div><div class="h5"><br>
<br>
<br>
<br>
<br>
<br>
If you don&#39;t show your code we can&#39;t tell you what is wrong with it. So I<br>
think what you may have to do is<br>
<br>
when<br>
   $someObj: SomeClass()  # matches each WME of SomeClass<br>
   eval( $someObj.getValueBoolean(&quot;abc&quot;))<br>
then<br>
<br>
There is not much to be gained by using a DRL function; it would have to be<br>
called like<br>
   eval( someFunction( $someObj, &quot;abc&quot; ) )<br>
<br>
-W<br>
<br>
<br>
On 10 August 2011 11:05, Sumeet Karawal &lt;<a href="mailto:sumeet.karawal@tcs.com">sumeet.karawal@tcs.com</a>&gt; wrote:<br>
<br>
  Hi,<br>
<br>
  I have a requirement where there is a customized Java class having a<br>
  method<br>
  that returns some value.<br>
  like:<br>
<br>
  getValueBoolean(&quot;Some String&quot;)<br>
<br>
  { //some calculation<br>
    // returns a boolean value<br>
  }<br>
<br>
  The default getters and setters are not being used in the Application.<br>
  The<br>
  value that is being returned by the method needs to be checked in<br>
  the .drl<br>
  file.<br>
  There are different Java classes with these kind of methods. Where the<br>
  string and integer value is also returned. I have gone through the<br>
  documentation for Drools-Expert but have only found the implementation<br>
  for<br>
  the method in the consequence part, i.e., the then part.<br>
<br>
  This is how I tried:<br>
<br>
  importing the class<br>
<br>
  in when<br>
  binding the a variable to the Class name suppose $c<br>
  eval ($c.getValueBoolean(&quot;abc&quot;))<br>
  then<br>
  System.out.println(&quot;the value is true&quot;)<br>
<br>
<br>
  It didn&#39;t work this way.<br>
  I tried by another way like :<br>
<br>
  creating a function in the .drl itself that calls the method of that<br>
  class<br>
  and returns a value<br>
  then calling this drl function in the when part and carrying on.<br>
<br>
  It would be very helpful if some body could let me know how to do this in<br>
  the .drl.<br>
<br>
<br>
  Thanks &amp; Regards,<br>
  Sumeet Karawal<br>
  Mailto: <a href="mailto:sumeet.karawal@tcs.com">sumeet.karawal@tcs.com</a><br>
<br>
  =====-----=====-----=====<br>
  Notice: The information contained in this e-mail<br>
  message and/or attachments to it may contain<br>
  confidential or privileged information. If you are<br>
  not the intended recipient, any dissemination, use,<br>
  review, distribution, printing or copying of the<br>
  information contained in this e-mail message<br>
  and/or attachments to it are strictly prohibited. If<br>
  you have received this communication in error,<br>
  please notify us by reply e-mail or telephone and<br>
  immediately and permanently delete the message<br>
  and any attachments. Thank you<br>
<br>
<br>
<br>
  _______________________________________________<br>
  rules-users mailing list<br>
  <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
  <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br>