private void checkForImportsChange(OWLOntologyChange change) {
if (change.isImportChange()) {
resetImportsClosureCache();
if (change instanceof AddImport) {
OWLImportsDeclaration addImportDeclaration = ((AddImport) change)
.getImportDeclaration();
boolean found = false;
IRI iri = addImportDeclaration.getIRI();
for (OWLOntologyID id : ontologiesByID.keySet()) {
if (iri.equals(id.getDefaultDocumentIRI().orNull())
|| iri.equals(id.getOntologyIRI().orNull())
|| iri.equals(id.getVersionIRI().orNull())) {
found = true;
ontologyIDsByImportsDeclaration.put(
addImportDeclaration, id);
}
}
if (!found) {
// then the import does not refer to a known IRI for
// ontologies; check for a document IRI
for (Map.Entry<OWLOntologyID, IRI> e : documentIRIsByID
.entrySet()) {
if (e.getValue().equals(iri)) {
// found the ontology id corresponding to the file
// location
ontologyIDsByImportsDeclaration.put(
addImportDeclaration, e.getKey());
}
}
}
} else {
// Remove the mapping from declaration to ontology
OWLImportsDeclaration importDeclaration = ((RemoveImport) change)
.getImportDeclaration();
ontologyIDsByImportsDeclaration.remove(importDeclaration);
importedIRIs.remove(importDeclaration.getIRI());
}
}
}