#347 OWLOntologyDocumentAlreadyExistsException in OWL API 3.4.1

closed
None
5
2012-10-30
2012-10-29
Leaving
No

I am trying to load two different versions of the same ontology (with the same IRI).
This bug appers with ontologies in Manchester Syntax.
I am using different managers. At least I think they are different. Here is my code:

OWLOntologyManager m1 = OWLManager.createOWLOntologyManager();
OWLOntologyManager m2 = OWLManager.createOWLOntologyManager();
OWLOntology o1 = m1.loadOntologyFromOntologyDocument(new FileDocumentSource(new File(baseFilename)), config);
OWLOntology o2 = m2.loadOntologyFromOntologyDocument(new FileDocumentSource(new File(remoteFilename)), config);

Here is the exception I get:

java.lang.RuntimeException: org.semanticweb.owlapi.model.OWLOntologyDocumentAlreadyExistsException
at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.getOntology(OWLOntologyManagerImpl.java:295)
at org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseOntology(ManchesterOWLSyntaxEditorParser.java:2855)
at org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxOntologyParser.parse(ManchesterOWLSyntaxOntologyParser.java:124)
at uk.ac.manchester.cs.owl.owlapi.ParsableOWLOntologyFactory.loadOWLOntology(ParsableOWLOntologyFactory.java:210)
at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:889)
at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntologyFromOntologyDocument(OWLOntologyManagerImpl.java:843)

I think this bug came in 3.4.1 with this hack in OWLOntologyManagerImpl:

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(
documentIRI));
}
}
return result;
}

In 3.4 this was just:

public OWLOntology getOntology\(IRI ontologyIRI\) \{
    OWLOntologyID ontologyID = new OWLOntologyID\(ontologyIRI\);
    return getOntology\(ontologyID\);
\}

Discussion

  • Ignazio Palmisano

    • assigned_to: nobody --> ignazio1977
     
  • Ignazio Palmisano

    thanks for reporting the issue. Having two managers should not be the issue, they are independent. I will investigate.

     
  • Ignazio Palmisano

    I cannot replicate without the ontologies, but it looks like the problem is to do with matching an IRI and the available ontology ids. I have patched the code to remove the exception.

     
  • Ignazio Palmisano

    • status: open --> closed
     

Log in to post a comment.