use of io.automatiko.engine.workflow.compiler.xml.ProcessBuildData in project automatiko-engine by automatiko-io.
the class EndEventHandler method handleErrorNode.
@SuppressWarnings("unchecked")
public void handleErrorNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
FaultNode faultNode = (FaultNode) node;
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("dataInputAssociation".equals(nodeName)) {
readFaultDataInputAssociation(xmlNode, faultNode);
} else if ("errorEventDefinition".equals(nodeName)) {
String errorRef = ((Element) xmlNode).getAttribute("errorRef");
if (errorRef != null && errorRef.trim().length() > 0) {
List<Error> errors = (List<Error>) ((ProcessBuildData) parser.getData()).getMetaData("Errors");
if (errors == null) {
throw new IllegalArgumentException("No errors found");
}
Error error = null;
for (Error listError : errors) {
if (errorRef.equals(listError.getId())) {
error = listError;
break;
}
}
if (error == null) {
throw new IllegalArgumentException("Could not find error " + errorRef);
}
faultNode.setFaultName(error.getErrorCode());
faultNode.setTerminateParent(true);
}
}
xmlNode = xmlNode.getNextSibling();
}
}
use of io.automatiko.engine.workflow.compiler.xml.ProcessBuildData in project automatiko-engine by automatiko-io.
the class EndEventHandler method handleEscalationNode.
@SuppressWarnings("unchecked")
public void handleEscalationNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
FaultNode faultNode = (FaultNode) node;
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("dataInputAssociation".equals(nodeName)) {
readFaultDataInputAssociation(xmlNode, faultNode);
} else if ("escalationEventDefinition".equals(nodeName)) {
String escalationRef = ((Element) xmlNode).getAttribute("escalationRef");
if (escalationRef != null && escalationRef.trim().length() > 0) {
Map<String, Escalation> escalations = (Map<String, Escalation>) ((ProcessBuildData) parser.getData()).getMetaData(ProcessHandler.ESCALATIONS);
if (escalations == null) {
throw new IllegalArgumentException("No escalations found");
}
Escalation escalation = escalations.get(escalationRef);
if (escalation == null) {
throw new IllegalArgumentException("Could not find escalation " + escalationRef);
}
faultNode.setFaultName(escalation.getEscalationCode());
} else {
// are _required_ to reference a specific escalation(-code).
throw new IllegalArgumentException("End events throwing an escalation must throw *specific* escalations (and not general ones).");
}
}
xmlNode = xmlNode.getNextSibling();
}
}
use of io.automatiko.engine.workflow.compiler.xml.ProcessBuildData in project automatiko-engine by automatiko-io.
the class EscalationHandler 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 escalationCode = attrs.getValue("escalationCode");
ProcessBuildData buildData = (ProcessBuildData) parser.getData();
Map<String, Escalation> escalations = (Map<String, Escalation>) buildData.getMetaData(ProcessHandler.ESCALATIONS);
if (escalations == null) {
escalations = new HashMap<String, Escalation>();
buildData.setMetaData(ProcessHandler.ESCALATIONS, escalations);
}
Escalation e = new Escalation(id, escalationCode);
escalations.put(id, e);
return e;
}
use of io.automatiko.engine.workflow.compiler.xml.ProcessBuildData in project automatiko-engine by automatiko-io.
the class InterfaceHandler 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 name = attrs.getValue("name");
String implRef = attrs.getValue("implementationRef");
if (name == null || name.isEmpty()) {
throw new MalformedNodeException(id, name, "interface name is a required attribute");
}
ProcessBuildData buildData = (ProcessBuildData) parser.getData();
List<Interface> interfaces = (List<Interface>) buildData.getMetaData("Interfaces");
if (interfaces == null) {
interfaces = new ArrayList<Interface>();
buildData.setMetaData("Interfaces", interfaces);
}
Interface i = new Interface(id, name);
if (implRef != null) {
i.setImplementationRef(implRef);
}
interfaces.add(i);
return i;
}
use of io.automatiko.engine.workflow.compiler.xml.ProcessBuildData in project automatiko-engine by automatiko-io.
the class IntermediateCatchEventHandler 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
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("signalEventDefinition".equals(nodeName)) {
// reuse already created EventNode
handleSignalNode(node, element, uri, localName, parser);
node.setMetaData(EVENT_TYPE, "signal");
node.setMetaData("functionFlowContinue", "true");
break;
} else if ("messageEventDefinition".equals(nodeName)) {
// reuse already created EventNode
handleMessageNode(node, element, uri, localName, parser);
node.setMetaData(EVENT_TYPE, "message");
node.setMetaData("functionFlowContinue", "true");
break;
} else if ("timerEventDefinition".equals(nodeName)) {
// create new timerNode
TimerNode timerNode = new TimerNode();
timerNode.setId(node.getId());
timerNode.setName(node.getName());
timerNode.setMetaData("UniqueId", node.getMetaData().get("UniqueId"));
node = timerNode;
node.setMetaData(EVENT_TYPE, "timer");
handleTimerNode(node, element, uri, localName, parser);
node.setMetaData("functionFlowContinue", "true");
break;
} else if ("conditionalEventDefinition".equals(nodeName)) {
// create new stateNode
StateNode stateNode = new StateNode();
stateNode.setId(node.getId());
stateNode.setName(node.getName());
stateNode.setMetaData("UniqueId", node.getMetaData().get("UniqueId"));
node = stateNode;
node.setMetaData(EVENT_TYPE, "conditional");
handleStateNode(node, element, uri, localName, parser);
node.setMetaData("functionFlowContinue", "true");
break;
} else if ("linkEventDefinition".equals(nodeName)) {
CatchLinkNode linkNode = new CatchLinkNode();
linkNode.setId(node.getId());
node = linkNode;
node.setMetaData(EVENT_TYPE, "link");
handleLinkNode(element, node, xmlNode, parser);
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;
}
Aggregations