@Override public long id( PropertyContainer entity ) { return ((Relationship) entity).getId(); } };
@Override public String getIdentity() { return Long.toString( rel.getId() ); }
@Override long getId( Path source ) { return source.lastRelationship().getId(); }
@SuppressWarnings( "boxing" ) public IndexedEntityRepresentation( Relationship rel, String key, String value, IndexRepresentation indexRepresentation ) { this( new RelationshipRepresentation( rel ), rel.getId(), key, value, indexRepresentation ); }
public int compareTo( Object rel ) { Relationship r = (Relationship) rel; return Long.compare( this.getId(), r.getId() ); }
@Override public boolean equals( Object o ) { return o instanceof Relationship && this.getId() == ((Relationship) o).getId(); }
private static void getRelationshipByIdReadOnly( long index ) { Relationship value = graphDbReadOnly.getRelationshipById( index ); fail( String.format( "Returned Relationship [0x%x] for index 0x%x (int value: 0x%x)", value.getId(), index, (int) index ) ); } }
private static Relationship mockRelationship( long id, Node start, String type, Node end, Properties properties ) { Relationship relationship = mockPropertyContainer( Relationship.class, properties ); when( relationship.getId() ).thenReturn( id ); when( relationship.getStartNode() ).thenReturn( start ); when( relationship.getEndNode() ).thenReturn( end ); when( relationship.getType() ).thenReturn( RelationshipType.withName( type ) ); return relationship; }
@Test public void correctlySaysRelIsDeleted() { // Given state.relationshipDoDelete( 1L, 1, 1L, 2L ); Relationship rel = mock( Relationship.class ); when( rel.getId() ).thenReturn( 1L ); ops.withRelationship( 1L, 1L, 1, 2L ); // When & Then assertThat( snapshot().isDeleted( rel ), equalTo( true ) ); }
private static Function<Node,StartRelationship> loop( String type ) { return node -> { RelationshipType relType = withName( type ); return new StartRelationship( node.createRelationshipTo( node, relType ).getId(), Direction.BOTH, relType ); }; } }
@Override protected long createPropertyContainer() { return db.createNode().createRelationshipTo( db.createNode(), withName( "FOO" ) ).getId(); }
long createRelationshipWithProperty( long firstNodeId, long secondNodeId, String propertyKey, Object propertyValue ) { Node first = db.getNodeById( firstNodeId ); Node second = db.getNodeById( secondNodeId ); Relationship relationship = first.createRelationshipTo( second, RELTYPE ); relationship.setProperty( propertyKey, propertyValue ); return relationship.getId(); }
private static long createRelationship( GraphDatabaseService db ) { long relationshipId; try ( Transaction tx = db.beginTx() ) { Node start = db.createNode( Label.label( System.currentTimeMillis() + "" ) ); Node end = db.createNode( Label.label( System.currentTimeMillis() + "" ) ); relationshipId = start.createRelationshipTo( end, withName( "KNOWS" ) ).getId(); tx.success(); } return relationshipId; }
private static Function<Node,StartRelationship> outgoing( String type ) { return node -> { GraphDatabaseService db = node.getGraphDatabase(); RelationshipType relType = withName( type ); return new StartRelationship( node.createRelationshipTo( db.createNode(), relType ).getId(), Direction.OUTGOING, relType ); }; }
private static Function<Node,StartRelationship> incoming( String type ) { return node -> { GraphDatabaseService db = node.getGraphDatabase(); RelationshipType relType = withName( type ); return new StartRelationship( db.createNode().createRelationshipTo( node, relType ).getId(), Direction.INCOMING, relType ); }; }
private Runnable getById() { return () -> { dbr.getGraphDatabaseAPI().getNodeById( node.getId() ); dbr.getGraphDatabaseAPI().getRelationshipById( relationship.getId() ); }; }
private long initWithRel( GraphDatabaseService db ) { try ( Transaction tx = db.beginTx() ) { Node node = db.createNode(); node.setProperty( "a", "prop" ); Relationship rel = node.createRelationshipTo( db.createNode(), RelationshipType.withName( "T" ) ); long id = rel.getId(); tx.success(); return id; } }
@Test @Title( "Remove properties from a relationship" ) @Graph( nodes = {@NODE( name = "Romeo", setNameProperty = true ), @NODE( name = "Juliet", setNameProperty = true )}, relationships = { @REL( start = "Romeo", end = "Juliet", type = "LOVES", properties = { @PROP( key = "cost", value = "high", type = GraphDescription.PropType.STRING )} )} ) public void shouldReturn204WhenPropertiesAreRemovedFromRelationship() { Relationship loves = getFirstRelationshipFromRomeoNode(); gen().expectedStatus( Status.NO_CONTENT.getStatusCode() ) .delete( functionalTestHelper.relationshipPropertiesUri( loves.getId() ) ).entity(); }
public long createRelationship( String type, long startNodeId, long endNodeId ) { try ( Transaction tx = database.getGraph().beginTransaction( implicit, AnonymousContext.writeToken() ) ) { Node startNode = database.getGraph().getNodeById( startNodeId ); Node endNode = database.getGraph().getNodeById( endNodeId ); Relationship relationship = startNode.createRelationshipTo( endNode, RelationshipType.withName( type ) ); tx.success(); return relationship.getId(); } }