<!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">
Ok Edson, it's working fine now!<br>
<br>
Thanks<br>
Alesssandro<br>
<br>
<br>
Edson Tirelli escreveu:
<blockquote
 cite="mid:e6dd5ba30805050953l341740ccx542c4e14c319f2a6@mail.gmail.com"
 type="cite"><br>
&nbsp;&nbsp;&nbsp; Hi Alessandro, just saw your e-mail and answered to you, but
basically no-loop will not work for cases like this.<br>
&nbsp;&nbsp;&nbsp; Either specify your constraints in a way they prevent the loop or
use lock-on-active.<br>
  <br>
rule "Nota final das questoes"
  <br>
&nbsp;&nbsp; when
  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $qr : QuestionarioResposta( $nf : notaFinal )
  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $result : Number( this != $nf )
  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from accumulate(
QuestaoResposta($nota:nota,$peso:questao.questaoPeso.peso)
  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from $qr.questoesResposta,
  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sum( $nota * (Double)$peso )
)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; then
  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; modify( $qr ) {
  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setNotaFinal($result)
  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
  <br>
end<br>
  <br>
&nbsp;&nbsp;&nbsp; Hope it helps.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Edson<br>
&nbsp; <br>
  <br>
  <div class="gmail_quote">2008/5/5 Alessandro Lazarotti &lt;<a
 moz-do-not-send="true" href="mailto:alessandro@siq.com.br">alessandro@siq.com.br</a>&gt;:<br>
  <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">It's
a bug?<br>
    <font color="#888888"><br>
Alessandro Lazarotti escreveu:</font>
    <div>
    <div class="Wj3C7c"><br>
    <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Sorry, my code is ugly in last email...<br>
This is more clean:<br>
      <br>
rule "The Rule"<br>
&nbsp; no-loop true<br>
&nbsp; when<br>
      <br>
&nbsp; &nbsp; &nbsp; questionarioResposta : QuestionarioResposta()<br>
      <br>
&nbsp; &nbsp; &nbsp; &nbsp;$resultFinal : Number() from
accumulate(QuestaoResposta($peso:questao.questaoPeso.peso)<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;from
questionarioResposta.getQuestoesResposta(),<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sum( $peso ))<br>
&nbsp; then<br>
&nbsp; &nbsp; &nbsp; System.out.println($resultFinal);<br>
&nbsp; &nbsp; &nbsp; update( questionarioResposta );<br>
end<br>
      <br>
This is a recursive and no-loop is ignored.<br>
Who knows why this?<br>
      <br>
Thanks<br>
      <br>
      <br>
      <br>
      <br>
      <br>
      <br>
      <br>
      <br>
      <br>
Alessandro Lazarotti escreveu:<br>
      <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi<br>
When I use accumulate and update, no-loop is ignored and the rule is<br>
recursive.<br>
Why?<br>
        <br>
The Rule:<br>
        <br>
rule "Nota final das questoes"<br>
&nbsp; &nbsp;no-loop true<br>
&nbsp; &nbsp;when<br>
      </blockquote>
      <br>
      <br>
      <br>
      <br>
      <br>
      <br>
      <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
        <br>
&nbsp; &nbsp; &nbsp; &nbsp;questionarioResposta : QuestionarioResposta()<br>
&nbsp; &nbsp; &nbsp; &nbsp;$result : Number() from<br>
accumulate(QuestaoResposta($nota:nota,$peso:questao.questaoPeso.peso) &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; from
questionarioResposta.getQuestoesResposta(), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum($nota * (Double)$peso))<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$resultFinal :
Number() from<br>
accumulate(QuestaoResposta($nota:nota,$peso:questao.questaoPeso.peso) &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; from
questionarioResposta.getQuestoesResposta(), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum( $peso )) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;then<br>
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println($result.doubleValue() /
$resultFinal.doubleValue()); &nbsp; &nbsp; &nbsp; &nbsp;
questionarioResposta.setNotaFinal($result.doubleValue() /<br>
$resultFinal.doubleValue());<br>
&nbsp; &nbsp; &nbsp; &nbsp;update( questionarioResposta );<br>
end<br>
        <br>
_______________________________________________<br>
rules-users mailing list<br>
        <a moz-do-not-send="true"
 href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
        <a moz-do-not-send="true"
 href="https://lists.jboss.org/mailman/listinfo/rules-users"
 target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
        <br>
      </blockquote>
_______________________________________________<br>
rules-users mailing list<br>
      <a moz-do-not-send="true"
 href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
      <a moz-do-not-send="true"
 href="https://lists.jboss.org/mailman/listinfo/rules-users"
 target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
      <br>
    </blockquote>
_______________________________________________<br>
rules-users mailing list<br>
    <a moz-do-not-send="true" href="mailto:rules-users@lists.jboss.org"
 target="_blank">rules-users@lists.jboss.org</a><br>
    <a moz-do-not-send="true"
 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>
  <br clear="all">
  <br>
-- <br>
Edson Tirelli<br>
JBoss Drools Core Development<br>
Office: +55 11 3529-6000<br>
Mobile: +55 11 9287-5646<br>
JBoss, a division of Red Hat @ <a moz-do-not-send="true"
 href="http://www.jboss.com">www.jboss.com</a>
  <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>
</body>
</html>