コード例 #1
0
 private Node addNode(EmbeddedGraphDatabase graphDb) {
   Node referenceNode = graphDb.getReferenceNode();
   Node node = graphDb.createNode();
   node.setProperty("theId", node.getId());
   referenceNode.createRelationshipTo(node, MyRels.TEST);
   return node;
 }
コード例 #2
0
 public void verify(String dbPath) {
   EmbeddedGraphDatabase graphDb = new EmbeddedGraphDatabase(dbPath);
   assertEquals(
       "Reference node did not have zero relationships.",
       0,
       IteratorUtil.count(graphDb.getReferenceNode().getRelationships()));
   assertEquals("There was more than one node.", 1, IteratorUtil.count(graphDb.getAllNodes()));
   graphDb.shutdown();
 }
コード例 #3
0
  public void generate(String dbPath) {
    EmbeddedGraphDatabase graphDb = new EmbeddedGraphDatabase(dbPath);
    Index<Node> nodeIndex = graphDb.index().forNodes("nodes");
    Index<Relationship> relationshipIndex = graphDb.index().forRelationships("relationships");
    graphDb.beginTx();
    Node n = graphDb.createNode();
    Relationship rel = graphDb.getReferenceNode().createRelationshipTo(n, REL_TYPE);

    nodeIndex.add(n, "name", "a");
    relationshipIndex.add(rel, "name", "a");
  }
    @Override
    public void run(EmbeddedGraphDatabase graphdb) {
      Node node = graphdb.getReferenceNode();
      Transaction tx = graphdb.beginTx();
      try {
        // First do the index operations, to add that data source first
        graphdb.index().forNodes("nodes").add(node, "value", "indexed");
        // Then update the graph
        node.setProperty("value", "indexed");

        enableBreakPoint();

        tx.success();
      } finally {
        tx.finish();
      }
      done();
    }
コード例 #5
0
  protected void tryBackup(EmbeddedGraphDatabase graphDb, String location, int relCount)
      throws IOException {
    setupBackup(graphDb, location);

    EmbeddedGraphDatabase bDb = Util.startGraphDbInstance(location);
    IndexService bIndexService = new LuceneIndexService(bDb);
    Transaction bTx = bDb.beginTx();
    try {
      List<Relationship> rels = new ArrayList<Relationship>();
      for (Relationship rel : bDb.getReferenceNode().getRelationships()) {
        rels.add(rel);
      }
      assertEquals(relCount, rels.size());
      Node node = bIndexService.getSingleNode("number", relCount);
      assertEquals(true, node != null);
      assertEquals(node.getId(), (long) (Long) node.getProperty("theId", -1L));
      bTx.success();
    } finally {
      bTx.finish();
    }
    Util.stopGraphDb(bDb, bIndexService);
  }
コード例 #6
0
 public Node getReferenceNode() {
   return inner.getReferenceNode();
 }