Search in sources :

Example 21 with Process

use of io.automatiko.engine.api.definition.process.Process in project automatiko-engine by automatiko-io.

the class DynamicUtils method executeSubProcess.

private static String executeSubProcess(InternalProcessRuntime runtime, String processId, Map<String, Object> parameters, ProcessInstance processInstance, SubProcessNodeInstance subProcessNodeInstance) {
    Process process = runtime.getProcess(processId);
    if (process == null) {
        logger.error("Could not find process {}", processId);
        throw new IllegalArgumentException("No process definition found with id: " + processId);
    } else {
        ProcessEventSupport eventSupport = runtime.getProcessEventSupport();
        eventSupport.fireBeforeNodeTriggered(subProcessNodeInstance, runtime);
        ProcessInstance subProcessInstance = null;
        if (((WorkflowProcessInstanceImpl) processInstance).getCorrelationKey() != null) {
            List<String> businessKeys = new ArrayList<>();
            businessKeys.add(((WorkflowProcessInstanceImpl) processInstance).getCorrelationKey());
            businessKeys.add(processId);
            businessKeys.add(String.valueOf(System.currentTimeMillis()));
            CorrelationKey subProcessCorrelationKey = new StringCorrelationKey(businessKeys.stream().collect(Collectors.joining(":")));
            subProcessInstance = (ProcessInstance) runtime.createProcessInstance(processId, subProcessCorrelationKey, parameters);
        } else {
            subProcessInstance = (ProcessInstance) runtime.createProcessInstance(processId, parameters);
        }
        ((ProcessInstanceImpl) subProcessInstance).setMetaData("ParentProcessInstanceId", processInstance.getId());
        ((ProcessInstanceImpl) subProcessInstance).setParentProcessInstanceId(processInstance.getId());
        subProcessInstance = (ProcessInstance) runtime.startProcessInstance(subProcessInstance.getId());
        subProcessNodeInstance.internalSetProcessInstanceId(subProcessInstance.getId());
        eventSupport.fireAfterNodeTriggered(subProcessNodeInstance, runtime);
        if (subProcessInstance.getState() == io.automatiko.engine.api.runtime.process.ProcessInstance.STATE_COMPLETED) {
            subProcessNodeInstance.triggerCompleted();
        } else {
            subProcessNodeInstance.addEventListeners();
        }
        return subProcessInstance.getId();
    }
}
Also used : ProcessEventSupport(io.automatiko.engine.workflow.base.core.event.ProcessEventSupport) StringCorrelationKey(io.automatiko.engine.services.correlation.StringCorrelationKey) CorrelationKey(io.automatiko.engine.services.correlation.CorrelationKey) StringCorrelationKey(io.automatiko.engine.services.correlation.StringCorrelationKey) WorkflowProcessInstanceImpl(io.automatiko.engine.workflow.process.instance.impl.WorkflowProcessInstanceImpl) ProcessInstanceImpl(io.automatiko.engine.workflow.base.instance.impl.ProcessInstanceImpl) ArrayList(java.util.ArrayList) WorkflowProcess(io.automatiko.engine.workflow.process.core.WorkflowProcess) Process(io.automatiko.engine.api.definition.process.Process) ProcessInstance(io.automatiko.engine.workflow.base.instance.ProcessInstance) WorkflowProcessInstance(io.automatiko.engine.workflow.process.instance.WorkflowProcessInstance)

Example 22 with Process

use of io.automatiko.engine.api.definition.process.Process 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 Process

use of io.automatiko.engine.api.definition.process.Process in project automatiko-engine by automatiko-io.

the class XmlBPMNProcessDumper method readProcess.

