use of org.neo4j.values.virtual.RelationshipValue in project neo4j by neo4j.
the class PathValueBuilder method addMultipleIncoming.
/**
* Adds multiple incoming relationships to the path
*
* @param relationships the incoming relationships to add
* @param target the final target node of the path
*/
@CalledFromGeneratedCode
public void addMultipleIncoming(ListValue relationships, NodeValue target) {
if (relationships.isEmpty()) {
// nothing to do here
return;
}
int i;
for (i = 0; i < relationships.size() - 1; i++) {
AnyValue value = relationships.value(i);
if (notNoValue(value)) {
RelationshipValue relationship = (RelationshipValue) value;
nodes.add(relationship.startNode());
rels.add(relationship);
}
}
AnyValue last = relationships.value(i);
if (notNoValue(last)) {
rels.add((RelationshipValue) last);
nodes.add(target);
}
}
use of org.neo4j.values.virtual.RelationshipValue in project neo4j by neo4j.
the class PathValueBuilder method addMultipleOutgoing.
/**
* Adds multiple outgoing relationships to the path
*
* @param relationships the outgoing relationships to add
*/
@CalledFromGeneratedCode
public void addMultipleOutgoing(ListValue relationships) {
for (AnyValue value : relationships) {
if (notNoValue(value)) {
// we know these relationships have already loaded start and end relationship
// so we should not use CypherFunctions::[start,end]Node to look them up
RelationshipValue relationship = (RelationshipValue) value;
nodes.add(relationship.endNode());
rels.add(relationship);
}
}
}
use of org.neo4j.values.virtual.RelationshipValue in project neo4j by neo4j.
the class PathValueBuilder method addMultipleIncoming.
/**
* Adds multiple incoming relationships to the path
*
* @param relationships the incoming relationships to add
*/
@CalledFromGeneratedCode
public void addMultipleIncoming(ListValue relationships) {
for (AnyValue value : relationships) {
if (notNoValue(value)) {
// we know these relationships have already loaded start and end relationship
// so we should not use CypherFunctions::[start,end]Node to look them up
RelationshipValue relationship = (RelationshipValue) value;
nodes.add(relationship.startNode());
rels.add(relationship);
}
}
}
use of org.neo4j.values.virtual.RelationshipValue in project neo4j by neo4j.
the class PathValueBuilder method addMultipleOutgoing.
/**
* Adds multiple outgoing relationships to the path
*
* @param relationships the outgoing relationships to add
* @param target the final target node of the path
*/
@CalledFromGeneratedCode
public void addMultipleOutgoing(ListValue relationships, NodeValue target) {
if (relationships.isEmpty()) {
// nothing to do here
return;
}
int i;
for (i = 0; i < relationships.size() - 1; i++) {
AnyValue value = relationships.value(i);
if (notNoValue(value)) {
// we know these relationships have already loaded start and end relationship
// so we should not use CypherFunctions::[start,end]Node to look them up
RelationshipValue relationship = (RelationshipValue) value;
nodes.add(relationship.endNode());
rels.add(relationship);
}
}
AnyValue last = relationships.value(i);
if (notNoValue(last)) {
rels.add((RelationshipValue) last);
nodes.add(target);
}
}
use of org.neo4j.values.virtual.RelationshipValue in project neo4j by neo4j.
the class SchemaProcedureIT method testRelationShip.
@Test
void testRelationShip() throws Throwable {
// Given there ar
KernelTransaction transaction = newTransaction(AnonymousContext.writeToken());
long nodeIdPerson = transaction.dataWrite().nodeCreate();
int labelIdPerson = transaction.tokenWrite().labelGetOrCreateForName("Person");
transaction.dataWrite().nodeAddLabel(nodeIdPerson, labelIdPerson);
long nodeIdLocation = transaction.dataWrite().nodeCreate();
int labelIdLocation = transaction.tokenWrite().labelGetOrCreateForName("Location");
transaction.dataWrite().nodeAddLabel(nodeIdLocation, labelIdLocation);
int relationshipTypeId = transaction.tokenWrite().relationshipTypeGetOrCreateForName("LIVES_IN");
transaction.dataWrite().relationshipCreate(nodeIdPerson, relationshipTypeId, nodeIdLocation);
commit();
RawIterator<AnyValue[], ProcedureException> stream = procs().procedureCallRead(procs().procedureGet(procedureName("db", "schema", "visualization")).id(), new AnyValue[0], ProcedureCallContext.EMPTY);
// Then
while (stream.hasNext()) {
AnyValue[] next = stream.next();
assertEquals(2, next.length);
ListValue relationships = (ListValue) next[1];
assertEquals(1, relationships.size());
RelationshipValue relationship = (RelationshipValue) relationships.value(0);
assertEquals("LIVES_IN", relationship.type().stringValue());
assertThat(relationship.startNode().labels()).isEqualTo(Values.stringArray("Person"));
assertThat(relationship.endNode().labels()).isEqualTo(Values.stringArray("Location"));
}
}
Aggregations