Search in sources :

Example 11 with IterableWrapper

use of org.neo4j.helpers.collection.IterableWrapper in project neo4j by neo4j.

the class DatabaseActions method findPaths.

@SuppressWarnings({ "rawtypes", "unchecked" })
public ListRepresentation findPaths(long startId, long endId, Map<String, Object> map) {
    final FindParams findParams = new FindParams(startId, endId, map).invoke();
    PathFinder finder = findParams.getFinder();
    Node startNode = findParams.getStartNode();
    Node endNode = findParams.getEndNode();
    Iterable paths = finder.findAllPaths(startNode, endNode);
    IterableWrapper<PathRepresentation, Path> pathRepresentations = new IterableWrapper<PathRepresentation, Path>(paths) {

        @Override
        protected PathRepresentation underlyingObjectToObject(Path path) {
            return findParams.pathRepresentationOf(path);
        }
    };
    return new ListRepresentation(RepresentationType.PATH, pathRepresentations);
}
Also used : Path(org.neo4j.graphdb.Path) WeightedPath(org.neo4j.graphalgo.WeightedPath) ResourceIterable(org.neo4j.graphdb.ResourceIterable) PathRepresentation(org.neo4j.server.rest.repr.PathRepresentation) WeightedPathRepresentation(org.neo4j.server.rest.repr.WeightedPathRepresentation) Node(org.neo4j.graphdb.Node) PathFinder(org.neo4j.graphalgo.PathFinder) IterableWrapper(org.neo4j.helpers.collection.IterableWrapper) ListRepresentation(org.neo4j.server.rest.repr.ListRepresentation)

Aggregations

IterableWrapper (org.neo4j.helpers.collection.IterableWrapper)11 Node (org.neo4j.graphdb.Node)6 Relationship (org.neo4j.graphdb.Relationship)4 ArrayList (java.util.ArrayList)3 LinkedList (java.util.LinkedList)3 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)3 ListRepresentation (org.neo4j.server.rest.repr.ListRepresentation)3 PathRepresentation (org.neo4j.server.rest.repr.PathRepresentation)3 WeightedPathRepresentation (org.neo4j.server.rest.repr.WeightedPathRepresentation)3 BufferedReader (java.io.BufferedReader)2 IOException (java.io.IOException)2 InputStreamReader (java.io.InputStreamReader)2 URL (java.net.URL)2 HashSet (java.util.HashSet)2 NoSuchElementException (java.util.NoSuchElementException)2 NotFoundException (org.neo4j.graphdb.NotFoundException)2 Path (org.neo4j.graphdb.Path)2 NestingIterable (org.neo4j.helpers.collection.NestingIterable)2 PrefetchingIterator (org.neo4j.helpers.collection.PrefetchingIterator)2 EndNodeNotFoundException (org.neo4j.server.rest.domain.EndNodeNotFoundException)2