forEachNode, Node.CONNECTION_DEFAULT_TYPE,
endNode, Node.CONNECTION_DEFAULT_TYPE
);
final List<String> myList = new ArrayList<String>();
ActionNode actionNode = new ActionNode();
actionNode.setName("Print child");
DroolsAction action = new DroolsConsequenceAction("java", null);
action.setMetaData("Action", new Action() {
public void execute(KnowledgeHelper knowledgeHelper, WorkingMemory workingMemory, ProcessContext context) throws Exception {
System.out.println("Executed action for child " + ((Person) context.getVariable("child")).getName());
myList.add("Executed action");
}
});
actionNode.setAction(action);
forEachNode.addNode(actionNode);
forEachNode.linkIncomingConnections(
Node.CONNECTION_DEFAULT_TYPE,
actionNode.getId(), Node.CONNECTION_DEFAULT_TYPE);
forEachNode.linkOutgoingConnections(
actionNode.getId(), Node.CONNECTION_DEFAULT_TYPE,
Node.CONNECTION_DEFAULT_TYPE);
forEachNode.setVariable("child", personDataType);
AbstractRuleBase ruleBase = (AbstractRuleBase) RuleBaseFactory.newRuleBase();
ruleBase.addProcess(process);