kbss-cvut / bpmn2stamp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JOPA CardinalityConstraintViolatedException durring persistence

grigobog opened this issue · comments

Viz Meeting notes (BG) - 2021-12-01
commit 761b35b
Kroky pro reprodukci:

  1. mvn clean
  2. mvn package
  3. mvn aspectj-maven-plugin:1.12.6:compile
  4. Zmenit cestu k vyslednemu souboru v construktoru RdfWriterService
  5. Spustit BpmnReaderServiceTest#readFromXmlTest_resultShouldBePresent
    Musi spadnout na radku 55: rdfWriterService.save(elements);

The error is:

cz.cvut.kbss.jopa.exceptions.RollbackException: cz.cvut.kbss.jopa.exceptions.CardinalityConstraintViolatedException: At least 1 values of attribute FlowElement.has_container expected in instance _3M86QLqlEeq4RbAg2SWqZQ, but got only 0

@grigobog Your assumptions are ok to assume that you will have
FlowElement.has_container inferred from has_flowElements property

This can be seen if you take ontiky.owl file in protege and start reasoner as can be seen here :
image

However to see inferences in protege you had to do use a reasoner:
image

Same way you have to do it within your code. See my pull request which is failing but i guess you can continue from this point:
image

In case you are not able to fix it like that, try instead of that writing a test to load ontiky.owl that you have created (if i uncomment all failing violations you can generate ontiky.owl file). But remember that before loading the ontiky.owl you need to include import triple in there (of course :) :

    <Ontology>
        <imports rdf:resource="http://BPMNbasedOntology"/>
    </Ontology>

Reopened.
Issue was only reasolved for reading case:
Steps to verify:

  1. mvn clean
  2. mvn package
  3. mvn aspectj-maven-plugin:1.12.6:compile
  4. run BpmnReaderServiceTest#readTest_whenObjectExists_inferredFieldsShouldBeSet which should pass

Issue is still present for saving (persisting) case:
Steps to reproduce:

  1. make sure that model.bbo.model.FlowElement#has_container participation constraint is not commented
  2. mvn clean
  3. mvn package
  4. mvn aspectj-maven-plugin:1.12.6:compile
  5. run BpmnReaderServiceTest#mapAndWriteTest or BpmnReaderServiceTest#writeTest_usingNewEntities which should fail (both)
    Expected no errors occur, sice inverse property model.bbo.model.FlowElementsContainer#has_flowElements is set, ontology http://BPMNbasedOntology is imported and Openllet reasoner is used.

Following the reading case 1.-4. i got into this issue while runnig the test:
image

I tried remove java.xml but had no success ... I'll try later.

Hm, seems like the problem is somehow related to JAXB library, which is used to read files with bpmn and organization structure.
Most likely it's caused by different Java version, I'm using Amazon Corretto 11, which can be downloaded right from Intellij Idea.
If you are using Eclipse and java version is ok, the error may be caused by unnecessary external libraries in modulepath. This is all I could find in google for now.

  1. with Amazon Corretto 11 i am able to run test.
  2. test readTest_whenObjectExists_inferredFieldsShouldBeSet() does not make sense to me. It is not executable by itself :( as some other tests generates files that this test uses. Anyway, even if i let other tests to generate input files for this test, i get invalid input file and actualElement within this test is null:
    image

The generated file resources/jednani-sag-bpmn.ttl is invalid turtle format file:

{
<http://onto.fel.cvut.cz/ontologies/ucl/example/jednani-sag-bpmn> a owl:Ontology .
<http://onto.fel.cvut.cz/ontologies/ucl/example/jednani-sag-bpmn> owl:imports <http://onto.fel.cvut.cz/ontologies/ucl/example/jednani-sag-organization-structure> .
}

Even if I fix the file and make it parsable, it does not help. Thus I am switching to mapAndWriteTest but I am not sure if I will be able to help ....

Fixed in: kbss-cvut/jopa#98 (0.18.1)

will close after tests.