Ejemplo n.º 1
0
  @SuppressWarnings("rawtypes")
  public PathRepresentation findSinglePath(long startId, long endId, Map<String, Object> map) {
    FindParams findParams = new FindParams(startId, endId, map).invoke();
    PathFinder finder = findParams.getFinder();
    Node startNode = findParams.getStartNode();
    Node endNode = findParams.getEndNode();

    Path path = finder.findSinglePath(startNode, endNode);
    if (path == null) {
      throw new NotFoundException();
    }
    return findParams.pathRepresentationOf(path);
  }
Ejemplo n.º 2
0
  @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);
  }