Search in sources :

Example 6 with PathExpanderBuilder

use of org.neo4j.graphdb.PathExpanderBuilder in project neo4j by neo4j.

the class DatabaseActions method getNodeRelationships.

@SuppressWarnings("unchecked")
public ListRepresentation getNodeRelationships(long nodeId, RelationshipDirection direction, Collection<String> types) throws NodeNotFoundException {
    Node node = node(nodeId);
    PathExpander expander;
    if (types.isEmpty()) {
        expander = PathExpanders.forDirection(direction.internal);
    } else {
        PathExpanderBuilder builder = PathExpanderBuilder.empty();
        for (String type : types) {
            builder = builder.add(RelationshipType.withName(type), direction.internal);
        }
        expander = builder.build();
    }
    return RelationshipRepresentation.list(expander.expand(Paths.singleNodePath(node), BranchState.NO_STATE));
}
Also used : Node(org.neo4j.graphdb.Node) PathExpander(org.neo4j.graphdb.PathExpander) PathExpanderBuilder(org.neo4j.graphdb.PathExpanderBuilder)

Aggregations

PathExpanderBuilder (org.neo4j.graphdb.PathExpanderBuilder)6 Map (java.util.Map)4 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 TreeMap (java.util.TreeMap)2 Direction (org.neo4j.graphdb.Direction)2 RelationshipType (org.neo4j.graphdb.RelationshipType)2 ShellException.stackTraceAsString (org.neo4j.shell.ShellException.stackTraceAsString)2 ArrayList (java.util.ArrayList)1 Node (org.neo4j.graphdb.Node)1 Path (org.neo4j.graphdb.Path)1 PathExpander (org.neo4j.graphdb.PathExpander)1 Transaction (org.neo4j.graphdb.Transaction)1 Description (org.neo4j.server.plugins.Description)1 PluginTarget (org.neo4j.server.plugins.PluginTarget)1