From: Ignazio P. <ipa...@gm...> - 2012-10-26 21:51:10
|
On 26 October 2012 22:05, Rouquette, Nicolas F (313K) <nic...@jp...> wrote: > With 3.4.1 (revision 2092), our code fails when we try to get an imported > ontology like this: > > OWLOntologyManager ontManager = Š; > > OWLOntology ont = Š; > > for (IRI directImportDocumentIRI : ont.getDirectImportsDocuments()) { > OWLOntology directImportOntology = > ontManager.getOntology(directImportDocumentIRI); // << throws > OWLOntologyDocumentAlreadyExistsException > Š > > The exception comes from OWLOntologyManagerImpl, line 295 below: > > Thanks for reporting this, it looks to me like a problem with the relations between document names and ontology iris. Can you print out the directImportDocumentIRIs and the ontology ids for the ontologies in the import closure - or share the ontology on which this happens? I'm trying to figure out if there is a mismatch between document iris and ontology iris, and how to work it out. In the meantime, ontology.getDirectImports() should return the set of imported ontologies without the need for you to manually retrieve them. HTH, I. > public OWLOntology getOntology(IRI ontologyIRI) { > OWLOntologyID ontologyID = new OWLOntologyID(ontologyIRI); > // return getOntology(ontologyID); > OWLOntology result = ontologiesByID.get(ontologyID); > if (result == null) { > for (OWLOntologyID nextOntologyID : ontologiesByID.keySet()) { > if (ontologyIRI.equals(nextOntologyID.getVersionIRI())) { > result = ontologiesByID.get(nextOntologyID); > } > } > } > // HACK: This extra clause is necessary to make getOntology match > the > // behaviour of createOntology > // in cases where a documentIRI has been recorded, based on the > mappers, > // but an ontology has not > // been stored in ontologiesByID > if (result == null) { > IRI documentIRI = getDocumentIRIFromMappers(ontologyID, true); > if (documentIRI == null) { > if (!ontologyID.isAnonymous()) { > documentIRI = ontologyID.getDefaultDocumentIRI(); > } else { > documentIRI = IRI.generateDocumentIRI(); > } > Collection<IRI> existingDocumentIRIs = > documentIRIsByID.values(); > while (existingDocumentIRIs.contains(documentIRI)) { > documentIRI = IRI.generateDocumentIRI(); > } > } > if (documentIRIsByID.values().contains(documentIRI)) { > throw new RuntimeException(new > OWLOntologyDocumentAlreadyExistsException( // line 295 > documentIRI)); > } > } > return result; > } > > > > What is the rationale for getOntology(IRI) to throw > OWLOntologyDocumentAlreadyExistsException when we precisely want to > retrieve the ontology document? > > - Nicolas. > > > ------------------------------------------------------------------------------ > WINDOWS 8 is here. > Millions of people. Your app in 30 days. > Visit The Windows 8 Center at Sourceforge for all your go to resources. > http://windows8center.sourceforge.net/ > join-generation-app-and-make-money-coding-fast/ > _______________________________________________ > Owlapi-developer mailing list > Owl...@li... > https://lists.sourceforge.net/lists/listinfo/owlapi-developer |