owlcs / jfact

JFact repository
13 stars 8 forks source link

adding individuals causes crash #2

Closed ignazio1977 closed 10 years ago

ignazio1977 commented 10 years ago

@Test public void shouldLoadAndNotFailQuery() throws Exception { // given OWLOntology o = OWLManager.createOWLOntologyManager().createOntology(); OWLOntologyManager m = o.getOWLOntologyManager(); OWLDataFactory f = m.getOWLDataFactory(); OWLClass c1 = f.getOWLClass(IRI.create("urn:test#c1")); OWLClass c2 = f.getOWLClass(IRI.create("urn:test#c2")); OWLObjectProperty p = f.getOWLObjectProperty(IRI.create("urn:test#p")); m.addAxiom(o, f.getOWLDisjointClassesAxiom(c1, c2)); m.addAxiom(o, f.getOWLObjectPropertyDomainAxiom(p, c1)); m.addAxiom(o, f.getOWLObjectPropertyRangeAxiom(p, c2)); OWLReasoner r = new JFactFactory().createReasoner(o); r.precomputeInferences(InferenceType.CLASS_HIERARCHY); OWLIndividual i = f.getOWLNamedIndividual(IRI.create("urn:test#i")); OWLIndividual j = f.getOWLNamedIndividual(IRI.create("urn:test#j")); m.addAxiom(o, f.getOWLObjectPropertyAssertionAxiom(p, i, j)); r.flush(); r.precomputeInferences(InferenceType.CLASS_HIERARCHY); OWLIndividual k = f.getOWLNamedIndividual(IRI.create("urn:test#k")); OWLIndividual l = f.getOWLNamedIndividual(IRI.create("urn:test#l")); m.addAxiom(o, f.getOWLObjectPropertyAssertionAxiom(p, k, l)); r.flush(); r.precomputeInferences(InferenceType.CLASS_HIERARCHY); }

ignazio1977 commented 10 years ago

Reloading an ontology does not reset the named entries on all named entities when cleaning. As a result, the name collections are cleared but not refilled, and this causes individuals to not be found.

Fix is to reset the named entries on all the entities in the ontology signature.