Hi Mark,<br><br>I want this for a unit test. It will verify that the stateless session contains only expected objects after execution. I don&#39;t want to write a new query that will be used only in the unit test. <br>

<br>Currently it is possible to iterate over all objects in a StatefulKnowledgeSession through its getObjects method. However it is not supported by default on the StatelessKnowledgeSession.<br><br>I&#39;ve created a custom command for getting the objects. Its execute method looks like this:<br>
public Iterator&lt; ? &gt; execute(ReteooWorkingMemory session) {<br>    Iterator&lt;?&gt; objects = session.iterateObjects( filter );<br>    session.getBatchExecutionResult().getResults().put(identifier, objects);<br>    return objects;<br>
}<br><br>Another thing to note is that StatelessKnowledgeSession.execute(Command command) method first executes all given commands and then calls session.fireAllRules. So if you want to insert some objects and run a query you&#39;ll pass some insert commands and a query command. However the query will be executed before the fireAllRules call and so it won&#39;t return anything.<div>

Alternatively you could pass in a fireAllRules command as well, which will work fine. The fireAllRules will be executed twice but that is not a big deal.<br>Another issue is that the query command makes it difficult to pass in query arguments that are known only after the rules execution. Because you have to specify the query before the fireAllRules execution. I guess you could create your own command and do all logic there but this is not very nice.
<div><br></div><div>Just my 2c.<br><br>Best Regards,<br>Michal<br><br><br><div class="gmail_quote">2009/3/17 Mark Proctor <span dir="ltr">&lt;<a href="mailto:mproctor@codehaus.org" target="_blank">mproctor@codehaus.org</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;">




  

<div bgcolor="#ffffff" text="#000000"><div>
Michal Bali wrote:
<blockquote type="cite">Hi,<br>
  <br>
I am trying this on trunk. There is currently no way how to iterate
objects in a StatelessKnowledgeSession.<br>
  <br>
I&#39;ve tried to use the GetObjectsCommand, however when it is executes
the result is lost in the ether :). The collection of objects is not
handed back to the user.<br>
  <br>
I guess it should probably be added to the BatchExecutionResults? It
will then be possible to access this collection of objects.<br>
</blockquote></div>
You have ot specify what it is you want as an out, either as an &#39;out&#39;
on an inserted fact or global or a query. <br><div>
<blockquote type="cite"><br>
Please let me know if there is a different way how to iterate over
objects in a StatelessKnowledgeSession. I&#39;d like to use an ObjectFilter
as well.<br>
</blockquote></div>
Extend the Query interface and use that to filter the iterator on a
returned query.<br>
<blockquote type="cite"><br>
Best Regards,<br>
Michal<br>
  <pre><hr size="4" width="90%">_______________________________________________
rules-users mailing list
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a>
  </pre>
</blockquote>
<br>
</div>

<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br>
</div></div>