new ConnectionImpl(
startNode, Node.CONNECTION_DEFAULT_TYPE,
milestoneNode, Node.CONNECTION_DEFAULT_TYPE
);
EndNode endNode = new EndNode();
endNode.setName("EndNode");
endNode.setId(3);
process.addNode(endNode);
new ConnectionImpl(
milestoneNode, Node.CONNECTION_DEFAULT_TYPE,
endNode, Node.CONNECTION_DEFAULT_TYPE
);
EventNode eventNode = new EventNode();
EventTypeFilter eventFilter = new EventTypeFilter();
eventFilter.setType("myEvent");
eventNode.addEventFilter(eventFilter);
eventNode.setVariableName("event");
eventNode.setId(4);
process.addNode(eventNode);
final List<String> myList = new ArrayList<String>();
ActionNode actionNode = new ActionNode();
actionNode.setName("Print");
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("Detected event for person " + ((Person) context.getVariable("event")).getName());
myList.add("Executed action");
}
});
actionNode.setAction(action);
actionNode.setId(5);
process.addNode(actionNode);
new ConnectionImpl(
eventNode, Node.CONNECTION_DEFAULT_TYPE,
actionNode, Node.CONNECTION_DEFAULT_TYPE
);
EndNode endNode2 = new EndNode();
endNode2.setName("EndNode");
endNode2.setTerminate(false);
endNode2.setId(6);
process.addNode(endNode2);
new ConnectionImpl(
actionNode, Node.CONNECTION_DEFAULT_TYPE,
endNode2, Node.CONNECTION_DEFAULT_TYPE
);