Search in sources :

Example 26 with ProcessBuildData

use of io.automatiko.engine.workflow.compiler.xml.ProcessBuildData in project automatiko-engine by automatiko-io.

the class ScriptTaskHandler 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
    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++);
            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);
            // remove input/output collection data input/output of for each to avoid problems when running in variable strict mode
            if (orignalNode instanceof ActionNode) {
                adjustNodeConfiguration(orignalNode, forEachNode);
            }
            break;
        }
        xmlNode = xmlNode.getNextSibling();
    }
    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) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) Node(io.automatiko.engine.workflow.process.core.Node) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) NodeContainer(io.automatiko.engine.workflow.process.core.NodeContainer)

Example 27 with ProcessBuildData

use of io.automatiko.engine.workflow.compiler.xml.ProcessBuildData in project automatiko-engine by automatiko-io.

the class SignalHandler 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);
    // according to the (Semantic.)xsd, both the name and structureRef are optional
    String id = attrs.getValue("id");
    // referred to by the signalEventDefinition.signalRef attr
    String name = attrs.getValue("name");
    String structureRef = attrs.getValue("structureRef");
    ProcessBuildData buildData = (ProcessBuildData) parser.getData();
    Map<String, Signal> signals = (Map<String, Signal>) buildData.getMetaData("Signals");
    if (signals == null) {
        signals = new HashMap<String, Signal>();
        buildData.setMetaData("Signals", signals);
    }
    Signal s = new Signal(id, name, structureRef);
    signals.put(id, s);
    return s;
}
Also used : Signal(io.automatiko.engine.workflow.bpmn2.core.Signal) ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) HashMap(java.util.HashMap) Map(java.util.Map)

Example 28 with ProcessBuildData

use of io.automatiko.engine.workflow.compiler.xml.ProcessBuildData in project automatiko-engine by automatiko-io.

the class BPMNPlaneHandler method end.

public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    parser.endElementBuilder();
    ProcessInfo processInfo = (ProcessInfo) parser.getCurrent();
    List<Process> processes = ((ProcessBuildData) parser.getData()).getProcesses();
    ExecutableProcess process = null;
    for (Process p : processes) {
        if (p.getId() != null && p.getId().equals(processInfo.getProcessRef())) {
            process = (ExecutableProcess) p;
            break;
        }
    }
    if (process != null) {
        for (NodeInfo nodeInfo : processInfo.getNodeInfos()) {
            processNodeInfo(nodeInfo, process.getNodes());
        }
        postProcessNodeOffset(process.getNodes(), 0, 0);
        for (ConnectionInfo connectionInfo : processInfo.getConnectionInfos()) {
            if (connectionInfo.getBendpoints() != null) {
                processConnectionInfo(connectionInfo, process.getNodes());
            }
        }
    }
    return processInfo;
}
Also used : ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) NodeInfo(io.automatiko.engine.workflow.bpmn2.xml.di.BPMNShapeHandler.NodeInfo) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) Process(io.automatiko.engine.api.definition.process.Process) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) ConnectionInfo(io.automatiko.engine.workflow.bpmn2.xml.di.BPMNEdgeHandler.ConnectionInfo)

Example 29 with ProcessBuildData

use of io.automatiko.engine.workflow.compiler.xml.ProcessBuildData in project automatiko-engine by automatiko-io.

