views:

260

answers:

1

Hello,

Our team is using Drools ruleflows for evaluations. Now we are planning to migrate to decision tables instead.

In the Drools ruleflow version, we used to have DRL files that have query component to extract objects created within the context of DRL files from working memory.

I'm stuck on doing the same in Decision Table? We are using StatefulSession for firing rules. Also, these facts are inserted in the RHS of the rules; we do not have have the FactHandles at the time of firing them.

The code used to bootstrap Drools rule engine is as follows:

RuleBase ruleBase = RuleBaseFactory.newRuleBase();
StatefulSession session = ruleBase.newStatefulSession(); 
MyFacts nmrs = new MyFacts();
session.insert(nmrs);
session.fireAllRules();

The drools file used to retrieve query looked as follows:

query "resultQuery"
    response :  Outcome()
end

Thanks

A: 

There is no direct support for queries in XLS decision tables at this time. However, decision tables compile down to drl itself - so it is possible to programmatically add queries after the fact to the drl (perhaps in a separate DRL file).

You can also get a collection of all fact handles and (ugly) iterate through looking for instanceof Outcome, etc...

Michael Neale
When I try to add query as addPackageFromDRL in package builder with StringReader(queryString), it fails for some reason. I've to do an ugly hack of prepending to the last rule file
Maddy