JOPA CardinalityConstraintViolatedException durring persistence
grigobog opened this issue · comments
Viz Meeting notes (BG) - 2021-12-01
commit 761b35b
Kroky pro reprodukci:
- mvn clean
- mvn package
- mvn aspectj-maven-plugin:1.12.6:compile
- Zmenit cestu k vyslednemu souboru v construktoru RdfWriterService
- 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 :
However to see inferences in protege you had to do use a reasoner:
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:
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:
- mvn clean
- mvn package
- mvn aspectj-maven-plugin:1.12.6:compile
- run BpmnReaderServiceTest#readTest_whenObjectExists_inferredFieldsShouldBeSet which should pass
Issue is still present for saving (persisting) case:
Steps to reproduce:
- make sure that model.bbo.model.FlowElement#has_container participation constraint is not commented
- mvn clean
- mvn package
- mvn aspectj-maven-plugin:1.12.6:compile
- 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.
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.
- with Amazon Corretto 11 i am able to run test.
- 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 andactualElement
within this test is null:
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.