Search in sources :

Example 16 with ProcessBuildData

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

Example 17 with ProcessBuildData

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

Example 18 with ProcessBuildData

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

Example 19 with ProcessBuildData

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();
    }
}
Also used : ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) Element(org.w3c.dom.Element) ItemDefinition(io.automatiko.engine.workflow.bpmn2.core.ItemDefinition) DataType(io.automatiko.engine.api.workflow.datatype.DataType) ObjectDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType) FloatDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.FloatDataType) IntegerDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.IntegerDataType) BooleanDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.BooleanDataType) StringDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.StringDataType) HashMap(java.util.HashMap) Map(java.util.Map)

Example 20 with ProcessBuildData

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

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