Search in sources :

Example 6 with MissingImportListener

use of org.semanticweb.owlapi.model.MissingImportListener in project stanbol by apache.

the class ODPRegistryCacheManager method retrieveLocalResource.

private static synchronized OWLOntology retrieveLocalResource(URI uri) throws OWLOntologyCreationException, ODPRegistryCacheException, URIUnresolvableException {
    File file = uris.get(uri);
    if (!file.exists()) {
        uris.remove(uri);
        return getOntology(uri);
    }
    manager.setSilentMissingImportsHandling(true);
    manager.addMissingImportListener(new MissingImportListener() {

        public void importMissing(MissingImportEvent arg0) {
            if (!getUnresolvedURIs().contains(arg0.getImportedOntologyURI()))
                getUnresolvedURIs().add(arg0.getImportedOntologyURI().toURI());
        }
    });
    IRI oi = oiri.get(uri);
    OWLOntology ontology = null;
    ontology = manager.getOntology(oi);
    if (ontology == null)
        try {
            ontology = manager.loadOntologyFromOntologyDocument(IRI.create(file));
        } catch (OWLOntologyAlreadyExistsException e) {
            ontology = manager.getOntology(e.getOntologyID());
        }
    return ontology;
}
Also used : MissingImportListener(org.semanticweb.owlapi.model.MissingImportListener) IRI(org.semanticweb.owlapi.model.IRI) MissingImportEvent(org.semanticweb.owlapi.model.MissingImportEvent) OWLOntology(org.semanticweb.owlapi.model.OWLOntology) File(java.io.File) OWLOntologyAlreadyExistsException(org.semanticweb.owlapi.model.OWLOntologyAlreadyExistsException)

Aggregations

MissingImportEvent (org.semanticweb.owlapi.model.MissingImportEvent)6 MissingImportListener (org.semanticweb.owlapi.model.MissingImportListener)6 OWLOntologyLoaderListener (org.semanticweb.owlapi.model.OWLOntologyLoaderListener)5 OWLOntologyManager (org.semanticweb.owlapi.model.OWLOntologyManager)4 File (java.io.File)2 OWLOntology (org.semanticweb.owlapi.model.OWLOntology)2 OWLOntologyAlreadyExistsException (org.semanticweb.owlapi.model.OWLOntologyAlreadyExistsException)2 URI (java.net.URI)1 IRI (org.semanticweb.owlapi.model.IRI)1 LoadingFinishedEvent (org.semanticweb.owlapi.model.OWLOntologyLoaderListener.LoadingFinishedEvent)1 LoadingStartedEvent (org.semanticweb.owlapi.model.OWLOntologyLoaderListener.LoadingStartedEvent)1 OWLOntologyStorageException (org.semanticweb.owlapi.model.OWLOntologyStorageException)1 UnknownOWLOntologyException (org.semanticweb.owlapi.model.UnknownOWLOntologyException)1