/** * Given an imports declaration, obtains the ontology that this import has been resolved to. * * @param declaration The declaration that points to the imported ontology. * @return The ontology that the imports declaration resolves to, or <code>null</code> if the imports declaration * could not be resolved to an ontology, because the ontology was not loaded or has been removed from this * manager */ public OWLOntology getImportedOntology(OWLImportsDeclaration declaration) { OWLOntologyID ontologyID = ontologyIDsByImportsDeclaration.get(declaration); if (ontologyID == null) { // No such ontology return null; } else { return getOntology(ontologyID); } }
@Override @Nullable public OWLOntology getImportedOntology(OWLImportsDeclaration declaration) { readLock.lock(); try { OWLOntologyID ontologyID = ontologyIDsByImportsDeclaration.get(declaration); if (ontologyID == null) { // No such ontology has been loaded through an import // declaration, but it might have been loaded manually. // Using the IRI to retrieve it will either find the ontology or // return null. // Last possibility is an import by document IRI; if the // ontology is not found by IRI, check by document IRI. OWLOntology ontology = getOntology(declaration.getIRI()); if (ontology == null) { ontology = getOntologyByDocumentIRI(declaration.getIRI()); } return ontology; } else { return getOntology(ontologyID); } } finally { readLock.unlock(); } }
@Override @Nullable public OWLOntology getImportedOntology(OWLImportsDeclaration declaration) { readLock.lock(); try { OWLOntologyID ontologyID = ontologyIDsByImportsDeclaration.get(declaration); if (ontologyID == null) { // No such ontology has been loaded through an import // declaration, but it might have been loaded manually. // Using the IRI to retrieve it will either find the ontology or // return null. // Last possibility is an import by document IRI; if the // ontology is not found by IRI, check by document IRI. OWLOntology ontology = getOntology(declaration.getIRI()); if (ontology == null) { ontology = getOntologyByDocumentIRI(declaration.getIRI()); } return ontology; } else { return getOntology(ontologyID); } } finally { readLock.unlock(); } }
/** * Gets a previously loaded/created ontology that has the specified ontology IRI and no version IRI. * * @param ontologyIRI The IRI of the ontology to be retrieved. * @return The ontology that has the specified IRI and no version IRI, or <code>null</code> if this manager does * not manage an ontology with the specified IRI and no version IRI. */ public OWLOntology getOntology(IRI ontologyIRI) { OWLOntologyID ontologyID = new OWLOntologyID(ontologyIRI); return getOntology(ontologyID); }
@Override @Nullable public OWLOntology getImportedOntology(OWLImportsDeclaration declaration) { readLock.lock(); try { OWLOntologyID ontologyID = ontologyIDsByImportsDeclaration.get(declaration); if (ontologyID == null) { // No such ontology has been loaded through an import // declaration, but it might have been loaded manually. // Using the IRI to retrieve it will either find the ontology or // return null. // Last possibility is an import by document IRI; if the // ontology is not found by IRI, check by document IRI. OWLOntology ontology = getOntology(declaration.getIRI()); if (ontology == null) { ontology = getOntologyByDocumentIRI(declaration.getIRI()); } return ontology; } else { return getOntology(ontologyID); } } finally { readLock.unlock(); } }
@Nullable private OWLOntology loadOntologyByDocumentIRI(IRI iri) { readLock.lock(); try { java.util.Optional<Entry<OWLOntologyID, IRI>> findAny = documentIRIsByID.entrySet() .stream().filter(o -> iri.equals(o.getValue())).findAny(); if (findAny.isPresent()) { return getOntology(findAny.get().getKey()); } return null; } finally { readLock.unlock(); } }
@Override @Nullable public OWLOntology getImportedOntology(OWLImportsDeclaration declaration) { readLock.lock(); try { OWLOntologyID ontologyID = ontologyIDsByImportsDeclaration.get(declaration); if (ontologyID == null) { // No such ontology has been loaded through an import // declaration, but it might have been loaded manually. // Using the IRI to retrieve it will either find the ontology or // return null. // Last possibility is an import by document IRI; if the // ontology is not found by IRI, check by document IRI. OWLOntology ontology = getOntology(declaration.getIRI()); if (ontology == null) { ontology = getOntologyByDocumentIRI(declaration.getIRI()); } return ontology; } else { return getOntology(ontologyID); } } finally { readLock.unlock(); } }
@Nullable private OWLOntology loadOntologyByDocumentIRI(IRI iri) { readLock.lock(); try { java.util.Optional<Entry<OWLOntologyID, IRI>> findAny = documentIRIsByID.entrySet() .stream().filter(o -> iri.equals(o.getValue())).findAny(); if (findAny.isPresent()) { return getOntology(findAny.get().getKey()); } return null; } finally { readLock.unlock(); } }
@Nullable private OWLOntology loadOntologyByDocumentIRI(IRI iri) { readLock.lock(); try { java.util.Optional<Entry<OWLOntologyID, IRI>> findAny = documentIRIsByID.entrySet() .stream().filter(o -> iri.equals(o.getValue())).findAny(); if (findAny.isPresent()) { return getOntology(findAny.get().getKey()); } return null; } finally { readLock.unlock(); } }
@Nullable private OWLOntology loadOntologyByDocumentIRI(IRI iri) { readLock.lock(); try { java.util.Optional<Entry<OWLOntologyID, IRI>> findAny = documentIRIsByID.entrySet() .stream().filter(o -> iri.equals(o.getValue())).findAny(); if (findAny.isPresent()) { return getOntology(findAny.get().getKey()); } return null; } finally { readLock.unlock(); } }
public OWLOntology loadOntology(IRI ontologyIRI) throws OWLOntologyCreationException { OWLOntologyID id = new OWLOntologyID(ontologyIRI); OWLOntology ontByID = ontologiesByID.get(id); if (ontByID != null) { return ontByID; } IRI documentIRI = getDocumentIRIFromMappers(id, true); if (documentIRIsByID.values().contains(documentIRI)) { throw new OWLOntologyDocumentAlreadyExistsException(documentIRI); } // The ontology might be being loaded, but its IRI might // not have been set (as is probably the case with RDF/XML!) if (documentIRI != null) { OWLOntology ontByDocumentIRI = getOntology(documentIRI); if (ontByDocumentIRI != null) { return ontByDocumentIRI; } } else { // Nothing we can do here. We can't get a document IRI to load // the ontology from. throw new OntologyIRIMappingNotFoundException(ontologyIRI); } return loadOntology(ontologyIRI, new IRIDocumentSource(documentIRI)); }