Search in sources :

Example 1 with SemanticModules

use of org.jbpm.compiler.xml.core.SemanticModules in project kogito-runtimes by kiegroup.

the class SemanticKnowledgeBuilderConfigurationImpl method initSemanticModules.

public void initSemanticModules() {
    this.semanticModules = new SemanticModules();
    RulesSemanticModule ruleModule = new RulesSemanticModule("http://ddefault");
    this.semanticModules.addSemanticModule(new WrapperSemanticModule("http://drools.org/drools-5.0", ruleModule));
    this.semanticModules.addSemanticModule(new WrapperSemanticModule("http://drools.org/drools-5.2", ruleModule));
    // split on each space
    String[] locations = getChainedProperties().getProperty("semanticModules", "").split("\\s");
    // load each SemanticModule
    for (String moduleLocation : locations) {
        // trim leading/trailing spaces and quotes
        moduleLocation = moduleLocation.trim();
        if (moduleLocation.startsWith("\"")) {
            moduleLocation = moduleLocation.substring(1);
        }
        if (moduleLocation.endsWith("\"")) {
            moduleLocation = moduleLocation.substring(0, moduleLocation.length() - 1);
        }
        if (!moduleLocation.equals("")) {
            loadSemanticModule(moduleLocation);
        }
    }
}
Also used : SemanticModules(org.jbpm.compiler.xml.core.SemanticModules) WrapperSemanticModule(org.jbpm.compiler.xml.core.WrapperSemanticModule)

Example 2 with SemanticModules

use of org.jbpm.compiler.xml.core.SemanticModules in project kogito-runtimes by kiegroup.

the class TestXml method testSimpleXml.

@Test
public void testSimpleXml() throws Exception {
    SemanticModules modules = new SemanticModules();
    modules.addSemanticModule(new ProcessSemanticModule());
    XmlProcessReader reader = new XmlProcessReader(modules, getClass().getClassLoader());
    reader.read(new InputStreamReader(TestXml.class.getResourceAsStream("XmlTest.xml")));
    List<Process> processes = reader.getProcess();
    assertNotNull(processes);
    assertEquals(1, processes.size());
    RuleFlowProcess process = (RuleFlowProcess) processes.get(0);
    assertNotNull(process);
    String output = XmlRuleFlowProcessDumper.INSTANCE.dump(process);
    logger.info(output);
    reader = new XmlProcessReader(new SemanticModules(), getClass().getClassLoader());
    reader.read(new StringReader(output));
}
Also used : SemanticModules(org.jbpm.compiler.xml.core.SemanticModules) RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) InputStreamReader(java.io.InputStreamReader) StringReader(java.io.StringReader) Process(org.kie.api.definition.process.Process) RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) Test(org.junit.jupiter.api.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 3 with SemanticModules

use of org.jbpm.compiler.xml.core.SemanticModules in project kogito-runtimes by kiegroup.

the class XmlRuleFlowProcessDumper method readProcess.

@Override
public Process readProcess(String processXml) {
    SemanticKnowledgeBuilderConfigurationImpl configuration = new SemanticKnowledgeBuilderConfigurationImpl();
    SemanticModules modules = configuration.getSemanticModules();
    modules.addSemanticModule(new ProcessSemanticModule());
    XmlProcessReader xmlReader = new XmlProcessReader(modules, 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 : SemanticKnowledgeBuilderConfigurationImpl(org.jbpm.compiler.xml.compiler.SemanticKnowledgeBuilderConfigurationImpl) SemanticModules(org.jbpm.compiler.xml.core.SemanticModules) StringReader(java.io.StringReader) WorkflowProcess(org.kie.api.definition.process.WorkflowProcess) Process(org.kie.api.definition.process.Process)

Example 4 with SemanticModules

use of org.jbpm.compiler.xml.core.SemanticModules in project kogito-runtimes by kiegroup.

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(org.jbpm.compiler.xml.core.SemanticModules) XmlProcessReader(org.jbpm.compiler.xml.XmlProcessReader) StringReader(java.io.StringReader) Process(org.kie.api.definition.process.Process) RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) WorkflowProcess(org.kie.api.definition.process.WorkflowProcess)

Aggregations

SemanticModules (org.jbpm.compiler.xml.core.SemanticModules)4 StringReader (java.io.StringReader)3 Process (org.kie.api.definition.process.Process)3 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)2 WorkflowProcess (org.kie.api.definition.process.WorkflowProcess)2 InputStreamReader (java.io.InputStreamReader)1 XmlProcessReader (org.jbpm.compiler.xml.XmlProcessReader)1 SemanticKnowledgeBuilderConfigurationImpl (org.jbpm.compiler.xml.compiler.SemanticKnowledgeBuilderConfigurationImpl)1 WrapperSemanticModule (org.jbpm.compiler.xml.core.WrapperSemanticModule)1 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)1 Test (org.junit.jupiter.api.Test)1