<br><a href="http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-expert/html_single/index.html#d0e3614">http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-expert/html_single/index.html#d0e3614</a><br>
<br><a href="http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java">http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java</a><br>
<br><pre> public void testGeneratedBeans1()</pre><br>   Edson<br><br><div class="gmail_quote">2009/10/16 leif hanack <span dir="ltr">&lt;<a href="mailto:leif.hanack@hypoport.de">leif.hanack@hypoport.de</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>
since Drools 5 it is possible to define a dynamic variable holder by<br>
using the declare notation. This feature is really cool.<br>
I can create easily helper rules, that calculate temporary values:<br>
<br>
File: calculate_total_amount.drl<br>
<br>
declare TotalAmount<br>
  amount : Money<br>
end<br>
<br>
rule &quot;calculate total amount&quot;<br>
  when<br>
    ..<br>
  then<br>
    TotalAmount totalAmount = new TotalAmount();<br>
    totalAmount.setAmount($calculatedAmount);<br>
    insert(totalAmount);<br>
end<br>
<br>
Inside another file I use this helper.<br>
<br>
File: another_rule.drl<br>
<br>
rule &quot;another rule&quot;<br>
  when<br>
    TotalAmount( amount &gt; 1000)<br>
  then<br>
     // do <a href="http://s.th" target="_blank">s.th</a>.<br>
end<br>
<br>
I unit test my rule by querying a fact and verify my assertions. This<br>
works fine, as long as the fact is a class of my factmodel.<br>
Now my question: Is there a way to query a declared class (in this<br>
case TotalAmount)<br>
<br>
I tried it with some variations but without success:<br>
<br>
import my.package.of.the.rule;<br>
query &quot;get total amount&quot;<br>
  amount : TotalAmount()<br>
end<br>
<br>
I thought that a declare is compiled to a class, but I can not find it<br>
in the generated classes.<br>
Did you have any help?<br>
<br>
An alternative might be to create a holder class. S.th. like that<br>
<br>
rule &quot;calculate total amount&quot;<br>
  ..<br>
  then<br>
    TotalAmount totalAmount = new TotalAmount();<br>
    totalAmount.setAmount($calculatedAmount);<br>
    insert(totalAmount);<br>
    Holder holder = new Holder();<br>
    holder.setObject(totalAmount);<br>
    insert(holder);<br>
end<br>
<br>
<br>
import my.package.holder;<br>
query &quot;get holder&quot;<br>
  holder : Holder()<br>
end<br>
<br>
Thanks in advance, Leif<br>
_______________________________________________<br>
rules-dev mailing list<br>
<a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>  Edson Tirelli<br>  JBoss Drools Core Development<br>  JBoss by Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>