I have a decision table with multiple imports of the same type: be.example.Person . One person is the offender, the other person is the legal guardian.
This is the start of the decision table:
The compilation of the decision table is succesfull, however at runtime, it does not give back the expected result. The way I insert my facts for the decision table is as follows:
StatefulKnowledgeSession ksession = null;
try {
ksession = ruleEngine.createStatelessKnowledgeSession();
ksession.setGlobal("result", result);
ksession.insert(offender);
ksession.insert(legalGuardian);
ksession.fireAllRules(1);
} finally {
if(Controles.isRenseignee(ksession)) {
ksession.dispose();
}
}
It seems that when I fire the rules, drools seems to insert the objects 2 times as p:Person and not as: the first one is p:Person and the second one is q:Person.
Or to put it otherwise, the execution seems to be like:
- Execute rule1 with offender as p:Person
- Execute rule1 with legalGuardian as p:Person
- Execute rule2 with offender as p:Person
- Execute rule2 with legalGuardian as p:Person
Whereas, I would have expected it to behave like:
- Execute rule1 with offender as p:Person and legalGuardian as q:Person.
- Execute rule2 with legalGuardian as p:Person and legalGuardian as q:Person.
Does drools not support this kind of functionality? In the past we used similar decision tables where the type of objects where different and that seemed to work fine. But in this case, with the objects being of the same type it doesn,'t.
Anyone has an idea if it's not possible or if I'm injecting the objects in an incorrect way?
The version of drools being used is 5.5.0.Final.
offender
orlegalGuardian
, Drools is not aware of the meaning of these names. Also, apart from the semantic conclusion that you wouldn't testalreadyConvicted
for a potential guardian there is nothing in the rule which would make Drools separate the bad from the good. – laune