Dan Seaver wrote:
There is the command GetGlobal, that you can execute at the end, it takes an out identifier. That should solve your prolbem.So, I'd like to have a ruleset that returns true or false. The way I set that up in one of the version 5 candidate releases is to use a Boolean global and use drools.getWorkingMemory().setGlobal("result", new Boolean(false)) to change the value of the global. I could then access the updated value in the code by using the old style getGlobal.However in version 5 Final release, the global value changes fine within the ruleset, but is not updated when I access it via ExecResults. I imagine the reason for this is that immutable variables are handled differently in the final release than in the candidate release, but need to know whether this is by design.
Mark
Here is the RuleSet I'm using: package BooleanTest global Boolean result rule "Initialize" salience -1 whenthen drools.getWorkingMemory().setGlobal("result", new Boolean(false));System.out.println("Initialized result to false"); end rule "Display result" salience -2 when then System.out.println("result is " + result); end Here is the pertinent code: cmds.add(CommandFactory.newSetGlobal("result", null, true)); ExecutionResults execResults = ksession.execute(CommandFactory .newBatchExecution(cmds)); for (String identifier : execResults.getIdentifiers()) { System.out.format(String.format("Identifier: %s, Value: %s \n", identifier, execResults.getValue(identifier))); } Here is the output: Initialized result to false result is false Identifier: result, Value: null
_______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
