@Override public Node endNode() { return new NodeProxy( proxySPI, nodes[nodes.length - 1] ); }
@Override public String toString() { return "Node[" + this.getId() + "]"; }
private ResourceIterable<Relationship> innerGetRelationships( KernelTransaction transaction, final Direction direction, int[] typeIds ) { return () -> getRelationshipSelectionIterator( transaction, direction, typeIds ); }
@Override public ResourceIterable<Relationship> getRelationships( final Direction direction ) { KernelTransaction transaction = safeAcquireTransaction(); return innerGetRelationships( transaction, direction, null ); }
@Override public boolean hasRelationship( Direction direction ) { KernelTransaction transaction = safeAcquireTransaction(); return innerHasRelationships( transaction, direction, null ); }
@Override public ResourceIterable<Relationship> getRelationships( final Direction direction, RelationshipType... types ) { KernelTransaction transaction = safeAcquireTransaction(); int[] typeIds = relTypeIds( types, transaction.tokenRead() ); return innerGetRelationships( transaction, direction, typeIds ); }
@Override public void delete() { KernelTransaction transaction = safeAcquireTransaction(); try { boolean deleted = transaction.dataWrite().nodeDelete( getId() ); if ( !deleted ) { throw new NotFoundException( "Unable to delete Node[" + nodeId + "] since it has already been deleted." ); } } catch ( InvalidTransactionTypeKernelException e ) { throw new ConstraintViolationException( e.getMessage(), e ); } catch ( AutoIndexingKernelException e ) { throw new IllegalStateException( "Auto indexing encountered a failure while deleting the node: " + e.getMessage(), e ); } }
@Override public boolean hasRelationship( Direction direction, RelationshipType... types ) { KernelTransaction transaction = safeAcquireTransaction(); int[] typeIds = relTypeIds( types, transaction.tokenRead() ); return innerHasRelationships( transaction, direction, typeIds ); }
@Override public ResourceIterable<Relationship> getRelationships( RelationshipType... types ) { return getRelationships( Direction.BOTH, types ); }
@Override public boolean hasRelationship() { return hasRelationship( Direction.BOTH ); }
@Override public void delete() { KernelTransaction transaction = safeAcquireTransaction(); try { boolean deleted = transaction.dataWrite().nodeDelete( getId() ); if ( !deleted ) { throw new NotFoundException( "Unable to delete Node[" + nodeId + "] since it has already been deleted." ); } } catch ( InvalidTransactionTypeKernelException e ) { throw new ConstraintViolationException( e.getMessage(), e ); } catch ( AutoIndexingKernelException e ) { throw new IllegalStateException( "Auto indexing encountered a failure while deleting the node: " + e.getMessage(), e ); } }
@Override public ResourceIterable<Relationship> getRelationships( final Direction direction, RelationshipType... types ) { KernelTransaction transaction = safeAcquireTransaction(); int[] typeIds = relTypeIds( types, transaction.tokenRead() ); return innerGetRelationships( transaction, direction, typeIds ); }
@Override public boolean hasRelationship( Direction direction, RelationshipType... types ) { KernelTransaction transaction = safeAcquireTransaction(); int[] typeIds = relTypeIds( types, transaction.tokenRead() ); return innerHasRelationships( transaction, direction, typeIds ); }
@Override public ResourceIterable<Relationship> getRelationships() { return getRelationships( Direction.BOTH ); }
@Override public ResourceIterable<Relationship> getRelationships( final Direction direction ) { KernelTransaction transaction = safeAcquireTransaction(); return innerGetRelationships( transaction, direction, null ); }
@Override public boolean hasRelationship( Direction direction ) { KernelTransaction transaction = safeAcquireTransaction(); return innerHasRelationships( transaction, direction, null ); }
@Override public boolean hasRelationship( RelationshipType... types ) { return hasRelationship( Direction.BOTH, types ); }
@Override public Node startNode() { return new NodeProxy( proxySPI, nodes[0] ); }
@Override public boolean equals( Object o ) { return o instanceof Node && this.getId() == ((Node) o).getId(); }
@Override public ResourceIterable<Relationship> getRelationships( RelationshipType type, Direction dir ) { return getRelationships( dir, type ); }