Search in sources :

Example 6 with SemanticModules

use of org.drools.core.xml.SemanticModules in project jbpm 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.drools.core.xml.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.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 7 with SemanticModules

use of org.drools.core.xml.SemanticModules in project jbpm by kiegroup.

the class XmlRuleFlowProcessDumper method readProcess.

@Override
public Process readProcess(String processXml) {
    KnowledgeBuilderConfigurationImpl configuration = new KnowledgeBuilderConfigurationImpl();
    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 : SemanticModules(org.drools.core.xml.SemanticModules) KnowledgeBuilderConfigurationImpl(org.drools.compiler.builder.impl.KnowledgeBuilderConfigurationImpl) StringReader(java.io.StringReader) WorkflowProcess(org.kie.api.definition.process.WorkflowProcess) Process(org.kie.api.definition.process.Process)

Example 8 with SemanticModules

use of org.drools.core.xml.SemanticModules in project jbpm 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.drools.core.xml.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)

Example 9 with SemanticModules

use of org.drools.core.xml.SemanticModules in project jbpm by kiegroup.

the class BPMN2XMLTest method testInvalidXML.

public void testInvalidXML() throws Exception, SAXException {
    SemanticModules modules = new SemanticModules();
    modules.addSemanticModule(new BPMNSemanticModule());
    modules.addSemanticModule(new BPMNDISemanticModule());
    XmlProcessReader processReader = new XmlProcessReader(modules, getClass().getClassLoader()) {

        @Override
        protected String processParserMessage(LinkedList<Object> parents, org.xml.sax.Attributes attr, String errorMessage) {
            setErrorMessage(super.processParserMessage(parents, attr, errorMessage));
            return errorMessage;
        }
    };
    processReader.read(BPMN2XMLTest.class.getResourceAsStream("/BPMN2-XMLProcessWithError.bpmn2"));
    assertNotNull(getErrorMessage());
    assertThat(getErrorMessage()).contains("Process Info: id:error.process, pkg:org.jbpm, name:errorprocess, version:1.0 \n" + "Node Info: id:_F8A89567-7416-4CCA-9CCD-BC1DDE870F1E name: \n" + "Parser message: (null: 45, 181): cvc-complex-type.2.4.a: Invalid content was found");
}
Also used : SemanticModules(org.drools.core.xml.SemanticModules) BPMNDISemanticModule(org.jbpm.bpmn2.xml.BPMNDISemanticModule) XmlProcessReader(org.jbpm.compiler.xml.XmlProcessReader) BPMNSemanticModule(org.jbpm.bpmn2.xml.BPMNSemanticModule) LinkedList(java.util.LinkedList)

Aggregations

SemanticModules (org.drools.core.xml.SemanticModules)9 XmlProcessReader (org.jbpm.compiler.xml.XmlProcessReader)6 Process (org.kie.api.definition.process.Process)6 StringReader (java.io.StringReader)5 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)5 BPMNDISemanticModule (org.jbpm.bpmn2.xml.BPMNDISemanticModule)3 BPMNSemanticModule (org.jbpm.bpmn2.xml.BPMNSemanticModule)3 Test (org.junit.Test)3 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 Diff (org.custommonkey.xmlunit.Diff)2 ElementNameAndAttributeQualifier (org.custommonkey.xmlunit.ElementNameAndAttributeQualifier)2 ProcessSemanticModule (org.jbpm.compiler.xml.ProcessSemanticModule)2 Node (org.jbpm.workflow.core.Node)2 ActionNode (org.jbpm.workflow.core.node.ActionNode)2 CompositeContextNode (org.jbpm.workflow.core.node.CompositeContextNode)2 DynamicNode (org.jbpm.workflow.core.node.DynamicNode)2 EndNode (org.jbpm.workflow.core.node.EndNode)2 EventNode (org.jbpm.workflow.core.node.EventNode)2 FaultNode (org.jbpm.workflow.core.node.FaultNode)2