Package org.neo4j.graphdb

Examples of org.neo4j.graphdb.Node


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


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

    }

    private void checkImportedNode(String prop, String value) {
        GraphDatabaseService gdb = service.getGraphDatabase();
        try (Transaction tx = gdb.beginTx()) {
            Node imported = IteratorUtil.single(GlobalGraphOperations.at(gdb).getAllNodes());
            assertEquals(value, imported.getProperty(prop));
            tx.success();
        }
    }
View Full Code Here

    StringBuilder query = new StringBuilder( "MATCH" );
    appendNodePattern( key, parameters, query, label );
    query.append( " RETURN n" );
    ExecutionResult result = engine.execute( query.toString(), parameters );
    ResourceIterator<Node> column = result.columnAs( "n" );
    Node node = null;
    if ( column.hasNext() ) {
      node = column.next();
    }
    column.close();
    return node;
View Full Code Here

    StringBuilder query = new StringBuilder( "MERGE" );
    appendNodePattern( key, parameters, query, label );
    query.append( " RETURN n" );
    ExecutionResult result = engine.execute( query.toString(), parameters );
    ResourceIterator<Node> column = result.columnAs( "n" );
    Node node = null;
    if ( column.hasNext() ) {
      node = column.next();
    }
    column.close();
    return node;
View Full Code Here

    }
  }

  @Override
  public Association getAssociation(AssociationKey associationKey, AssociationContext associationContext) {
    Node entityNode = neo4jCRUD.findNode( associationKey.getEntityKey(), ENTITY );
    if ( entityNode == null ) {
      return null;
    }
    return new Association( new Neo4jAssociationSnapshot( entityNode, associationKey ) );
  }
View Full Code Here

  public void forEachTuple(Consumer consumer, EntityKeyMetadata... entityKeyMetadatas) {
    for ( EntityKeyMetadata entityKeyMetadata : entityKeyMetadatas ) {
      ResourceIterator<Node> queryNodes = neo4jCRUD.findNodes( entityKeyMetadata.getTable() );
      try {
        while ( queryNodes.hasNext() ) {
          Node next = queryNodes.next();
          Tuple tuple = createTuple( next );
          consumer.consume( tuple );
        }
      }
      finally {
View Full Code Here

  private int sequence(RowKey rowKey, int increment, final int initialValue) {
    Transaction tx = neo4jDb.beginTx();
    Lock lock = null;
    try {
      Node sequence = getOrCreateSequence( rowKey, initialValue );
      lock = tx.acquireWriteLock( sequence );
      int nextValue = updateSequenceValue( sequenceName( rowKey ), sequence, increment );
      tx.success();
      lock.release();
      return nextValue;
View Full Code Here

    Map<String, Object> parameters = new HashMap<String, Object>( 2 );
    parameters.put( "initialValue", initialValue );
    parameters.put( "sequenceName", sequenceName( rowKey ) );
    ExecutionResult result = engine.execute( updateSequenceQuery, parameters );
    ResourceIterator<Node> column = result.columnAs( "n" );
    Node node = null;
    if ( column.hasNext() ) {
      node = column.next();
    }
    column.close();
    return node;
View Full Code Here

    throw new UnsupportedOperationException( "LockMode " + lockMode + " is not supported by the Neo4j GridDialect" );
  }

  @Override
  public Tuple getTuple(EntityKey key, TupleContext context) {
    Node entityNode = neo4jCRUD.findNode( key, ENTITY );
    if ( entityNode == null ) {
      return null;
    }
    return createTuple( entityNode );
  }
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.