Skip to content

OWLEntity#isBuiltIn() throws an exception in case an entity is alredy deleted #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sszuev opened this issue Feb 16, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@sszuev
Copy link
Contributor

sszuev commented Feb 16, 2020

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());
@sszuev sszuev added enhancement New feature or request bug Something isn't working and removed bug Something isn't working labels Feb 16, 2020
sszuev added a commit that referenced this issue Feb 16, 2020
…detached (see issue #10), add test + minor changes in OntologyManagerImpl (javadocs, deprecation use)
@sszuev
Copy link
Contributor Author

sszuev commented Feb 16, 2020

fix

@sszuev sszuev closed this as completed Feb 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant