@Test public void testGetSupplementaryRDFStream() { try (InputStream in = annotationDAO.getSupplementaryRDFStream(); OutputStream out = new FileOutputStream(new File("target", "test_supplemental.rdf"))) { getLog().debug("Reading from supplementary RDF data stream..."); byte[] buffer = new byte[1024]; int len = in.read(buffer); getLog().debug("Read next " + len + " bytes"); while (len != -1) { out.write(buffer, 0, len); len = in.read(buffer); getLog().debug("Read next " + len + " bytes"); } getLog().debug("Finished reading from RDF stream"); } catch (Exception e) { e.printStackTrace(); fail(); } }
@Override public InputStream getSupplementaryRDFStream() { try { final OWLOntology ontology = owlLoader.getOntology(); final OWLOntologyManager manager = ontology.getOWLOntologyManager(); final PipedOutputStream out = new PipedOutputStream(); final PipedInputStream in = new PipedInputStream(out); new Thread(new Runnable() { @Override public void run() { try { getLog().debug("Writing ontology to supplementary RDF data stream using RDF/XML format..."); manager.saveOntology(ontology, new RDFXMLOntologyFormat(), out); getLog().debug("Finished streaming ontology to supplementary RDF data stream"); } catch (OWLOntologyStorageException e) { getLog().error("Failed to stream OWLOntology for '" + getDatasourceName() + "' to RDF"); } finally { try { out.close(); } catch (IOException e) { getLog().warn("Failed to close supplementary RDF data stream", e); } } } }).start(); return in; } catch (IOException e) { String msg = "Failed to stream OWLOntology for '" + getDatasourceName() + "' to RDF"; getLog().error(msg); throw new RuntimeException(msg, e); } }
OWLAnnotationDAO extends Initializable implements AnnotationDAO, SemanticallyEnrichedDAO { @Override public InputStream getSupplementaryRDFStream() { try { final OWLOntology ontology = owlLoader.getOntology(); final OWLOntologyManager manager = ontology.getOWLOntologyManager(); final PipedOutputStream out = new PipedOutputStream(); final PipedInputStream in = new PipedInputStream(out); new Thread(new Runnable() { @Override public void run() { try { getLog().debug("Writing ontology to supplementary RDF data stream using RDF/XML format..."); manager.saveOntology(ontology, new RDFXMLOntologyFormat(), out); getLog().debug("Finished streaming ontology to supplementary RDF data stream"); } catch (OWLOntologyStorageException e) { getLog().error("Failed to stream OWLOntology for '" + getDatasourceName() + "' to RDF"); } finally { try { out.close(); } catch (IOException e) { getLog().warn("Failed to close supplementary RDF data stream", e); } } } }).start(); return in; } catch (IOException e) { String msg = "Failed to stream OWLOntology for '" + getDatasourceName() + "' to RDF"; getLog().error(msg); throw new RuntimeException(msg, e); } } }
OWLAnnotationDAO extends Initializable implements AnnotationDAO, SemanticallyEnrichedDAO { @Override public InputStream getSupplementaryRDFStream() { try { final OWLOntology ontology = owlLoader.getOntology(); final OWLOntologyManager manager = ontology.getOWLOntologyManager(); final PipedOutputStream out = new PipedOutputStream(); final PipedInputStream in = new PipedInputStream(out); new Thread(new Runnable() { @Override public void run() { try { getLog().debug("Writing ontology to supplementary RDF data stream using RDF/XML format..."); manager.saveOntology(ontology, new RDFXMLOntologyFormat(), out); getLog().debug("Finished streaming ontology to supplementary RDF data stream"); } catch (OWLOntologyStorageException e) { getLog().error("Failed to stream OWLOntology for '" + getDatasourceName() + "' to RDF"); } finally { try { out.close(); } catch (IOException e) { getLog().warn("Failed to close supplementary RDF data stream", e); } } } }).start(); return in; } catch (IOException e) { String msg = "Failed to stream OWLOntology for '" + getDatasourceName() + "' to RDF"; getLog().error(msg); throw new RuntimeException(msg, e); } } OWLAnnotationDAO(AnnotationFactory annotationFactory, OntologyLoader owlLoader, String datasourceName); }
OWLAnnotationDAO extends Initializable implements AnnotationDAO, SemanticallyEnrichedDAO { @Override public InputStream getSupplementaryRDFStream() { try { final OWLOntology ontology = owlLoader.getOntology(); final OWLOntologyManager manager = ontology.getOWLOntologyManager(); final PipedOutputStream out = new PipedOutputStream(); final PipedInputStream in = new PipedInputStream(out); new Thread(new Runnable() { @Override public void run() { try { getLog().debug("Writing ontology to supplementary RDF data stream using RDF/XML format..."); manager.saveOntology(ontology, new RDFXMLOntologyFormat(), out); getLog().debug("Finished streaming ontology to supplementary RDF data stream"); } catch (OWLOntologyStorageException e) { getLog().error("Failed to stream OWLOntology for '" + getDatasourceName() + "' to RDF"); } finally { try { out.close(); } catch (IOException e) { getLog().warn("Failed to close supplementary RDF data stream", e); } } } }).start(); return in; } catch (IOException e) { String msg = "Failed to stream OWLOntology for '" + getDatasourceName() + "' to RDF"; getLog().error(msg); throw new RuntimeException(msg, e); } } OWLAnnotationDAO(AnnotationFactory annotationFactory, OntologyLoader owlLoader, String datasourceName); @Override String getDatasourceName(); @Override InputStream getSupplementaryRDFStream(); @Override Collection<Annotation> readByStudy(Study study); @Override Collection<Annotation> readByBiologicalEntity(BiologicalEntity biologicalEntity); @Override Collection<Annotation> readByProperty(Property property); @Override Collection<Annotation> readBySemanticTag(URI semanticTagURI); @Override int count(); @Override void create(Annotation identifiable); @Override void create(Collection<Annotation> identifiable); @Override Collection<Annotation> read(); @Override List<Annotation> read(int size, int start); @Override Annotation read(URI uri); @Override void update(Annotation object); @Override void update(Collection<Annotation> object); @Override void delete(Annotation object); }
OWLAnnotationDAO extends Initializable implements AnnotationDAO, SemanticallyEnrichedDAO { @Override public InputStream getSupplementaryRDFStream() { try { final OWLOntology ontology = owlLoader.getOntology(); final OWLOntologyManager manager = ontology.getOWLOntologyManager(); final PipedOutputStream out = new PipedOutputStream(); final PipedInputStream in = new PipedInputStream(out); new Thread(new Runnable() { @Override public void run() { try { getLog().debug("Writing ontology to supplementary RDF data stream using RDF/XML format..."); manager.saveOntology(ontology, new RDFXMLOntologyFormat(), out); getLog().debug("Finished streaming ontology to supplementary RDF data stream"); } catch (OWLOntologyStorageException e) { getLog().error("Failed to stream OWLOntology for '" + getDatasourceName() + "' to RDF"); } finally { try { out.close(); } catch (IOException e) { getLog().warn("Failed to close supplementary RDF data stream", e); } } } }).start(); return in; } catch (IOException e) { String msg = "Failed to stream OWLOntology for '" + getDatasourceName() + "' to RDF"; getLog().error(msg); throw new RuntimeException(msg, e); } } OWLAnnotationDAO(AnnotationFactory annotationFactory, OntologyLoader owlLoader, String datasourceName); @Override String getDatasourceName(); @Override InputStream getSupplementaryRDFStream(); @Override Collection<Annotation> readByStudy(Study study); @Override Collection<Annotation> readByBiologicalEntity(BiologicalEntity biologicalEntity); @Override Collection<Annotation> readByProperty(Property property); @Override Collection<Annotation> readBySemanticTag(URI semanticTagURI); @Override int count(); @Override void create(Annotation identifiable); @Override void create(Collection<Annotation> identifiable); @Override Collection<Annotation> read(); @Override List<Annotation> read(int size, int start); @Override Annotation read(URI uri); @Override void update(Annotation object); @Override void update(Collection<Annotation> object); @Override void delete(Annotation object);  }