MobiOntologyFactory implements OWLOntologyFactory { @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()) { 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; } MobiOntologyFactory(OntologyManager ontologyManager, OWLOntologyFactory factory,
                               SesameTransformer sesameTransformer); @Override boolean canCreateFromDocumentIRI(IRI documentIRI); @Override boolean canAttemptLoading(OWLOntologyDocumentSource source); @Override OWLOntology createOWLOntology(OWLOntologyManager manager, OWLOntologyID ontologyID, IRI documentIRI,
                                         OWLOntologyCreationHandler handler); @Override OWLOntology loadOWLOntology(OWLOntologyManager manager, OWLOntologyDocumentSource source,
                                       OWLOntologyCreationHandler handler, OWLOntologyLoaderConfiguration config);  }
@Test public void loadOWLOntologyTest() throws Exception { assertEquals(owlOntology, factory.loadOWLOntology(owlOntologyManager, protocolSource, handler, configuration)); verify(ontologyManager).getOntologyModel(matIRI); verify(handler).setOntologyFormat(any(OWLOntology.class), any(OWLDocumentFormat.class)); verify(owlOntologyManager).removeOntology(any(OWLOntology.class)); verify(ontologyFactory, times(2)).createOWLOntology(eq(owlOntologyManager), any(OWLOntologyID.class), eq(owlProtocolIRI), eq(handler)); }