<!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>
Hi Alessandro, just saw your e-mail and answered to you, but
basically no-loop will not work for cases like this.<br>
Either specify your constraints in a way they prevent the loop or
use lock-on-active.<br>
<br>
rule "Nota final das questoes"
<br>
when
<br>
$qr : QuestionarioResposta( $nf : notaFinal )
<br>
$result : Number( this != $nf )
<br>
from accumulate(
QuestaoResposta($nota:nota,$peso:questao.questaoPeso.peso)
<br>
from $qr.questoesResposta,
<br>
sum( $nota * (Double)$peso )
) then
<br>
modify( $qr ) {
<br>
setNotaFinal($result)
<br>
}
<br>
end<br>
<br>
Hope it helps.<br>
Edson<br>
<br>
<br>
<div class="gmail_quote">2008/5/5 Alessandro Lazarotti <<a
moz-do-not-send="true" href="mailto:alessandro@siq.com.br">alessandro@siq.com.br</a>>:<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>
no-loop true<br>
when<br>
<br>
questionarioResposta : QuestionarioResposta()<br>
<br>
$resultFinal : Number() from
accumulate(QuestaoResposta($peso:questao.questaoPeso.peso)<br>
from
questionarioResposta.getQuestoesResposta(),<br>
sum( $peso ))<br>
then<br>
System.out.println($resultFinal);<br>
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>
no-loop true<br>
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>
questionarioResposta : QuestionarioResposta()<br>
$result : Number() from<br>
accumulate(QuestaoResposta($nota:nota,$peso:questao.questaoPeso.peso)
from
questionarioResposta.getQuestoesResposta(),
sum($nota * (Double)$peso))<br>
$resultFinal :
Number() from<br>
accumulate(QuestaoResposta($nota:nota,$peso:questao.questaoPeso.peso)
from
questionarioResposta.getQuestoesResposta(),
sum( $peso ))
then<br>
System.out.println($result.doubleValue() /
$resultFinal.doubleValue());
questionarioResposta.setNotaFinal($result.doubleValue() /<br>
$resultFinal.doubleValue());<br>
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>