Search in sources :

Example 1 with BinaryOWLParseException

use of org.semanticweb.binaryowl.BinaryOWLParseException in project webprotege by protegeproject.

the class ImportsCacheManager method parseOntologyDocument.

private void parseOntologyDocument(File ontologyDocument) {
    try {
        WRITE_LOCK.lock();
        try (InputStream is = new BufferedInputStream(new FileInputStream(ontologyDocument))) {
            BinaryOWLOntologyDocumentSerializer serializer = new BinaryOWLOntologyDocumentSerializer();
            final Handler handler = new Handler();
            serializer.read(is, handler, new OWLDataFactoryImpl());
            OWLOntologyID id = handler.getOntologyID();
            if (id.getOntologyIRI().isPresent()) {
                ontologyIDs.add(id);
                iri2Document.put(id.getOntologyIRI().get(), IRI.create(ontologyDocument.toURI()));
                if (id.getVersionIRI().isPresent()) {
                    iri2Document.put(id.getVersionIRI().get(), IRI.create(ontologyDocument));
                }
                metadataMap.put(id, new ImportedOntologyMetadata(id, handler.getDocumentIRI(), handler.getTimestamp()));
            }
        } catch (IOException | BinaryOWLParseException | UnloadableImportException e) {
            logger.error("An error occurred", e);
        }
    } finally {
        WRITE_LOCK.unlock();
    }
}
Also used : BinaryOWLParseException(org.semanticweb.binaryowl.BinaryOWLParseException) ImportedOntologyMetadata(edu.stanford.bmir.protege.web.shared.project.ImportedOntologyMetadata) BinaryOWLOntologyDocumentSerializer(org.semanticweb.binaryowl.BinaryOWLOntologyDocumentSerializer) OWLDataFactoryImpl(uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl)

Aggregations

ImportedOntologyMetadata (edu.stanford.bmir.protege.web.shared.project.ImportedOntologyMetadata)1 BinaryOWLOntologyDocumentSerializer (org.semanticweb.binaryowl.BinaryOWLOntologyDocumentSerializer)1 BinaryOWLParseException (org.semanticweb.binaryowl.BinaryOWLParseException)1 OWLDataFactoryImpl (uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl)1