use of io.automatiko.engine.workflow.compiler.xml.ProcessBuildData 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.compiler.xml.ProcessBuildData in project automatiko-engine by automatiko-io.
the class DefinitionsHandler method end.
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
final Element element = parser.endElementBuilder();
Definitions definitions = (Definitions) parser.getCurrent();
String namespace = element.getAttribute("targetNamespace");
List<Process> processes = ((ProcessBuildData) parser.getData()).getProcesses();
Map<String, ItemDefinition> itemDefinitions = (Map<String, ItemDefinition>) ((ProcessBuildData) parser.getData()).getMetaData("ItemDefinitions");
List<Interface> interfaces = (List<Interface>) ((ProcessBuildData) parser.getData()).getMetaData("Interfaces");
for (Process process : processes) {
ExecutableProcess ruleFlowProcess = (ExecutableProcess) process;
ruleFlowProcess.setMetaData("TargetNamespace", namespace);
postProcessItemDefinitions(ruleFlowProcess, itemDefinitions, parser.getClassLoader());
postProcessInterfaces(ruleFlowProcess, interfaces);
postProcessNodes(ruleFlowProcess, Collections.emptyList(), parser);
}
definitions.setTargetNamespace(namespace);
return definitions;
}
use of io.automatiko.engine.workflow.compiler.xml.ProcessBuildData in project automatiko-engine by automatiko-io.
the class EndEventHandler method handleMessageNode.
@SuppressWarnings("unchecked")
public void handleMessageNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
EndNode endNode = (EndNode) node;
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("dataInputAssociation".equals(nodeName)) {
readEndDataInputAssociation(xmlNode, endNode);
} else if ("messageEventDefinition".equals(nodeName)) {
String messageRef = ((Element) xmlNode).getAttribute("messageRef");
Map<String, Message> messages = (Map<String, Message>) ((ProcessBuildData) parser.getData()).getMetaData("Messages");
if (messages == null) {
throw new IllegalArgumentException("No messages found");
}
Message message = messages.get(messageRef);
if (message == null) {
throw new IllegalArgumentException("Could not find message " + messageRef);
}
String variable = (String) endNode.getMetaData("MappingVariable");
endNode.setMetaData("MessageType", message.getType());
endNode.setMetaData("TriggerType", "ProduceMessage");
endNode.setMetaData("TriggerRef", message.getName());
for (Entry<String, Object> entry : message.getMetaData().entrySet()) {
endNode.setMetaData(entry.getKey(), entry.getValue());
}
List<ProcessAction> actions = new ArrayList<ProcessAction>();
ConsequenceAction action = createJavaAction(new HandleMessageAction(message.getType(), variable));
actions.add(action);
endNode.setActions(EndNode.EVENT_NODE_ENTER, actions);
}
xmlNode = xmlNode.getNextSibling();
}
}
use of io.automatiko.engine.workflow.compiler.xml.ProcessBuildData in project automatiko-engine by automatiko-io.
the class EndEventHandler 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();
// determine type of event definition, so the correct type of node
// can be generated
super.handleNode(node, element, uri, localName, parser);
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("terminateEventDefinition".equals(nodeName)) {
// reuse already created EndNode
handleTerminateNode(node, element, uri, localName, parser);
node.setMetaData("functionFlowContinue", "true");
break;
} else if ("signalEventDefinition".equals(nodeName)) {
handleSignalNode(node, element, uri, localName, parser);
node.setMetaData("functionFlowContinue", "true");
} else if ("messageEventDefinition".equals(nodeName)) {
handleMessageNode(node, element, uri, localName, parser);
node.setMetaData("functionFlowContinue", "true");
} else if ("errorEventDefinition".equals(nodeName)) {
// create new faultNode
FaultNode faultNode = new FaultNode();
faultNode.setId(node.getId());
faultNode.setName(node.getName());
faultNode.setTerminateParent(true);
faultNode.setMetaData("UniqueId", node.getMetaData().get("UniqueId"));
node = faultNode;
super.handleNode(node, element, uri, localName, parser);
handleErrorNode(node, element, uri, localName, parser);
node.setMetaData("functionFlowContinue", "true");
break;
} else if ("escalationEventDefinition".equals(nodeName)) {
// create new faultNode
FaultNode faultNode = new FaultNode();
faultNode.setId(node.getId());
faultNode.setName(node.getName());
faultNode.setMetaData("UniqueId", node.getMetaData().get("UniqueId"));
node = faultNode;
super.handleNode(node, element, uri, localName, parser);
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;
}
xmlNode = xmlNode.getNextSibling();
}
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 ErrorHandler 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 errorCode = attrs.getValue("errorCode");
String structureRef = attrs.getValue("structureRef");
Definitions definitions = (Definitions) parser.getParent();
List<Error> errors = definitions.getErrors();
if (errors == null) {
errors = new ArrayList<Error>();
definitions.setErrors(errors);
((ProcessBuildData) parser.getData()).setMetaData("Errors", errors);
}
Error e = new Error(id, errorCode, structureRef);
errors.add(e);
return e;
}
Aggregations