Package org.neo4j.graphdb

Examples of org.neo4j.graphdb.Node


   */
  public int nextValue(IdSourceKey idSourceKey, int increment, int initialValue) {
    Transaction tx = neo4jDb.beginTx();
    Lock lock = null;
    try {
      Node sequence = getSequence( idSourceKey );

      if ( sequence == null ) {
        // sequence nodes are expected to have been created up-front
        if ( idSourceKey.getMetadata().getType() == IdSourceType.SEQUENCE ) {
          throw new HibernateException( "Sequence missing: " + idSourceKey.getMetadata().getName() );
View Full Code Here


   */
  private Node getSequence(IdSourceKey idSourceKey) {
    String updateSequenceQuery = getQuery( idSourceKey );
    ExecutionResult result = engine.execute( updateSequenceQuery, singletonMap( SEQUENCE_NAME_QUERY_PARAM, (Object) sequenceName( idSourceKey ) ) );
    ResourceIterator<Node> column = result.columnAs( "n" );
    Node node = null;
    if ( column.hasNext() ) {
      node = column.next();
    }
    column.close();
    return node;
View Full Code Here

        assertEquals("["+node.getId()+"|name root;],", res);
    }
    @Test
    public void testNamedGraphToYuml() throws Exception {
        node.setProperty("name", "root");
        final Node n1 = gdb.createNode();
        n1.setProperty("name", "Peter");
        node.createRelationshipTo(n1, DynamicRelationshipType.withName("PERSON"));
        final Node n2 = gdb.createNode();
        n2.setProperty("name", "Andreas");
        node.createRelationshipTo(n2, DynamicRelationshipType.withName("PERSON"));
        final Node n3 = gdb.createNode();
        n3.setProperty("name","Michael");
        node.createRelationshipTo(n3, DynamicRelationshipType.withName("PERSON"));
        n1.createRelationshipTo(n2, DynamicRelationshipType.withName("FRIEND"));
        n3.createRelationshipTo(n1, DynamicRelationshipType.withName("FRIEND"));
        final String res = new YumlExport().toYuml(SubGraph.from(gdb), "name");
        System.out.println("res = " + res);
        assertEquals(true, res.contains("[Peter]FRIEND->[Andreas],"));
        assertEquals(true,res.contains("[root],[Peter],[Andreas],[Michael],"));
    }
View Full Code Here

        System.out.println("res = " + res);
        assertEquals("[root],", res);
    }
    @Test
    public void testGraphToYuml() throws Exception {
        final Node n1 = gdb.createNode();
        node.createRelationshipTo(n1, DynamicRelationshipType.withName("REL"));
        final String res = new YumlExport().toYuml(SubGraph.from(gdb));
        assertEquals("["+node.getId()+"],["+n1.getId()+"],["+node.getId()+"]REL->["+n1.getId()+"],", res);
    }
View Full Code Here

    public void testUpdate() throws Exception {
        final GraphInfo info = storage.create(new GraphInfo(Util.randomId(), "init", "query", "message"));
        final GraphInfo info2 = info.newQuery("query2");
        storage.update(info2);
        try (Transaction tx = gdb.beginTx()) {
            final Node node = index.get("id", info.getId()).getSingle();
            assertNotNull(node);
            assertEquals("query2", node.getProperty("query"));
            assertEquals(info.getId(), node.getProperty("id"));
            assertEquals(info.getInit(), node.getProperty("init"));
            assertEquals(info.getMessage(),node.getProperty("message"));
            delete(node);
            tx.success();
        }

        try (Transaction tx2 = gdb.beginTx()) {
View Full Code Here

    }
    @Test
    public void testCreateWithVersion() throws Exception {
        final GraphInfo info = storage.create(new GraphInfo(Util.randomId(), "init", "query", "message","version"));
        Transaction tx = gdb.beginTx();
        final Node node = index.get("id", info.getId()).getSingle();
        assertNotNull(node);
        assertEquals(info.getId(), node.getProperty("id"));
        assertEquals(info.getVersion(),node.getProperty("version"));
        tx.success();tx.close();
    }
View Full Code Here

    @Test
    public void testCreateWithNoRoot() throws Exception {
        final GraphInfo info = storage.create(new GraphInfo(Util.randomId(), "init", "query", "message","version",true));
        Transaction tx = gdb.beginTx();
        final Node node = index.get("id", info.getId()).getSingle();
        assertNotNull(node);
        assertEquals(info.getId(), node.getProperty("id"));
        assertEquals(info.getVersion(),node.getProperty("version"));
        assertEquals(!info.hasRoot(),(Boolean)node.getProperty("no_root"));
        tx.success();tx.close();
    }
View Full Code Here

    @Test
    public void testCreateWithNullId() throws Exception {
        final GraphInfo info = storage.create(new GraphInfo(null, "init", "query", "message"));
        Transaction tx = gdb.beginTx();
        assertNotNull(info.getId());
        final Node node = index.get("id", info.getId()).getSingle();
        assertNotNull(node);
        assertEquals(info.getId(), node.getProperty("id"));
        tx.success();tx.close();
    }
View Full Code Here

        final GraphInfo info = storage.create(new GraphInfo(id, "init", "query", "message"));
        Transaction tx = gdb.beginTx();
        assertNotNull(info.getId());
        assertNotSame(id,info.getId());
        assertFalse(info.getId().trim().isEmpty());
        final Node node = index.get("id", info.getId()).getSingle();
        assertNull(index.get("id", id).getSingle());
        assertNotNull(node);
        assertEquals(info.getId(), node.getProperty("id"));
        tx.success();tx.close();
    }
View Full Code Here

        final GraphInfo info = storage.create(new GraphInfo(id, "init", "query", "message"));
        Transaction tx = gdb.beginTx();
        assertNotNull(info.getId());
        assertNotSame(id,info.getId());
        assertFalse(info.getId().trim().isEmpty());
        final Node node = index.get("id", info.getId()).getSingle();
        assertNull(index.get("id", id).getSingle());
        assertNotNull(node);
        assertEquals(info.getId(), node.getProperty("id"));
        tx.success();tx.close();
    }
View Full Code Here

TOP

Related Classes of org.neo4j.graphdb.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.