org.semanticweb.owlapi.model.OWLOntologyLoaderConfiguration Java Examples

The following examples show how to use org.semanticweb.owlapi.model.OWLOntologyLoaderConfiguration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MobiOntologyFactory.java    From mobi with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public OWLOntology loadOWLOntology(OWLOntologyManager manager, OWLOntologyDocumentSource source,
                                   OWLOntologyCreationHandler handler, OWLOntologyLoaderConfiguration config)
        throws OWLOntologyCreationException {
    LOG.trace("Enter loadOWLOntology()");
    long start = System.currentTimeMillis();
    OWLOntology existingOntology = null;
    IRI documentIRI = source.getDocumentIRI();
    if (manager.contains(documentIRI)) {
        existingOntology = manager.getOntology(documentIRI);
    }
    OWLOntologyID ontologyID = new OWLOntologyID();
    OWLOntology ont = createOWLOntology(manager, ontologyID, documentIRI, handler);
    if (existingOntology == null && !ont.isEmpty()) {
        // Junk from a previous parse. We should clear the ont
        LOG.trace("Clearing extraneous ontology");
        manager.removeOntology(ont);
        ont = createOWLOntology(manager, ontologyID, documentIRI, handler);
    }
    IRI recordId = IRI.create(documentIRI.getIRIString().replace(MobiOntologyIRIMapper.protocol,
            MobiOntologyIRIMapper.standardProtocol));
    Model ontologyModel = ontologyManager.getOntologyModel(SimpleOntologyValues.mobiIRI(recordId));
    RioParserImpl parser = new RioParserImpl(new RioRDFXMLDocumentFormatFactory());
    org.eclipse.rdf4j.model.Model sesameModel = sesameTransformer.sesameModel(ontologyModel);
    OWLDocumentFormat format = parser.parse(new RioMemoryTripleSource(sesameModel), ont, config);
    handler.setOntologyFormat(ont, format);
    LOG.debug("Loaded imported Ontology: {}", ont.getOntologyID().toString());
    LOG.trace("Exit loadOWLOntology() {} ms", System.currentTimeMillis() - start);
    return ont;
}
 
Example #2
Source File: OntologyLoader.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
private OWLOntology loadOwlOntology() throws OWLOntologyCreationException {
  FileDocumentSource fileDocumentSource = new FileDocumentSource(ontologyFile);
  // use silent import handling strategy to enable ontology loading without internet access
  // see: https://github.com/molgenis/molgenis/issues/5301
  OWLOntologyLoaderConfiguration owlOntologyLoaderConfiguration =
      new OWLOntologyLoaderConfiguration()
          .setMissingImportHandlingStrategy(MissingImportHandlingStrategy.SILENT);
  return manager.loadOntologyFromOntologyDocument(
      fileDocumentSource, owlOntologyLoaderConfiguration);
}