use of io.automatiko.engine.workflow.process.core.node.ActionNode in project automatiko-engine by automatiko-io.
the class ActionNodeHandler method handleNode.
public void handleNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
super.handleNode(node, element, uri, localName, parser);
ActionNode actionNode = (ActionNode) node;
org.w3c.dom.Node xmlNode = element.getFirstChild();
if (xmlNode instanceof Element) {
Element actionXml = (Element) xmlNode;
ProcessAction action = extractAction(actionXml);
actionNode.setAction(action);
}
}
use of io.automatiko.engine.workflow.process.core.node.ActionNode in project automatiko-engine by automatiko-io.
the class ProcessHandler method handleIntermediateOrEndThrowCompensationEvent.
protected void handleIntermediateOrEndThrowCompensationEvent(ExtendedNodeImpl throwEventNode) {
if (throwEventNode.getMetaData("compensation-activityRef") != null) {
String activityRef = (String) throwEventNode.getMetaData().remove("compensation-activityRef");
NodeContainer nodeParent = (NodeContainer) throwEventNode.getParentContainer();
if (nodeParent instanceof EventSubProcessNode) {
boolean compensationEventSubProcess = false;
List<Trigger> startTriggers = ((EventSubProcessNode) nodeParent).findStartNode().getTriggers();
CESP_CHECK: for (Trigger trigger : startTriggers) {
if (trigger instanceof EventTrigger) {
for (EventFilter filter : ((EventTrigger) trigger).getEventFilters()) {
if (((EventTypeFilter) filter).getType().equals("Compensation")) {
compensationEventSubProcess = true;
break CESP_CHECK;
}
}
}
}
if (compensationEventSubProcess) {
// BPMN2 spec, p. 252, p. 248: intermediate and end compensation event
// visibility scope
nodeParent = (NodeContainer) ((NodeImpl) nodeParent).getParentContainer();
}
}
String parentId;
if (nodeParent instanceof ExecutableProcess) {
parentId = ((ExecutableProcess) nodeParent).getId();
} else {
parentId = (String) ((NodeImpl) nodeParent).getMetaData("UniqueId");
}
String compensationEvent;
if (activityRef.length() == 0) {
// general/implicit compensation
compensationEvent = CompensationScope.IMPLICIT_COMPENSATION_PREFIX + parentId;
} else {
// specific compensation
compensationEvent = activityRef;
}
throwEventNode.setMetaData("CompensationEvent", compensationEvent);
ConsequenceAction compensationAction = new ConsequenceAction("java", "");
compensationAction.setMetaData("Action", new ProcessInstanceCompensationAction(compensationEvent));
if (throwEventNode instanceof ActionNode) {
((ActionNode) throwEventNode).setAction(compensationAction);
} else if (throwEventNode instanceof EndNode) {
List<ProcessAction> actions = new ArrayList<ProcessAction>();
actions.add(compensationAction);
((EndNode) throwEventNode).setActions(EndNode.EVENT_NODE_ENTER, actions);
}
throwEventNode.setMetaData("TriggerType", "Compensation");
}
}
use of io.automatiko.engine.workflow.process.core.node.ActionNode in project automatiko-engine by automatiko-io.
the class IntermediateThrowEventHandler method handleSignalNode.
public void handleSignalNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
ActionNode actionNode = (ActionNode) node;
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("dataInput".equals(nodeName)) {
String id = ((Element) xmlNode).getAttribute("id");
String inputName = ((Element) xmlNode).getAttribute("name");
dataInputs.put(id, inputName);
} else if ("dataInputAssociation".equals(nodeName)) {
readDataInputAssociation(xmlNode, actionNode, parser);
} else if ("signalEventDefinition".equals(nodeName)) {
String signalName = ((Element) xmlNode).getAttribute("signalRef");
String variable = findVariable((String) actionNode.getMetaData(MAPPING_VARIABLE_KEY), parser);
signalName = checkSignalAndConvertToRealSignalNam(parser, signalName);
actionNode.setMetaData("EventType", "signal");
actionNode.setMetaData("Ref", signalName);
actionNode.setMetaData("Variable", variable);
actionNode.setMetaData("TriggerType", "Signal");
// check if signal should be send async
if (dataInputs.containsValue("async")) {
signalName = "ASYNC-" + signalName;
}
ConsequenceAction action = createJavaAction(new SignalProcessInstanceAction(signalName, variable, (String) actionNode.getMetaData("customScope"), (Transformation) actionNode.getMetaData().get(TRANSFORMATION_KEY)));
actionNode.setAction(action);
}
xmlNode = xmlNode.getNextSibling();
}
}
use of io.automatiko.engine.workflow.process.core.node.ActionNode in project automatiko-engine by automatiko-io.
the class IntermediateThrowEventHandler method end.
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
final Element element = parser.endElementBuilder();
ActionNode node = (ActionNode) parser.getCurrent();
// determine type of event definition, so the correct type of node
// can be generated
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("signalEventDefinition".equals(nodeName)) {
// reuse already created ActionNode
handleSignalNode(node, element, uri, localName, parser);
node.setMetaData("functionFlowContinue", "true");
break;
} else if ("messageEventDefinition".equals(nodeName)) {
// reuse already created ActionNode
handleMessageNode(node, element, uri, localName, parser);
node.setMetaData("functionFlowContinue", "true");
break;
} else if ("escalationEventDefinition".equals(nodeName)) {
// reuse already created ActionNode
handleEscalationNode(node, element, uri, localName, parser);
node.setMetaData("functionFlowContinue", "true");
break;
} else if ("compensateEventDefinition".equals(nodeName)) {
// reuse already created ActionNode
handleThrowCompensationEventNode(node, element, uri, localName, parser);
node.setMetaData("functionFlowContinue", "true");
break;
} else if ("linkEventDefinition".equals(nodeName)) {
ThrowLinkNode linkNode = new ThrowLinkNode();
linkNode.setId(node.getId());
handleLinkNode(element, linkNode, xmlNode, parser);
NodeContainer nodeContainer = (NodeContainer) parser.getParent();
nodeContainer.addNode(linkNode);
((ProcessBuildData) parser.getData()).addNode(node);
// we break the while and stop the execution of this method.
return linkNode;
}
xmlNode = xmlNode.getNextSibling();
}
// none event definition
if (node.getAction() == null) {
node.setAction(new ConsequenceAction("mvel", ""));
node.setMetaData("NodeType", "IntermediateThrowEvent-None");
}
NodeContainer nodeContainer = (NodeContainer) parser.getParent();
nodeContainer.addNode(node);
return node;
}
use of io.automatiko.engine.workflow.process.core.node.ActionNode in project automatiko-engine by automatiko-io.
the class ScriptTaskHandler method createNode.
protected Node createNode(Attributes attrs) {
ActionNode result = new ActionNode();
result.setAction(new ConsequenceAction());
return result;
}
Aggregations