use of io.automatiko.engine.workflow.process.core.NodeContainer 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.NodeContainer in project automatiko-engine by automatiko-io.
the class IntermediateThrowEventHandler method handleLinkNode.
protected void handleLinkNode(Element element, Node node, org.w3c.dom.Node xmlLinkNode, ExtensibleXmlParser parser) {
node.setName(element.getAttribute("name"));
NamedNodeMap linkAttr = xmlLinkNode.getAttributes();
String name = linkAttr.getNamedItem("name").getNodeValue();
String id = element.getAttribute("id");
node.setMetaData("UniqueId", id);
node.setMetaData(LINK_NAME, name);
org.w3c.dom.Node xmlNode = xmlLinkNode.getFirstChild();
NodeContainer nodeContainer = (NodeContainer) parser.getParent();
IntermediateLink aLink = new IntermediateLink();
aLink.setName(name);
aLink.setUniqueId(id);
while (null != xmlNode) {
String nodeName = xmlNode.getNodeName();
if (LINK_TARGET.equals(nodeName)) {
String target = xmlNode.getTextContent();
node.setMetaData(LINK_TARGET, target);
}
if (LINK_SOURCE.equals(nodeName)) {
String source = xmlNode.getTextContent();
ArrayList<String> sources = (ArrayList<String>) node.getMetaData().get(LINK_SOURCE);
// if there is no list, create one
if (null == sources) {
sources = new ArrayList<String>();
}
// to connect nodes.
aLink.addSource(source);
// to do the xml dump
sources.add(source);
node.setMetaData(LINK_SOURCE, sources);
}
xmlNode = xmlNode.getNextSibling();
}
aLink.configureThrow();
if (nodeContainer instanceof ExecutableProcess) {
ExecutableProcess process = (ExecutableProcess) nodeContainer;
List<IntermediateLink> links = (List<IntermediateLink>) process.getMetaData().get(ProcessHandler.LINKS);
if (null == links) {
links = new ArrayList<IntermediateLink>();
}
links.add(aLink);
process.setMetaData(ProcessHandler.LINKS, links);
} else if (nodeContainer instanceof CompositeNode) {
CompositeNode subprocess = (CompositeNode) nodeContainer;
List<IntermediateLink> links = (List<IntermediateLink>) subprocess.getMetaData().get(ProcessHandler.LINKS);
if (null == links) {
links = new ArrayList<IntermediateLink>();
}
links.add(aLink);
subprocess.setMetaData(ProcessHandler.LINKS, links);
}
}
use of io.automatiko.engine.workflow.process.core.NodeContainer in project automatiko-engine by automatiko-io.
the class CallActivityHandler method end.
@SuppressWarnings("unchecked")
@Override
public Object end(String uri, String localName, ExtensibleXmlParser parser) throws SAXException {
final Element element = parser.endElementBuilder();
Node node = (Node) parser.getCurrent();
handleNode(node, element, uri, localName, parser);
org.w3c.dom.Node xmlNode = element.getFirstChild();
int uniqueIdGen = 1;
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("multiInstanceLoopCharacteristics".equals(nodeName)) {
// create new timerNode
ForEachNode forEachNode = new ForEachNode();
forEachNode.setId(node.getId());
String uniqueId = (String) node.getMetaData().get("UniqueId");
forEachNode.setMetaData("UniqueId", uniqueId);
node.setMetaData("UniqueId", uniqueId + ":" + uniqueIdGen++);
node.setMetaData("hidden", true);
forEachNode.addNode(node);
forEachNode.linkIncomingConnections(NodeImpl.CONNECTION_DEFAULT_TYPE, node.getId(), NodeImpl.CONNECTION_DEFAULT_TYPE);
forEachNode.linkOutgoingConnections(node.getId(), NodeImpl.CONNECTION_DEFAULT_TYPE, NodeImpl.CONNECTION_DEFAULT_TYPE);
forEachNode.setSequential(Boolean.parseBoolean(((Element) xmlNode).getAttribute("isSequential")));
Node orignalNode = node;
node = forEachNode;
handleForEachNode(node, element, uri, localName, parser);
// running in variable strict mode
if (orignalNode instanceof SubProcessNode) {
adjustNodeConfiguration(orignalNode, forEachNode);
}
Map<String, String> dataInputs = (Map<String, String>) orignalNode.getMetaData().remove("DataInputs");
Map<String, String> dataOutputs = (Map<String, String>) orignalNode.getMetaData().remove("DataOutputs");
orignalNode.setMetaData("MICollectionOutput", dataOutputs.get(((ForEachNode) node).getMetaData("MICollectionOutput")));
orignalNode.setMetaData("MICollectionInput", dataInputs.get(((ForEachNode) node).getMetaData("MICollectionInput")));
break;
}
xmlNode = xmlNode.getNextSibling();
}
NodeContainer nodeContainer = (NodeContainer) parser.getParent();
nodeContainer.addNode(node);
((ProcessBuildData) parser.getData()).addNode(node);
return node;
}
use of io.automatiko.engine.workflow.process.core.NodeContainer in project automatiko-engine by automatiko-io.
the class DefinitionsHandler method postProcessInterfaces.
private void postProcessInterfaces(NodeContainer nodeContainer, List<Interface> interfaces) {
for (Node node : nodeContainer.getNodes()) {
if (node instanceof NodeContainer) {
postProcessInterfaces((NodeContainer) node, interfaces);
}
if (node instanceof WorkItemNode && "Service Task".equals(((WorkItemNode) node).getMetaData("Type"))) {
WorkItemNode workItemNode = (WorkItemNode) node;
if (interfaces == null) {
throw new IllegalArgumentException("No interfaces found");
}
String operationRef = (String) workItemNode.getMetaData("OperationRef");
String implementation = (String) workItemNode.getMetaData("Implementation");
Operation operation = null;
for (Interface i : interfaces) {
operation = i.getOperation(operationRef);
if (operation != null) {
break;
}
}
if (operation == null) {
throw new IllegalArgumentException("Could not find operation " + operationRef);
}
// avoid overriding parameters set by data input associations
if (workItemNode.getWork().getParameter("Interface") == null) {
workItemNode.getWork().setParameter("Interface", operation.getInterface().getName());
}
if (workItemNode.getWork().getParameter("Operation") == null) {
workItemNode.getWork().setParameter("Operation", operation.getName());
}
if (workItemNode.getWork().getParameter("ParameterType") == null && operation.getMessage() != null) {
workItemNode.getWork().setParameter("ParameterType", operation.getMessage().getType());
}
// parameters to support web service invocation
if (implementation != null) {
workItemNode.getWork().setParameter("interfaceImplementationRef", operation.getInterface().getImplementationRef());
workItemNode.getWork().setParameter("operationImplementationRef", operation.getImplementationRef());
workItemNode.getWork().setParameter("implementation", implementation);
}
}
}
}
use of io.automatiko.engine.workflow.process.core.NodeContainer in project automatiko-engine by automatiko-io.
the class BoundaryEventHandler method handleCompensationNode.
protected void handleCompensationNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser, final String attachedTo, final boolean cancelActivity) throws SAXException {
BoundaryEventNode eventNode = (BoundaryEventNode) parser.getCurrent();
super.handleNode(node, element, uri, localName, parser);
NodeList childs = element.getChildNodes();
for (int i = 0; i < childs.getLength(); i++) {
if (childs.item(i) instanceof Element) {
Element el = (Element) childs.item(i);
if ("compensateEventDefinition".equalsIgnoreCase(el.getNodeName())) {
String activityRef = el.getAttribute("activityRef");
if (activityRef != null && activityRef.length() > 0) {
logger.warn("activityRef value [" + activityRef + "] on Boundary Event '" + eventNode.getMetaData("UniqueId") + "' ignored per the BPMN2 specification.");
}
}
}
}
eventNode.setMetaData("AttachedTo", attachedTo);
eventNode.setAttachedToNodeId(attachedTo);
// 1. Find the parent (sub-)process
NodeContainer parentContainer = (NodeContainer) parser.getParent();
// 2. Add the event filter (never fires, purely for dumping purposes)
EventTypeFilter eventFilter = new NonAcceptingEventTypeFilter();
eventFilter.setType("Compensation");
List<EventFilter> eventFilters = new ArrayList<EventFilter>();
eventNode.setEventFilters(eventFilters);
eventFilters.add(eventFilter);
// 3. Add compensation scope (with key/id: attachedTo)
ProcessHandler.addCompensationScope((ExecutableProcess) parser.getParent(ExecutableProcess.class), eventNode, parentContainer, attachedTo);
}
Aggregations