Search in sources :

Example 1 with ProcessBuildData

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();
    }
}
Also used : FaultNode(io.automatiko.engine.workflow.process.core.node.FaultNode) ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) Error(io.automatiko.engine.workflow.bpmn2.core.Error) NodeList(org.w3c.dom.NodeList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with ProcessBuildData

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();
    }
}
Also used : FaultNode(io.automatiko.engine.workflow.process.core.node.FaultNode) ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) Escalation(io.automatiko.engine.workflow.bpmn2.core.Escalation) Map(java.util.Map)

Example 3 with ProcessBuildData

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;
}
Also used : ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) Escalation(io.automatiko.engine.workflow.bpmn2.core.Escalation) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with ProcessBuildData

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;
}
Also used : ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) ArrayList(java.util.ArrayList) List(java.util.List) Interface(io.automatiko.engine.workflow.bpmn2.core.Interface)

Example 5 with ProcessBuildData

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;
}
Also used : CatchLinkNode(io.automatiko.engine.workflow.process.core.node.CatchLinkNode) ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) Element(org.w3c.dom.Element) TimerNode(io.automatiko.engine.workflow.process.core.node.TimerNode) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) CatchLinkNode(io.automatiko.engine.workflow.process.core.node.CatchLinkNode) Node(io.automatiko.engine.workflow.process.core.Node) StateNode(io.automatiko.engine.workflow.process.core.node.StateNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) StateNode(io.automatiko.engine.workflow.process.core.node.StateNode) NodeContainer(io.automatiko.engine.workflow.process.core.NodeContainer) TimerNode(io.automatiko.engine.workflow.process.core.node.TimerNode)

Aggregations

ProcessBuildData (io.automatiko.engine.workflow.compiler.xml.ProcessBuildData)32 Map (java.util.Map)14 Element (org.w3c.dom.Element)13 Node (io.automatiko.engine.workflow.process.core.Node)11 NodeContainer (io.automatiko.engine.workflow.process.core.NodeContainer)10 HashMap (java.util.HashMap)9 List (java.util.List)8 ItemDefinition (io.automatiko.engine.workflow.bpmn2.core.ItemDefinition)6 ForEachNode (io.automatiko.engine.workflow.process.core.node.ForEachNode)6 ArrayList (java.util.ArrayList)6 Escalation (io.automatiko.engine.workflow.bpmn2.core.Escalation)4 ActionNode (io.automatiko.engine.workflow.process.core.node.ActionNode)4 ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)4 Error (io.automatiko.engine.workflow.bpmn2.core.Error)3 Message (io.automatiko.engine.workflow.bpmn2.core.Message)3 Signal (io.automatiko.engine.workflow.bpmn2.core.Signal)3 ConsequenceAction (io.automatiko.engine.workflow.process.core.impl.ConsequenceAction)3 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)3 WorkItemNode (io.automatiko.engine.workflow.process.core.node.WorkItemNode)3 Process (io.automatiko.engine.api.definition.process.Process)2