Search in sources :

Example 1 with BPMNSemanticModule

use of io.automatiko.engine.workflow.bpmn2.xml.BPMNSemanticModule in project kie-wb-common by kiegroup.

the class BPMNValidatorImpl method init.

@PostConstruct
protected void init() {
    modules = new SemanticModules();
    modules.addSemanticModule(new BPMNSemanticModule());
    modules.addSemanticModule(new BPMNDISemanticModule());
}
Also used : SemanticModules(org.drools.core.xml.SemanticModules) BPMNDISemanticModule(org.jbpm.bpmn2.xml.BPMNDISemanticModule) BPMNSemanticModule(org.jbpm.bpmn2.xml.BPMNSemanticModule) PostConstruct(javax.annotation.PostConstruct)

Example 2 with BPMNSemanticModule

use of io.automatiko.engine.workflow.bpmn2.xml.BPMNSemanticModule in project jbpm by kiegroup.

the class BPMN2XMLTest method testInvalidXMLInCompositeNode.

public void testInvalidXMLInCompositeNode() 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(Collection<Object> parents, org.xml.sax.Attributes attr, String errorMessage) {
            setErrorMessage(super.processParserMessage(parents, attr, errorMessage));
            return errorMessage;
        }
    };
    processReader.read(BPMN2XMLTest.class.getResourceAsStream("/BPMN2-XMLProcessWithErrorInCompositeNode.bpmn2"));
    assertNotNull(getErrorMessage());
    assertThat(getErrorMessage()).contains("Process Info: id:abc.abc, pkg:org.drools.bpmn2, name:abc, version:1.0 \n" + "Node Info: id:_47489F3D-FEBD-4452-B62E-B04EF191C6C3 name: \n" + "Parser message: (null: 24, 185): 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) Collection(java.util.Collection)

Example 3 with BPMNSemanticModule

use of io.automatiko.engine.workflow.bpmn2.xml.BPMNSemanticModule in project jbpm by kiegroup.

the class BPMN2XMLTest method testXML.

public void testXML() throws IOException, SAXException {
    SemanticModules modules = new SemanticModules();
    modules.addSemanticModule(new BPMNSemanticModule());
    modules.addSemanticModule(new BPMNDISemanticModule());
    XmlProcessReader processReader = new XmlProcessReader(modules, getClass().getClassLoader());
    for (String processName : processes) {
        String original = slurp(BPMN2XMLTest.class.getResourceAsStream("/" + processName));
        List<Process> processes = processReader.read(BPMN2XMLTest.class.getResourceAsStream("/" + processName));
        assertNotNull(processes);
        assertEquals(1, processes.size());
        RuleFlowProcess p = (RuleFlowProcess) processes.get(0);
        String result = XmlBPMNProcessDumper.INSTANCE.dump(p, XmlBPMNProcessDumper.META_DATA_USING_DI);
        // Compare original with result using XMLUnit
        Diff diff = new Diff(original, result);
        // Ignore the sequence of nodes (or children nodes) when looking at these nodes
        final HashSet<String> sequenceDoesNotMatter = new HashSet<String>();
        sequenceDoesNotMatter.add("startEvent");
        sequenceDoesNotMatter.add("scriptTask");
        sequenceDoesNotMatter.add("endEvent");
        sequenceDoesNotMatter.add("bpmndi:BPMNShape");
        diff.overrideDifferenceListener(new DifferenceListener() {

            public int differenceFound(Difference diff) {
                String nodeName = diff.getTestNodeDetail().getNode().getNodeName();
                if (sequenceDoesNotMatter.contains(nodeName) && diff.getId() == DifferenceConstants.CHILD_NODELIST_SEQUENCE_ID) {
                    return RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL;
                }
                logger.info("! {}", diff.getTestNodeDetail().getNode().getNodeName());
                return RETURN_ACCEPT_DIFFERENCE;
            }

            public void skippedComparison(Node one, Node two) {
                logger.info("{} : {}", one.getLocalName(), two.getLocalName());
            }
        });
        // nodes should only be compared if their attributes are the same
        diff.overrideElementQualifier(new ElementNameAndAttributeQualifier());
        assertTrue("Original and generated output is not the same.", diff.identical());
    }
}
Also used : RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) Diff(org.custommonkey.xmlunit.Diff) XmlProcessReader(org.jbpm.compiler.xml.XmlProcessReader) Node(org.w3c.dom.Node) Process(org.kie.api.definition.process.Process) RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) Difference(org.custommonkey.xmlunit.Difference) SemanticModules(org.drools.core.xml.SemanticModules) BPMNDISemanticModule(org.jbpm.bpmn2.xml.BPMNDISemanticModule) ElementNameAndAttributeQualifier(org.custommonkey.xmlunit.ElementNameAndAttributeQualifier) BPMNSemanticModule(org.jbpm.bpmn2.xml.BPMNSemanticModule) DifferenceListener(org.custommonkey.xmlunit.DifferenceListener) HashSet(java.util.HashSet)

