Search in sources :

Example 21 with ProcessBuildData

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;
}
Also used : Element(org.w3c.dom.Element) SubProcessNode(io.automatiko.engine.workflow.process.core.node.SubProcessNode) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) Node(io.automatiko.engine.workflow.process.core.Node) NodeContainer(io.automatiko.engine.workflow.process.core.NodeContainer) ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) SubProcessNode(io.automatiko.engine.workflow.process.core.node.SubProcessNode) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) HashMap(java.util.HashMap) Map(java.util.Map)

Example 22 with ProcessBuildData

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;
}
Also used : Element(org.w3c.dom.Element) Definitions(io.automatiko.engine.workflow.bpmn2.core.Definitions) ItemDefinition(io.automatiko.engine.workflow.bpmn2.core.ItemDefinition) WorkflowProcess(io.automatiko.engine.workflow.process.core.WorkflowProcess) Process(io.automatiko.engine.api.definition.process.Process) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) LinkedList(java.util.LinkedList) List(java.util.List) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) Map(java.util.Map) Interface(io.automatiko.engine.workflow.bpmn2.core.Interface)

Example 23 with ProcessBuildData

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();
    }
}
Also used : ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) Message(io.automatiko.engine.workflow.bpmn2.core.Message) ConsequenceAction(io.automatiko.engine.workflow.process.core.impl.ConsequenceAction) HandleMessageAction(io.automatiko.engine.workflow.base.instance.impl.actions.HandleMessageAction) Entry(java.util.Map.Entry) ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) NodeList(org.w3c.dom.NodeList) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map)

Example 24 with ProcessBuildData

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

Example 25 with ProcessBuildData

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;
}
Also used : ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) Definitions(io.automatiko.engine.workflow.bpmn2.core.Definitions) Error(io.automatiko.engine.workflow.bpmn2.core.Error)

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