<div>Look at this unit test for some examples:</div><div><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>
</div><div><br></div><div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// Retrieve the generated fact type</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;FactType cheeseFact = ruleBase.getFactType( &quot;org.drools.generatedbeans.Cheese&quot; );</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// Create a new Fact instance</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Object cheese = cheeseFact.newInstance();</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// Set a field value using the more verbose method chain...</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// should we add short cuts?</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// &nbsp; &nbsp; &nbsp; &nbsp;cheeseFact.getField( &quot;type&quot; ).getFieldAccessor().setValue( cheese,</div>
<div>&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; &quot;stilton&quot; );</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;cheeseFact.set( cheese,</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&quot;type&quot;,</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&quot;stilton&quot; );</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;assertEquals( &quot;stilton&quot;,</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cheeseFact.get( cheese,</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&quot;type&quot; ) );</div></div><br><br><div class="gmail_quote">On Tue, Jan 27, 2009 at 2:02 AM, Oleg Zenzin <span dir="ltr">&lt;<a href="mailto:zenzin@intalio.com">zenzin@intalio.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><p>There&#39;s now possibility to declare facts in the drl, like:<br></p><p><font face="courier new,monospace">declare Person<br>
&nbsp;name: String<br>&nbsp;age: int<br>end</font><br></p><p>My question is how do I instantiate this fact object during runtime? Do I still need to have class <font face="courier new,monospace">Person</font> compiled and existing somewhere in classpath, or there&#39;s a helper class which I can use &quot;fake the fact&quot;, something like:</p>

<p><font face="courier new,monospace">&nbsp; FakeFact person = FakeFact(&quot;Person&quot;);<br>&nbsp; person.setField(&quot;name&quot;, &quot;Oleg&quot;);<br>&nbsp; person.setField(&quot;age&quot;, &quot;42&quot;);<br>&nbsp; session.insert(person);</font></p>

<p>Or there&#39;s another nicer way?<br><br></p><p>Thank you,<br>-Oleg Zenzin<br></p>
<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>
<br></blockquote></div><br>