OWLGsonRenderer { public void render(OWLAxiom a) { writer.println(gson.toJson(convert(a))); } OWLGsonRenderer(PrintWriter writer); Object convert(OWLImportsDeclaration obj); Object convert(OWLObject obj); Object convert(OWLOntology ont); Object convert(OWLAxiom a); void render(OWLAxiom a); void render(OWLGraphEdge a); void render(OWLOntology a); void render(Set a); void flush(); Object convert(OWLGraphEdge edge); static void main(String[] args);  }
@Test public void testAxioms() throws Exception{ OWLGraphWrapper wrapper = getOBO2OWLOntologyWrapper("caro.obo"); final StringWriter stringWriter = new StringWriter(); OWLGsonRenderer gr = new OWLGsonRenderer(new PrintWriter(stringWriter)); OWLOntology ont = wrapper.getSourceOntology(); for (OWLAxiom a : ont.getAxioms()) { gr.render(a); } if (RENDER_FLAG) { LOG.debug(stringWriter.toString()); } }
@Test public void testGEdges() throws Exception{ OWLGraphWrapper wrapper = getOBO2OWLOntologyWrapper("caro.obo"); final StringWriter stringWriter = new StringWriter(); OWLGsonRenderer gr = new OWLGsonRenderer(new PrintWriter(stringWriter)); OWLOntology ont = wrapper.getSourceOntology(); for (OWLClass c : ont.getClassesInSignature()) { for (OWLGraphEdge e : wrapper.getOutgoingEdgesClosure(c)) { gr.render(e); } } if (RENDER_FLAG) { LOG.debug(stringWriter.toString()); } }
@Test public void testOnt() throws Exception{ OWLGraphWrapper wrapper = getOBO2OWLOntologyWrapper("caro.obo"); final StringWriter stringWriter = new StringWriter(); OWLGsonRenderer gr = new OWLGsonRenderer(new PrintWriter(stringWriter)); gr.render(wrapper.getSourceOntology()); if (RENDER_FLAG) { LOG.debug(stringWriter.toString()); ParserWrapper pw = new ParserWrapper(); OWLDocumentFormat owlFormat = new OWLJSONFormat(); File foo = folder.newFile("foo.json"); pw.saveOWL(wrapper.getSourceOntology(), owlFormat , foo.getAbsolutePath()); } }