Package org.neo4j.graphdb

Examples of org.neo4j.graphdb.Node


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

  @Override
  public Tuple getTuple(EntityKey key, TupleContext context) {
    Node entityNode = entityQueries.get( key.getMetadata() ).findEntity( executionEngine, key.getColumnValues() );
    if ( entityNode == null ) {
      return null;
    }
    return createTuple( entityNode, context );
  }
View Full Code Here


    return new Tuple( new Neo4jTupleSnapshot( entityNode, tupleContext.getAllAssociatedEntityKeyMetadata(), tupleContext.getAllRoles() ) );
  }

  @Override
  public void insertOrUpdateTuple(EntityKey key, Tuple tuple, TupleContext tupleContext) {
    Node node = entityQueries.get( key.getMetadata() ).findOrCreateEntity( executionEngine, key.getColumnValues() );
    applyTupleOperations( key, tuple, node, tuple.getOperations(), tupleContext );
    GraphLogger.log( "Inserted/Updated node: %1$s", node );
  }
View Full Code Here

    }
  }

  private Relationship createRelationshipWithEmbeddedNode(AssociationKey associationKey, Tuple associationRow, AssociatedEntityKeyMetadata associatedEntityKeyMetadata) {
    EntityKey entityKey = getEntityKey( associationRow, associatedEntityKeyMetadata );
    Node embeddedNode = entityQueries.get( entityKey.getMetadata() ).createEmbedded( executionEngine, entityKey.getColumnValues() );
    Relationship relationship = createRelationshipWithTargetNode( associationKey, associationRow, embeddedNode );
    applyProperties( associationKey, associationRow, relationship );
    return relationship;
  }
View Full Code Here

    return relationship;
  }

  private Relationship findOrCreateRelationshipWithEntityNode(AssociationKey associationKey, Tuple associationRow, AssociatedEntityKeyMetadata associatedEntityKeyMetadata) {
    EntityKey targetEntityKey = getEntityKey( associationRow, associatedEntityKeyMetadata );
    Node targetNode = entityQueries.get( targetEntityKey.getMetadata() ).findEntity( executionEngine, targetEntityKey.getColumnValues() );
    return createRelationshipWithTargetNode( associationKey, associationRow, targetNode );
  }
View Full Code Here

    }
  }

  private Relationship createRelationshipWithTargetNode(AssociationKey associationKey, Tuple associationRow, Node targetNode) {
    EntityKey entityKey = associationKey.getEntityKey();
    Node ownerNode = entityQueries.get( entityKey.getMetadata() ).findEntity( executionEngine, entityKey.getColumnValues() );
    Relationship relationship = ownerNode.createRelationshipTo( targetNode, withName( associationKey.getMetadata().getCollectionRole() ) );
    applyProperties( associationKey, associationRow, relationship );
    return relationship;
  }
View Full Code Here

  }

  @Override
  public Association getAssociation(AssociationKey associationKey, AssociationContext associationContext) {
    EntityKey entityKey = associationKey.getEntityKey();
    Node entityNode = entityQueries.get( entityKey.getMetadata() ).findEntity( executionEngine, entityKey.getColumnValues() );
    GraphLogger.log( "Found owner node: %1$s", entityNode );
    if ( entityNode == null ) {
      return null;
    }
    return new Association(
View Full Code Here

        if ( relationships.hasNext() ) {
          relationships.next().delete();
        }

        // create a new relationship
        Node targetNode = entityQueries.get( targetKey.getMetadata() ).findEntity( executionEngine, targetKey.getColumnValues() );
        node.createRelationshipTo( targetNode, withName( associationRole ) );
      }
    }
  }
View Full Code Here

  public void forEachTuple(ModelConsumer consumer, EntityKeyMetadata... entityKeyMetadatas) {
    for ( EntityKeyMetadata entityKeyMetadata : entityKeyMetadatas ) {
      ResourceIterator<Node> queryNodes = entityQueries.get( entityKeyMetadata ).findEntities( executionEngine );
      try {
        while ( queryNodes.hasNext() ) {
          Node next = queryNodes.next();
          Tuple tuple = new Tuple( new Neo4jTupleSnapshot( next ) );
          consumer.consume( tuple );
        }
      }
      finally {
View Full Code Here

  }

  private static Map<String, Object> collectProperties(Relationship relationship, AssociationKey associationKey, AssociatedEntityKeyMetadata associatedEntityKeyMetadata) {
    Map<String, Object> properties = new HashMap<String, Object>();
    String[] rowKeyColumnNames = associationKey.getMetadata().getRowKeyColumnNames();
    Node ownerNode = ownerNode( associationKey, relationship );
    Node targetNode = relationship.getOtherNode( ownerNode );

    // Index columns
    for ( int i = 0; i < rowKeyColumnNames.length; i++ ) {
      if ( relationship.hasProperty( rowKeyColumnNames[i] ) ) {
        properties.put( rowKeyColumnNames[i], relationship.getProperty( rowKeyColumnNames[i] ) );
      }
    }

    // Properties stored in the target side of the association
    for ( String associationColumn : associatedEntityKeyMetadata.getAssociationKeyColumns() ) {
      String targetColumnName = associatedEntityKeyMetadata.getCorrespondingEntityKeyColumn( associationColumn );
      if ( targetNode.hasProperty( targetColumnName ) ) {
        properties.put( associationColumn, targetNode.getProperty( targetColumnName ) );
      }
    }

    // Property stored in the owner side of the association
    for ( int i = 0; i < associationKey.getColumnNames().length; i++ ) {
View Full Code Here

  private Object readPropertyOnOtherNode(String column) {
    Iterator<Relationship> relationships = node.getRelationships( Direction.OUTGOING, withName( rolesByColumn.get( column ) ) ).iterator();

    if ( relationships.hasNext() ) {
      Node otherNode = relationships.next().getEndNode();
      return readProperty( otherNode, associatedEntityKeyMetadata.get( column ).getCorrespondingEntityKeyColumn( column ) );
    }

    return null;
  }
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.