<div dir="ltr"><br> Oh, I see. <br><br> Unfortunately in this case, there is nothing we can do about it, because the rules are behaving exactly as they were supposed to behave:<br><br>NegativeResult(applicant == $applicant)<br>
<br> As you can see, they are telling the application to use the equals comparison in the constraint:<br><br>applicant == $applicant<br><br> A fact should not change it's identity once it is asserted, so, either you use a constant "equals()/hashcode()" implementation, or you use constraints on an immutable ID:<br>
<br>NegativeResult(applicantId == $<a href="http://applicant.id">applicant.id</a>)<br><br> You can also fallback to java "identity" check by using eval, but it is ugly... :)<br><br>NegativeResult( eval( applicant == $applicant) )<br>
<br> []s<br> Edson<br><br><br><div class="gmail_quote">2008/8/4 <span dir="ltr"><<a href="mailto:ringsah@comcast.net">ringsah@comcast.net</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>
<div>
<div>Edson,</div>
<div> </div>
<div>I finally succeeded in coming up with a simple test case that shows the problem. I have attached the necessary files, which include a test case, three fact objects, and the drl.</div>
<div> </div>
<div>One key to this test are the fact that the Applicant fact object has an "equals" method that tests for equality of its attributes, rather than identity. A second key is that the applicant object is updated after it is inserted.</div>
<div> </div>
<div>It appears that what is happening is that an activation is created for the rule that uses "not" when the applicant is inserted. Then, when the applicant is updated, a second activation is created for that rule. It should be cancelling the previous activation, but doesn't find it because the Applicant instance no longer "equals" the fact object that caused the activation.</div>
<div> </div>
<div>Thanks!</div>
<div>-Hans</div>
<blockquote style="border-left: 2px solid rgb(16, 16, 255); padding-left: 5px; margin-left: 5px;"><div class="Ih2E3d">-------------- Original message -------------- <br>From: "Edson Tirelli" <<a href="mailto:tirelli@post.com" target="_blank">tirelli@post.com</a>> <br>
</div><div dir="ltr"><div class="Ih2E3d"><br> Hans, <br><br> Your reasoning is correct. There should not be 2 instances of ApplicantStatus in the working memory. <br><br> Can you provide a test case showing the problem? we have test cases here using "not" and logical assertions, and it works properly.<br>
<br> Thanks,<br> Edson<br><br>
</div><div class="gmail_quote">2008/7/31 <span dir="ltr"><<a href="mailto:ringsah@comcast.net" target="_blank">ringsah@comcast.net</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>
<div><div class="Ih2E3d"><font size="2">
<p>How is "</p></font><font size="2" face="Courier New">not</font><font size="2">" supposed to work with </font><font size="2" face="Courier New">insertLogical</font><font size="2">? Assume I have two different rules whose conditions are mutually exclusive, like the following:</font><b><font color="#960000" size="2" face="Courier New">
<p>rule</p></font></b><font size="2" face="Courier New"></font><font color="#008000" size="2" face="Courier New">"</font><font color="#008000" size="2" face="Courier New">Rule One</font><font color="#008000" size="2" face="Courier New">"</font><font size="2" face="Courier New">
<p></p></font><b><font color="#960000" size="2" face="Courier New">when</font></b><font size="2" face="Courier New">
<p></p></font><font size="2" face="Courier New">not NegativeResult()</font><font size="2" face="Courier New">
<p></p></font><b><font color="#960000" size="2" face="Courier New">then</font></b><font size="2" face="Courier New">
<p></p></font><b><font color="#960000" size="2" face="Courier New">insertLogical</font></b><font size="2" face="Courier New">(</font><font size="2" face="Courier New">new ApplicantStatus("Approved")</font><font size="2" face="Courier New">);</font><b><font color="#960000" size="2" face="Courier New">
<p>end</p></font></b><font size="2" face="Courier New"></font><b><font color="#960000" size="2" face="Courier New">
<p>rule</p></font></b><font size="2" face="Courier New"></font><font color="#008000" size="2" face="Courier New">"</font><font color="#008000" size="2" face="Courier New">Rule Two</font><font color="#008000" size="2" face="Courier New">"</font><font size="2" face="Courier New">
<p></p></font><b><font color="#960000" size="2" face="Courier New">when</font></b><font size="2" face="Courier New">
<p></p></font><font size="2" face="Courier New">NegativeResult()</font><font size="2" face="Courier New">
<p></p></font><b><font color="#960000" size="2" face="Courier New">then</font></b><font size="2" face="Courier New">
<p></p></font><b><font color="#960000" size="2" face="Courier New">insertLogical</font></b><font size="2" face="Courier New">(</font><font size="2" face="Courier New">new ApplicantStatus("Denied")</font><font size="2" face="Courier New">);</font><b><font color="#960000" size="2" face="Courier New">
<p>end</p></font></b><font size="2" face="Courier New"></font><font size="2">
<p>Assume that the above two rules are the only way an </p></font><font size="2" face="Courier New">ApplicantStatus</font><font size="2"> fact can be inserted into working memory. I would expect, after all rules are run, that it would be impossible for there to be one </font><font size="2" face="Courier New">ApplicantStatus</font><font size="2"> with </font><font size="2" face="Courier New">"Approved"</font><font size="2"> as its reason, and another with </font><font size="2" face="Courier New">"Denied"</font><font size="2"> as its reason, in the working memory.
<p>I would expect that, before any </p></font></div><font size="2" face="Courier New">NegativeResult</font><font size="2"> is inserted, that rule one could run, and insert an </font><font size="2" face="Courier New">ApplicantStatus</font><font size="2"> fact with an </font><font size="2" face="Courier New">"Approved"</font><font size="2"> reason. Then, after a </font><font size="2" face="Courier New">NegativeResult</font><font size="2"> is inserted, that rule two could run, and insert an </font><font size="2" face="Courier New">ApplicantStatus</font><font size="2"> fact with a </font><font size="2" face="Courier New">"Denied"</font><font size="2"> reason. At this point I would expect that the original </font><font size="2" face="Courier New">ApplicantStatus</font><font size="2"> fact, with an </font><font size="2" face="Courier New">"Approved"</font><font size="2"> reason, would be retracted, since the conditions under which it was inserted are no lon! ger true.
<div class="Ih2E3d"><p>This is not what I am observing, however. I am finding </p></div></font><div class="Ih2E3d"><font size="2" face="Courier New">ApplicantStatus</font><font size="2"> facts with both reasons in working memory at the end of the rules run. Should "not" work as I expect with regard to inserting a fact via </font><font size="2" face="Courier New">insertLogical()</font><font size="2">? Or is this a known limitation, or simply the way it is designed to work?
<p>Thanks,</p>
<p>-Hans</p></font></div></div></div><div class="Ih2E3d"><br>_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org" target="_blank">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></div></blockquote></div><br><br clear="all"><br><div class="Ih2E3d">-- <br>Edson Tirelli<br>
JBoss Drools Core Development<br>JBoss, a division of Red Hat @ <a href="http://www.jboss.com/" target="_blank">www.jboss.com</a><br></div></div></blockquote></div></div>
<br><br>---------- Mensagem encaminhada ----------<br>From: <a href="mailto:ringsah@comcast.net">ringsah@comcast.net</a><br>To: Rules Users List <<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>><br>
Date: Mon, 04 Aug 2008 13:49:37 +0000<br>Subject: Re: [rules-users] "Not" Non-Existential Quantifier<br><br><br>---------- Mensagem encaminhada ----------<br>From: "Edson Tirelli" <<a href="mailto:tirelli@post.com">tirelli@post.com</a>><br>
To: "Rules Users List" <<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>><br>Date: Thu, 31 Jul 2008 17:41:39 +0000<br>Subject: Re: [rules-users] "Not" Non-Existential Quantifier<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></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>
</div>