OWLEntity#isBuiltIn() throws an exception in case an entity is alredy deleted
sszuev opened this issue · 1 comments
This is actually known behavior which is by design.
There is no guarantee that any method of unattached (i.e. deleted) object will not throw an exception.
It is already deleted, so it has no connection with the graph.
Unlike OWL-API default impl, in ONT-API there is a dynamic object's state, which depends on graph and model's settings, it is true even for isBuiltIn parameter-property.
But for OWLEntity#isBuiltIn()
it is better to make an exception:
there is an example of code in Protege where an entity is still in use even after its deletion (see org.protege.editor.owl.model.hierarchy.OWLAnnotationPropertyHierarchyProvider#handleChanges(...)
).
Moreover - it is always possible to safely determine whether an entity is builtin even it is deleted.
The testcase:
OntologyManager m = OntManagers.createONT();
DataFactory df = m.getOWLDataFactory();
Ontology o = m.createOntology();
OWLAxiom a = df.getOWLDeclarationAxiom(df.getOWLAnnotationProperty("a"));
o.add(a);
OWLEntity e1 = o.signature().filter(AsOWLAnnotationProperty::isOWLAnnotationProperty)
.findFirst().orElseThrow(AssertionError::new);
Assert.assertFalse(e1.isBuiltIn());
o.remove(a);
Assert.assertFalse(e1.isBuiltIn());
fix