Hi Mark,
I want this for a unit test. It will verify that the stateless session contains only expected objects after execution. I don't want to write a new query that will be used only in the unit test.
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.
I've created a custom command for getting the objects. Its execute method looks like this:
public Iterator< ? > execute(ReteooWorkingMemory session) {
Iterator<?> objects = session.iterateObjects( filter );
session.getBatchExecutionResult().getResults().put(identifier, objects);
return objects;
}
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'll pass some insert commands and a query command. However the query will be executed before the fireAllRules call and so it won't return anything.
Michal Bali wrote:You have ot specify what it is you want as an out, either as an 'out' on an inserted fact or global or a query.Hi,
I am trying this on trunk. There is currently no way how to iterate objects in a StatelessKnowledgeSession.
I'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.
I guess it should probably be added to the BatchExecutionResults? It will then be possible to access this collection of objects.
Extend the Query interface and use that to filter the iterator on a returned query.
Please let me know if there is a different way how to iterate over objects in a StatelessKnowledgeSession. I'd like to use an ObjectFilter as well.
Best Regards,
Michal
_______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users