the class SubProcessHandler 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
    boolean found = false;
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("multiInstanceLoopCharacteristics".equals(nodeName)) {
            Boolean isAsync = Boolean.parseBoolean((String) node.getMetaData().get("customAsync"));
            // create new timerNode
            ForEachNode forEachNode = new ForEachNode();
            forEachNode.setId(node.getId());
            forEachNode.setName(node.getName());
            forEachNode.setSequential(Boolean.parseBoolean(((Element) xmlNode).getAttribute("isSequential")));
            forEachNode.setAutoComplete(((CompositeContextNode) node).isAutoComplete());
            // for (io.automatiko.engine.api.definition.process.Node subNode : ((CompositeContextNode) node)
            // .getNodes()) {
            // 
            // forEachNode.addNode(subNode);
            // }
            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.setMetaData("UniqueId", ((CompositeContextNode) node).getMetaData("UniqueId"));
            // forEachNode.setMetaData(ProcessHandler.CONNECTIONS,
            // ((CompositeContextNode) node).getMetaData(ProcessHandler.CONNECTIONS));
            VariableScope v = (VariableScope) ((CompositeContextNode) node).getDefaultContext(VariableScope.VARIABLE_SCOPE);
            // ((VariableScope) ((CompositeContextNode) forEachNode.internalGetNode(2))
            // .getDefaultContext(VariableScope.VARIABLE_SCOPE)).setVariables(v.getVariables());
            List<SequenceFlow> connections = (List<SequenceFlow>) ((CompositeContextNode) node).getMetaData(ProcessHandler.CONNECTIONS);
            ProcessHandler processHandler = new ProcessHandler();
            processHandler.linkConnections((io.automatiko.engine.api.definition.process.NodeContainer) node, connections);
            processHandler.linkBoundaryEvents((io.automatiko.engine.api.definition.process.NodeContainer) node);
            node = forEachNode;
            handleForEachNode(node, element, uri, localName, parser, isAsync);
            found = true;
            break;
        }
        xmlNode = xmlNode.getNextSibling();
    }
    if (!found) {
        handleCompositeContextNode(node, element, uri, localName, parser);
    }
    NodeContainer nodeContainer = (NodeContainer) parser.getParent();
    nodeContainer.addNode(node);
    ((ProcessBuildData) parser.getData()).addNode(node);
    return node;
}
Also used : SequenceFlow(io.automatiko.engine.workflow.bpmn2.core.SequenceFlow) Element(org.w3c.dom.Element) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) CompositeContextNode(io.automatiko.engine.workflow.process.core.node.CompositeContextNode) StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) Node(io.automatiko.engine.workflow.process.core.Node) NodeContainer(io.automatiko.engine.workflow.process.core.NodeContainer) ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) List(java.util.List) VariableScope(io.automatiko.engine.workflow.base.core.context.variable.VariableScope)

Example 30 with ProcessBuildData

use of io.automatiko.engine.workflow.compiler.xml.ProcessBuildData in project automatiko-engine by automatiko-io.

the class TaskHandler method handleNode.

protected void handleNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    super.handleNode(node, element, uri, localName, parser);
    itemDefinitions = (Map<String, ItemDefinition>) ((ProcessBuildData) parser.getData()).getMetaData("ItemDefinitions");
    dataTypeInputs.clear();
    dataTypeOutputs.clear();
    WorkItemNode workItemNode = (WorkItemNode) node;
    String name = getTaskName(element);
    Work work = new WorkImpl();
    work.setName(name);
    workItemNode.setWork(work);
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("ioSpecification".equals(nodeName)) {
            readIoSpecification(xmlNode, dataInputs, dataOutputs, dataInputTypes);
        } else if ("dataInputAssociation".equals(nodeName)) {
            readDataInputAssociation(xmlNode, workItemNode, dataInputs);
        } else if ("dataOutputAssociation".equals(nodeName)) {
            readDataOutputAssociation(xmlNode, workItemNode, dataOutputs);
        }
        xmlNode = xmlNode.getNextSibling();
    }
    workItemNode.setMetaData("DataInputs", new LinkedHashMap<String, String>(dataTypeInputs));
    workItemNode.setMetaData("DataOutputs", new LinkedHashMap<String, String>(dataTypeOutputs));
    handleScript(workItemNode, element, "onEntry");
    handleScript(workItemNode, element, "onExit");
    String compensation = element.getAttribute("isForCompensation");
    if (compensation != null) {
        boolean isForCompensation = Boolean.parseBoolean(compensation);
        if (isForCompensation) {
            workItemNode.setMetaData("isForCompensation", isForCompensation);
        }
    }
    for (Entry<String, String> entryInputTypes : dataTypeInputs.entrySet()) {
        ParameterDefinition parameterDefinition = new ParameterDefinitionImpl();
        parameterDefinition.setName(entryInputTypes.getKey());
        parameterDefinition.setType(new ObjectDataType(constructClass(entryInputTypes.getValue()), entryInputTypes.getValue()));
        work.addParameterDefinition(parameterDefinition);
    }
}
Also used : ItemDefinition(io.automatiko.engine.workflow.bpmn2.core.ItemDefinition) ObjectDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType) ParameterDefinitionImpl(io.automatiko.engine.workflow.base.core.impl.ParameterDefinitionImpl) ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) Work(io.automatiko.engine.workflow.base.core.Work) WorkImpl(io.automatiko.engine.workflow.base.core.impl.WorkImpl) ParameterDefinition(io.automatiko.engine.workflow.base.core.ParameterDefinition)

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