Package org.neo4j.graphdb

Examples of org.neo4j.graphdb.Relationship


  }

  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


  }

  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

      break;
    }
  }

  private void putAssociationOperation(Association association, AssociationKey associationKey, AssociationOperation action, AssociatedEntityKeyMetadata associatedEntityKeyMetadata) {
    Relationship relationship = associationQueries.get( associationKey.getMetadata() ).findRelationship( executionEngine, associationKey, action.getKey() );

    if (relationship != null) {
      for ( String relationshipProperty : associationKey.getMetadata().getRowKeyIndexColumnNames() ) {
        relationship.setProperty( relationshipProperty, action.getValue().get( relationshipProperty ) );

      }
      GraphLogger.log( "Updated relationship: %1$s", relationship );
    }
    else {
View Full Code Here

        }
        if (value instanceof Node) {
            return value.toString() + props((PropertyContainer) value);
        }
        if (value instanceof Relationship) {
            Relationship rel = (Relationship) value;
            return ":" + rel.getType().name() + "[" + rel.getId() + "] " + props(rel);
        }
        if (value instanceof Iterable) {
            return formatIterator(((Iterable) value).iterator());
        }
        if (value.getClass().isArray()) {
View Full Code Here

    query.append( " - " );
    query.append( relationshipCypher( associationKey, rowKey, parameters, entityKey.getColumnNames().length ) );
    query.append( " -> () RETURN r" );
    ExecutionResult result = engine.execute( query.toString(), parameters );
    ResourceIterator<Relationship> column = result.columnAs( "r" );
    Relationship relationship = null;
    if ( column.hasNext() ) {
      relationship = column.next();
    }
    column.close();
    return relationship;
View Full Code Here

        keyColumnValues.toArray( new Object[keyColumnValues.size()] ) );
  }

  private Relationship deleteTempNodeAndUpdateRelationshipWithEntity(AssociationKey associationKey, RowKey rowKey, Node rowKeyNode) {
    Node ownerNode = neo4jCRUD.findNode( associationKey.getEntityKey(), ENTITY );
    Relationship inverseRelationship = updateInverseRelationship( rowKey, rowKeyNode, ownerNode );

    RelationshipType associationType = relationshipType( associationKey );
    Relationship relationship = null;
    if ( !associationKey.getCollectionRole().equals( associationKey.getTable() ) ) {
      relationship = ownerNode.createRelationshipTo( inverseRelationship.getStartNode(), associationType );
      applyColumnValues( rowKey, relationship );
    }
    return relationship;
View Full Code Here

    }
    return relationship;
  }

  private Relationship updateInverseRelationship(RowKey rowKey, Node rowKeyNode, Node ownerNode) {
    Relationship inverseRelationship = rowKeyNode.getRelationships( Direction.INCOMING ).iterator().next();
    Relationship newInverseRelationship = inverseRelationship.getStartNode().createRelationshipTo( ownerNode, inverseRelationship.getType() );
    applyColumnValues( rowKey, newInverseRelationship );
    inverseRelationship.delete();
    inverseRelationship.getEndNode().delete();
    return newInverseRelationship;
  }
View Full Code Here

  }

  private PropertyContainer createRelationshipWithEntity(AssociationKey associationKey, RowKey rowKey, Node node) {
    EntityKey ownerEntityKey = associationKey.getEntityKey();
    Node ownerNode = neo4jCRUD.findNode( ownerEntityKey, ENTITY );
    Relationship relationship = ownerNode.createRelationshipTo( node, relationshipType( associationKey ) );
    applyColumnValues( rowKey, relationship );
    return relationship;
  }
View Full Code Here

      break;
    }
  }

  private void putAssociationOperation(AssociationKey associationKey, AssociationOperation action) {
    Relationship relationship = neo4jCRUD.findRelationship( associationKey, action.getKey() );
    applyTupleOperations( relationship, action.getValue().getOperations() );
  }
View Full Code Here

  }

  private Relationship deleteTempNodeAndCreateRelationshipWithEntity(AssociationKey associationKey, RowKey rowKey, Node tempNode) {
    Node ownerNode = neo4jCRUD.findNode( associationKey.getEntityKey(), ENTITY );
    Iterator<Relationship> iterator = tempNode.getRelationships( Direction.INCOMING ).iterator();
    Relationship tempRelationship = iterator.next();
    Relationship relationship = ownerNode.createRelationshipTo( tempRelationship.getStartNode(), relationshipType( associationKey ) );
    applyColumnValues( rowKey, relationship );
    tempRelationship.delete();
    tempNode.delete();
    return relationship;
  }
View Full Code Here

TOP

Related Classes of org.neo4j.graphdb.Relationship

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.