Reputation: 65
I create a DRL file as below -
rule 'CHECK_AGE_LIMIT'
when
$payroll : Payroll();
Participant(null != dob, $dob : dob);
Plan(null!= eligibilityAge, $eligibilityAge:eligibilityAge);
eval (!(Period.between($dob, LocalDate.now()).getYears() > $eligibilityAge))
then
Result $result = new Result(false, "Age Eligibility Not Met");
insert( $result );
end
How can I access the result from the calling Java class.
This is how I call the DRL -
commands.add(CommandFactory.newFireAllRules());
commands.add(CommandFactory.newGetObjects(GET_OBJECTS_KEY));
ExecutionResults executionResults = kSession.execute(CommandFactory.newBatchExecution(commands));
While I can access all the Facts that I passed on to the DRL, I cant seem to find a way to access, how to Access result.
I know that I can just pass Result as a fact to the DRL. Just want to understand if there's a way to access something that is created inside the DRL.
Upvotes: 0
Views: 341
Reputation: 936
I believe the getObjectsCommands is a way to go. Please make sure you are passing proper filter - it seems you are passing String into getObjectsCommand constructor, which is specifying "output-identifier" and not the filter. Here is an example, which should be compatible with your use case:
ObjectFilter filter = new ObjectFilter() {
@Override
public boolean accept(Object object) {
if (object instanceof Result) {
return true;
}
return false;
}
};
commands.add(CommandFactory.newGetObjects(filter));
Upvotes: 1