Exemple #1
0
 @Override
 String process(Block block, State state) {
   String first = block.lines.get(0);
   String id = "";
   if (first.length() > 8) {
     id = first.substring(first.indexOf("graph") + 5).trim();
     if (id.indexOf(':') != -1) {
       id = first.substring(first.indexOf(':') + 1).trim();
     }
   }
   GraphvizWriter writer =
       new GraphvizWriter(AsciiDocSimpleStyle.withAutomaticRelationshipTypeColors());
   ByteArrayOutputStream out = new ByteArrayOutputStream();
   try (Transaction tx = state.database.beginTx()) {
     writer.emit(out, Walker.fullGraph(state.database));
     tx.success();
   } catch (IOException e) {
     e.printStackTrace();
   }
   StringBuilder output = new StringBuilder(512);
   try {
     String dot = out.toString("UTF-8");
     output
         .append("[\"dot\", \"cypherdoc-")
         .append(id)
         .append('-')
         .append(Integer.toHexString(dot.hashCode()))
         .append(".svg\", \"neoviz\"]\n----\n")
         .append(dot)
         .append("----\n");
   } catch (UnsupportedEncodingException e) {
     e.printStackTrace();
   }
   return output.toString();
 }
  @Test
  public void test() throws Exception {
    OwlLoadConfiguration config = new OwlLoadConfiguration();
    Neo4jConfiguration neo4jConfig = new Neo4jConfiguration();
    neo4jConfig.setLocation(folder.getRoot().getAbsolutePath());
    config.setGraphConfiguration(neo4jConfig);
    OntologySetup ontSetup = new OntologySetup();
    ontSetup.setUrl("http://127.0.0.1:10000/main.owl");
    config.getOntologies().add(ontSetup);
    BatchOwlLoader.load(config);

    GraphDatabaseService graphDb =
        new GraphDatabaseFactory().newEmbeddedDatabase(folder.getRoot().toString());
    graphDb.beginTx();
    GraphvizWriter writer = new GraphvizWriter();
    Walker walker = Walker.fullGraph(graphDb);
    writer.emit(new File("/tmp/test.dot"), walker);
  }
Exemple #3
0
 void drawGraph() throws IOException {
   GraphvizWriter writer = new GraphvizWriter();
   Walker walker = Walker.fullGraph(graphDb);
   new File("target/owl_cases").mkdirs();
   writer.emit(new File("target/owl_cases/" + getTestName() + ".dot"), walker);
 }