Example 4 with BPMNSemanticModule

use of io.automatiko.engine.workflow.bpmn2.xml.BPMNSemanticModule 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(Collection<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) Collection(java.util.Collection)

Example 5 with BPMNSemanticModule

use of io.automatiko.engine.workflow.bpmn2.xml.BPMNSemanticModule in project jbpm by kiegroup.

the class BPMN2ProcessProviderImpl method configurePackageBuilder.

public void configurePackageBuilder(KnowledgeBuilder knowledgeBuilder) {
    KnowledgeBuilderConfigurationImpl conf = ((KnowledgeBuilderImpl) knowledgeBuilder).getBuilderConfiguration();
    if (conf.getSemanticModules().getSemanticModule(BPMNSemanticModule.BPMN2_URI) == null) {
        conf.addSemanticModule(new BPMNSemanticModule());
        conf.addSemanticModule(new BPMNDISemanticModule());
        conf.addSemanticModule(new BPMNExtensionsSemanticModule());
    }
}
Also used : BPMNExtensionsSemanticModule(org.jbpm.bpmn2.xml.BPMNExtensionsSemanticModule) BPMNDISemanticModule(org.jbpm.bpmn2.xml.BPMNDISemanticModule) KnowledgeBuilderConfigurationImpl(org.drools.compiler.builder.impl.KnowledgeBuilderConfigurationImpl) KnowledgeBuilderImpl(org.drools.compiler.builder.impl.KnowledgeBuilderImpl) BPMNSemanticModule(org.jbpm.bpmn2.xml.BPMNSemanticModule)

Aggregations

BPMNDISemanticModule (org.jbpm.bpmn2.xml.BPMNDISemanticModule)7 BPMNSemanticModule (org.jbpm.bpmn2.xml.BPMNSemanticModule)7 SemanticModules (org.drools.core.xml.SemanticModules)4 XmlProcessReader (org.jbpm.compiler.xml.XmlProcessReader)4 KnowledgeBuilderConfigurationImpl (org.drools.compiler.builder.impl.KnowledgeBuilderConfigurationImpl)3 BPMNExtensionsSemanticModule (org.jbpm.bpmn2.xml.BPMNExtensionsSemanticModule)3 Collection (java.util.Collection)2 KnowledgeBuilderImpl (org.drools.compiler.builder.impl.KnowledgeBuilderImpl)2 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)2 Process (org.kie.api.definition.process.Process)2 StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 PostConstruct (javax.annotation.PostConstruct)1 Diff (org.custommonkey.xmlunit.Diff)1 Difference (org.custommonkey.xmlunit.Difference)1 DifferenceListener (org.custommonkey.xmlunit.DifferenceListener)1 ElementNameAndAttributeQualifier (org.custommonkey.xmlunit.ElementNameAndAttributeQualifier)1 Resource (org.kie.api.io.Resource)1 KnowledgeBuilderConfiguration (org.kie.internal.builder.KnowledgeBuilderConfiguration)1