use of io.automatiko.engine.workflow.compiler.xml.ProcessBuildData in project automatiko-engine by automatiko-io.
the class MessageHandler method start.
@SuppressWarnings("unchecked")
public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
parser.startElementBuilder(localName, attrs);
String id = attrs.getValue("id");
String itemRef = attrs.getValue("itemRef");
String name = attrs.getValue("name");
if (name == null) {
name = id;
}
Map<String, ItemDefinition> itemDefinitions = (Map<String, ItemDefinition>) ((ProcessBuildData) parser.getData()).getMetaData("ItemDefinitions");
if (itemDefinitions == null) {
throw new IllegalArgumentException("No item definitions found");
}
ItemDefinition itemDefinition = itemDefinitions.get(itemRef);
if (itemDefinition == null) {
throw new IllegalArgumentException("Could not find itemDefinition " + itemRef);
}
ProcessBuildData buildData = (ProcessBuildData) parser.getData();
Map<String, Message> messages = (Map<String, Message>) ((ProcessBuildData) parser.getData()).getMetaData("Messages");
if (messages == null) {
messages = new HashMap<String, Message>();
buildData.setMetaData("Messages", messages);
}
Message message = new Message(id);
message.setType(itemDefinition.getStructureRef());
message.setName(name);
if (message.getType() != null && !message.getType().isEmpty()) {
messages.put(id, message);
}
return message;
}
use of io.automatiko.engine.workflow.compiler.xml.ProcessBuildData in project automatiko-engine by automatiko-io.
the class BoundaryEventHandler method end.
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
final Element element = parser.endElementBuilder();
Node node = (Node) parser.getCurrent();
String attachedTo = element.getAttribute("attachedToRef");
Attr cancelActivityAttr = element.getAttributeNode("cancelActivity");
boolean cancelActivity = true;
if (cancelActivityAttr != null) {
cancelActivity = Boolean.parseBoolean(cancelActivityAttr.getValue());
}
// 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 ("escalationEventDefinition".equals(nodeName)) {
// reuse already created EventNode
handleEscalationNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
node.setMetaData(EVENT_TYPE, "escalation");
break;
} else if ("errorEventDefinition".equals(nodeName)) {
// reuse already created EventNode
handleErrorNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
node.setMetaData(EVENT_TYPE, "error");
break;
} else if ("timerEventDefinition".equals(nodeName)) {
// reuse already created EventNode
handleTimerNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
node.setMetaData(EVENT_TYPE, "timer");
break;
} else if ("compensateEventDefinition".equals(nodeName)) {
// reuse already created EventNode
handleCompensationNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
node.setMetaData(EVENT_TYPE, "compensation");
break;
} else if ("signalEventDefinition".equals(nodeName)) {
// reuse already created EventNode
handleSignalNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
node.setMetaData(EVENT_TYPE, "signal");
break;
} else if ("conditionalEventDefinition".equals(nodeName)) {
handleConditionNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
node.setMetaData(EVENT_TYPE, "condition");
break;
} else if ("messageEventDefinition".equals(nodeName)) {
handleMessageNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
node.setMetaData(EVENT_TYPE, "message");
break;
}
xmlNode = xmlNode.getNextSibling();
}
node.setMetaData("DataOutputs", new LinkedHashMap<String, String>(dataOutputTypes));
NodeContainer nodeContainer = (NodeContainer) parser.getParent();
nodeContainer.addNode(node);
((ProcessBuildData) parser.getData()).addNode(node);
return node;
}
use of io.automatiko.engine.workflow.compiler.xml.ProcessBuildData in project automatiko-engine by automatiko-io.
the class AbstractNodeHandler method findSignalByName.
protected Signal findSignalByName(ExtensibleXmlParser parser, String signalName) {
ProcessBuildData buildData = ((ProcessBuildData) parser.getData());
Set<String> signalNames = (Set<String>) buildData.getMetaData(SIGNAL_NAMES);
if (signalNames == null) {
signalNames = new HashSet<>();
buildData.setMetaData(SIGNAL_NAMES, signalNames);
}
signalNames.add(signalName);
Map<String, Signal> signals = (Map<String, Signal>) buildData.getMetaData("Signals");
if (signals != null) {
return signals.get(signalName);
}
return null;
}
use of io.automatiko.engine.workflow.compiler.xml.ProcessBuildData in project automatiko-engine by automatiko-io.
the class AbstractNodeHandler method readMultiInstanceLoopCharacteristics.
@SuppressWarnings("unchecked")
protected void readMultiInstanceLoopCharacteristics(org.w3c.dom.Node xmlNode, ForEachNode forEachNode, ExtensibleXmlParser parser) {
// sourceRef
org.w3c.dom.Node subNode = xmlNode.getFirstChild();
while (subNode != null) {
String nodeName = subNode.getNodeName();
if ("inputDataItem".equals(nodeName)) {
String variableName = ((Element) subNode).getAttribute("name");
if (variableName == null || variableName.isEmpty()) {
variableName = ((Element) subNode).getAttribute("id");
}
String itemSubjectRef = ((Element) subNode).getAttribute("itemSubjectRef");
DataType dataType = null;
Map<String, ItemDefinition> itemDefinitions = (Map<String, ItemDefinition>) ((ProcessBuildData) parser.getData()).getMetaData("ItemDefinitions");
dataType = getDataType(itemSubjectRef, itemDefinitions, parser.getClassLoader());
if (variableName != null && variableName.trim().length() > 0) {
forEachNode.setMetaData("MIInput", ((Element) subNode).getAttribute("id"));
forEachNode.setVariable(variableName, dataType);
}
} else if ("outputDataItem".equals(nodeName)) {
String variableName = ((Element) subNode).getAttribute("name");
if (variableName == null || variableName.isEmpty()) {
variableName = ((Element) subNode).getAttribute("id");
}
String itemSubjectRef = ((Element) subNode).getAttribute("itemSubjectRef");
DataType dataType = null;
Map<String, ItemDefinition> itemDefinitions = (Map<String, ItemDefinition>) ((ProcessBuildData) parser.getData()).getMetaData("ItemDefinitions");
dataType = getDataType(itemSubjectRef, itemDefinitions, parser.getClassLoader());
if (variableName != null && variableName.trim().length() > 0) {
forEachNode.setMetaData("MIOutput", ((Element) subNode).getAttribute("id"));
forEachNode.setOutputVariable(variableName, dataType);
}
} else if ("loopDataOutputRef".equals(nodeName)) {
String outputDataRef = ((Element) subNode).getTextContent();
if (outputDataRef != null && outputDataRef.trim().length() > 0) {
String collectionName = outputAssociation.get(outputDataRef);
if (collectionName == null) {
collectionName = dataOutputs.get(outputDataRef);
}
forEachNode.setOutputCollectionExpression(collectionName);
}
forEachNode.setMetaData("MICollectionOutput", outputDataRef);
} else if ("loopDataInputRef".equals(nodeName)) {
String inputDataRef = ((Element) subNode).getTextContent();
if (inputDataRef != null && inputDataRef.trim().length() > 0) {
String collectionName = inputAssociation.get(inputDataRef);
if (collectionName == null) {
collectionName = dataInputs.get(inputDataRef);
}
forEachNode.setCollectionExpression(collectionName);
}
forEachNode.setMetaData("MICollectionInput", inputDataRef);
} else if (COMPLETION_CONDITION.equals(nodeName)) {
String expression = subNode.getTextContent();
forEachNode.setCompletionConditionExpression(expression);
String language = ((Element) subNode).getAttribute("language");
forEachNode.setExpressionLang(language);
}
subNode = subNode.getNextSibling();
}
}
use of io.automatiko.engine.workflow.compiler.xml.ProcessBuildData 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;
}
Aggregations