<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> // Retrieve the generated fact type</div><div> FactType cheeseFact = ruleBase.getFactType( "org.drools.generatedbeans.Cheese" );</div><div><br></div><div> // Create a new Fact instance</div>
<div> Object cheese = cheeseFact.newInstance();</div><div><br></div><div> // Set a field value using the more verbose method chain...</div><div> // should we add short cuts?</div><div> // cheeseFact.getField( "type" ).getFieldAccessor().setValue( cheese,</div>
<div> // "stilton" );</div><div><br></div><div> cheeseFact.set( cheese,</div><div> "type",</div><div> "stilton" );</div>
<div> assertEquals( "stilton",</div><div> cheeseFact.get( cheese,</div><div> "type" ) );</div></div><br><br><div class="gmail_quote">On Tue, Jan 27, 2009 at 2:02 AM, Oleg Zenzin <span dir="ltr"><<a href="mailto:zenzin@intalio.com">zenzin@intalio.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><p>There's now possibility to declare facts in the drl, like:<br></p><p><font face="courier new,monospace">declare Person<br>
name: String<br> 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's a helper class which I can use "fake the fact", something like:</p>
<p><font face="courier new,monospace"> FakeFact person = FakeFact("Person");<br> person.setField("name", "Oleg");<br> person.setField("age", "42");<br> session.insert(person);</font></p>
<p>Or there'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>