Search in sources :

Example 1 with XmlProcessReader

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

the class BpmnProcessCompiler method parse.

public List<Process> parse(ProcessConfig config, Resource... resources) {
    try {
        List<Process> processes = new ArrayList<>();
        XmlProcessReader xmlReader = new XmlProcessReader(getSemanticModules(), Thread.currentThread().getContextClassLoader());
        configureProcessReader(xmlReader, config);
        for (Resource resource : resources) {
            processes.addAll(xmlReader.read(resource.getReader()));
        }
        return processes;
    } catch (Exception e) {
        throw new BpmnProcessReaderException(e);
    }
}
Also used : XmlProcessReader(io.automatiko.engine.workflow.compiler.xml.XmlProcessReader) ArrayList(java.util.ArrayList) Resource(io.automatiko.engine.api.io.Resource) WorkflowProcess(io.automatiko.engine.workflow.process.core.WorkflowProcess) Process(io.automatiko.engine.api.definition.process.Process)

Example 2 with XmlProcessReader

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

the class BpmnProcessCompiler method from.

public List<BpmnProcess> from(ProcessConfig config, Resource... resources) {
    try {
        List<Process> processes = new ArrayList<>();
        for (Resource resource : resources) {
            XmlProcessReader xmlReader = new XmlProcessReader(getSemanticModules(), Thread.currentThread().getContextClassLoader());
            configureProcessReader(xmlReader, config);
            processes.addAll(xmlReader.read(resource.getReader()));
        }
        List<BpmnProcess> bpmnProcesses = processes.stream().map(p -> create(p, config)).filter(p -> p != null).collect(Collectors.toList());
        bpmnProcesses.forEach(p -> {
            for (Node node : ((WorkflowProcess) p.process()).getNodesRecursively()) {
                processNode(node, bpmnProcesses);
            }
        });
        return (List<BpmnProcess>) bpmnProcesses;
    } catch (Exception e) {
        throw new BpmnProcessReaderException(e);
    }
}
Also used : SubProcessNode(io.automatiko.engine.workflow.process.core.node.SubProcessNode) SemanticModule(io.automatiko.engine.workflow.compiler.xml.SemanticModule) SemanticModules(io.automatiko.engine.workflow.compiler.xml.SemanticModules) XmlProcessReader(io.automatiko.engine.workflow.compiler.xml.XmlProcessReader) ProcessConfig(io.automatiko.engine.api.workflow.ProcessConfig) Collectors(java.util.stream.Collectors) BPMNSemanticModule(io.automatiko.engine.workflow.bpmn2.xml.BPMNSemanticModule) Node(io.automatiko.engine.api.definition.process.Node) ArrayList(java.util.ArrayList) Resource(io.automatiko.engine.api.io.Resource) List(java.util.List) BPMNDISemanticModule(io.automatiko.engine.workflow.bpmn2.xml.BPMNDISemanticModule) WorkflowProcess(io.automatiko.engine.workflow.process.core.WorkflowProcess) Process(io.automatiko.engine.api.definition.process.Process) BPMNExtensionsSemanticModule(io.automatiko.engine.workflow.bpmn2.xml.BPMNExtensionsSemanticModule) XmlProcessReader(io.automatiko.engine.workflow.compiler.xml.XmlProcessReader) SubProcessNode(io.automatiko.engine.workflow.process.core.node.SubProcessNode) Node(io.automatiko.engine.api.definition.process.Node) ArrayList(java.util.ArrayList) Resource(io.automatiko.engine.api.io.Resource) WorkflowProcess(io.automatiko.engine.workflow.process.core.WorkflowProcess) Process(io.automatiko.engine.api.definition.process.Process) ArrayList(java.util.ArrayList) List(java.util.List) WorkflowProcess(io.automatiko.engine.workflow.process.core.WorkflowProcess)

Example 3 with XmlProcessReader

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

the class ProcessCodegen method parseProcessFile.

private static Collection<? extends Process> parseProcessFile(Resource r) {
    try {
        XmlProcessReader xmlReader = new XmlProcessReader(BPMN_SEMANTIC_MODULES, Thread.currentThread().getContextClassLoader());
        Collection<? extends Process> parsed = xmlReader.read(r.getReader());
        parsed.forEach(p -> p.setResource(r));
        return parsed;
    } catch (SAXException | IOException e) {
        throw new ProcessParsingException("Could not parse file " + r.getSourcePath(), e);
    }
}
Also used : XmlProcessReader(io.automatiko.engine.workflow.compiler.xml.XmlProcessReader) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException)

Example 4 with XmlProcessReader

use of io.automatiko.engine.workflow.compiler.xml.XmlProcessReader 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)

Aggregations

XmlProcessReader (io.automatiko.engine.workflow.compiler.xml.XmlProcessReader)4 Process (io.automatiko.engine.api.definition.process.Process)3 Resource (io.automatiko.engine.api.io.Resource)2 SemanticModules (io.automatiko.engine.workflow.compiler.xml.SemanticModules)2 WorkflowProcess (io.automatiko.engine.workflow.process.core.WorkflowProcess)2 ArrayList (java.util.ArrayList)2 Node (io.automatiko.engine.api.definition.process.Node)1 WorkflowProcess (io.automatiko.engine.api.definition.process.WorkflowProcess)1 ProcessConfig (io.automatiko.engine.api.workflow.ProcessConfig)1 BPMNDISemanticModule (io.automatiko.engine.workflow.bpmn2.xml.BPMNDISemanticModule)1 BPMNExtensionsSemanticModule (io.automatiko.engine.workflow.bpmn2.xml.BPMNExtensionsSemanticModule)1 BPMNSemanticModule (io.automatiko.engine.workflow.bpmn2.xml.BPMNSemanticModule)1 SemanticModule (io.automatiko.engine.workflow.compiler.xml.SemanticModule)1 SubProcessNode (io.automatiko.engine.workflow.process.core.node.SubProcessNode)1 ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 UncheckedIOException (java.io.UncheckedIOException)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1