[rules-dev] is there a way to get "declare"s out of the working memory?

strug strug at web.de
Sat Oct 17 16:15:58 EDT 2009


Thanks for open my eyes. I guess it was too late yesterday:)

I read the documentation but still got a problem. Is it possible to retrieve
a declared type without inserting it previously?

None of my tries work out.

Try a)

No query and trying to get at the fact after the rules were fired. With
session.getObjects I see that my declared type is in, but I did not find out
which API to use to get on it. How I get the fact handle of this declared
type?

Try b)

I query - as usual - a fact and try to make the declared type know to
drools:

  String query = "import platform.calculations;" +
                      "query \"calc total dri amount\"\n" +
                      "  totalDriAmount: TotalDriAmount()\n" +
                      "end";
  ..
  builder.add(another-drl-file..)
  builder.add(ResourceFactory.newReaderResource(new StringReader(query)),
ResourceType.DRL);
  ..
  statefulSession.fireAllRules();
 
  FactType factType = ruleBase.getFactType("platform.calculations",
"TotalDriAmount");

  QueryResults queryResults = statefulSession.getQueryResults("calc total
dri amount");

  for (QueryResultsRow result : queryResults) {
    Object totalDriAmount = result.get("totalDriAmount");
    FMoney amount = (FMoney) factType.get( totalDriAmount, "amount" );
    FPerson person = (FPerson) factType.get( totalDriAmount, "ownedBy" );
  }

Unfortunately while building the knowledgebase I got this error:
Unable to resolve ObjectType 'TotalDriAmount' : [Rule name='calc total dri
amount']


Any idea?
Thanks in advance, Leif 
-- 
View this message in context: http://www.nabble.com/is-there-a-way-to-get-%22declare%22s-out-of-the-working-memory--tp25933286p25941458.html
Sent from the drools - dev mailing list archive at Nabble.com.



More information about the rules-dev mailing list