Search in sources :

Example 1 with InternalEntity

use of org.neo4j.driver.internal.InternalEntity in project neo4j-apoc-procedures by neo4j-contrib.

the class Bolt method toRelationship.

private Object toRelationship(Object value, boolean virtual, Map<Long, Object> nodesCache) {
    Value internalValue = ((InternalEntity) value).asValue();
    Relationship relationship = internalValue.asRelationship();
    if (virtual) {
        VirtualNode start = (VirtualNode) nodesCache.getOrDefault(relationship.startNodeId(), new VirtualNode(relationship.startNodeId(), db));
        VirtualNode end = (VirtualNode) nodesCache.getOrDefault(relationship.endNodeId(), new VirtualNode(relationship.endNodeId(), db));
        VirtualRelationship virtualRelationship = new VirtualRelationship(relationship.id(), start, end, RelationshipType.withName(relationship.type()), relationship.asMap());
        return virtualRelationship;
    } else
        return Util.map("entityType", internalValue.type().name(), "type", relationship.type(), "id", relationship.id(), "start", relationship.startNodeId(), "end", relationship.endNodeId(), "properties", relationship.asMap());
}
Also used : VirtualRelationship(apoc.result.VirtualRelationship) InternalEntity(org.neo4j.driver.internal.InternalEntity) VirtualNode(apoc.result.VirtualNode) VirtualRelationship(apoc.result.VirtualRelationship) Relationship(org.neo4j.driver.v1.types.Relationship)

Example 2 with InternalEntity

use of org.neo4j.driver.internal.InternalEntity in project neo4j-apoc-procedures by neo4j-contrib.

the class Bolt method toNode.

private Object toNode(Object value, boolean virtual, Map<Long, Object> nodesCache) {
    Value internalValue = ((InternalEntity) value).asValue();
    Node node = internalValue.asNode();
    if (virtual) {
        List<Label> labels = new ArrayList<>();
        node.labels().forEach(l -> labels.add(Label.label(l)));
        VirtualNode virtualNode = new VirtualNode(node.id(), labels.toArray(new Label[0]), node.asMap(), db);
        nodesCache.put(node.id(), virtualNode);
        return virtualNode;
    } else
        return Util.map("entityType", internalValue.type().name(), "labels", node.labels(), "id", node.id(), "properties", node.asMap());
}
Also used : InternalEntity(org.neo4j.driver.internal.InternalEntity) VirtualNode(apoc.result.VirtualNode) VirtualNode(apoc.result.VirtualNode) Node(org.neo4j.driver.v1.types.Node) Label(org.neo4j.graphdb.Label)

Aggregations

VirtualNode (apoc.result.VirtualNode)2 InternalEntity (org.neo4j.driver.internal.InternalEntity)2 VirtualRelationship (apoc.result.VirtualRelationship)1 Node (org.neo4j.driver.v1.types.Node)1 Relationship (org.neo4j.driver.v1.types.Relationship)1 Label (org.neo4j.graphdb.Label)1