@Override
public Process readProcess(String processXml) {
    SemanticModules semanticModules = new SemanticModules();
    semanticModules.addSemanticModule(new BPMNSemanticModule());
    semanticModules.addSemanticModule(new BPMNExtensionsSemanticModule());
    semanticModules.addSemanticModule(new BPMNDISemanticModule());
    XmlProcessReader xmlReader = new XmlProcessReader(semanticModules, Thread.currentThread().getContextClassLoader());
    try {
        List<Process> processes = xmlReader.read(new StringReader(processXml));
        return processes.get(0);
    } catch (Throwable t) {
        t.printStackTrace();
        return null;
    }
}
Also used : SemanticModules(io.automatiko.engine.workflow.compiler.xml.SemanticModules) XmlProcessReader(io.automatiko.engine.workflow.compiler.xml.XmlProcessReader) StringReader(java.io.StringReader) Process(io.automatiko.engine.api.definition.process.Process) WorkflowProcess(io.automatiko.engine.api.definition.process.WorkflowProcess) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)

Example 24 with Process

use of io.automatiko.engine.api.definition.process.Process in project automatiko-engine by automatiko-io.

the class XmlBPMNProcessDumper method visitHeader.

protected void visitHeader(WorkflowProcess process, StringBuilder xmlDump, int metaDataType) {
    Map<String, Object> metaData = getMetaData(process.getMetaData());
    Set<String> imports = ((io.automatiko.engine.workflow.base.core.Process) process).getImports();
    Map<String, String> globals = ((io.automatiko.engine.workflow.base.core.Process) process).getGlobals();
    if ((imports != null && !imports.isEmpty()) || (globals != null && globals.size() > 0) || !metaData.isEmpty()) {
        xmlDump.append("    <extensionElements>" + EOL);
        if (imports != null) {
            for (String s : imports) {
                xmlDump.append("     <tns:import name=\"" + s + "\" />" + EOL);
            }
        }
        if (globals != null) {
            for (Map.Entry<String, String> global : globals.entrySet()) {
                xmlDump.append("     <tns:global identifier=\"" + global.getKey() + "\" type=\"" + global.getValue() + "\" />" + EOL);
            }
        }
        writeMetaData(getMetaData(process.getMetaData()), xmlDump);
        xmlDump.append("    </extensionElements>" + EOL);
    }
    // TODO: function imports
    // TODO: exception handlers
    VariableScope variableScope = (VariableScope) ((io.automatiko.engine.workflow.base.core.Process) process).getDefaultContext(VariableScope.VARIABLE_SCOPE);
    if (variableScope != null) {
        visitVariables(variableScope.getVariables(), xmlDump);
    }
    visitLanes(process, xmlDump);
}
Also used : Process(io.automatiko.engine.api.definition.process.Process) WorkflowProcess(io.automatiko.engine.api.definition.process.WorkflowProcess) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) Map(java.util.Map) HashMap(java.util.HashMap) VariableScope(io.automatiko.engine.workflow.base.core.context.variable.VariableScope)

Example 25 with Process

use of io.automatiko.engine.api.definition.process.Process 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)

Aggregations

Process (io.automatiko.engine.api.definition.process.Process)28 ArrayList (java.util.ArrayList)15 List (java.util.List)12 ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)11 Map (java.util.Map)10 WorkflowProcess (io.automatiko.engine.api.definition.process.WorkflowProcess)8 IOException (java.io.IOException)8 InternalProcessRuntime (io.automatiko.engine.workflow.base.instance.InternalProcessRuntime)7 WorkflowProcess (io.automatiko.engine.workflow.process.core.WorkflowProcess)7 StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)6 WorkflowProcessInstanceImpl (io.automatiko.engine.workflow.process.instance.impl.WorkflowProcessInstanceImpl)6 UncheckedIOException (java.io.UncheckedIOException)6 HashMap (java.util.HashMap)5 NodeInstance (io.automatiko.engine.api.runtime.process.NodeInstance)4 Variable (io.automatiko.engine.workflow.base.core.context.variable.Variable)4 VariableScope (io.automatiko.engine.workflow.base.core.context.variable.VariableScope)4 ProcessInstance (io.automatiko.engine.workflow.base.instance.ProcessInstance)4 XmlProcessReader (io.automatiko.engine.workflow.compiler.xml.XmlProcessReader)4 Connection (io.automatiko.engine.api.definition.process.Connection)3 Resource (io.automatiko.engine.api.io.Resource)3