Vertex destVertex = this.graph.getVertex(findPath.getDestVertexId(), authorizations);
checkNotNull(destVertex, "Could not find destination vertex: " + findPath.getDestVertexId());
int hops = findPath.getHops();
String workspaceId = findPath.getWorkspaceId();
ClientApiVertexFindPathResponse results = new ClientApiVertexFindPathResponse();
ProgressCallback progressCallback = new ProgressCallback() {
@Override
public void progress(double progressPercent, String message) {
longRunningProcessRepository.reportProgress(longRunningProcessQueueItem, progressPercent, message);
}
};
Iterable<Path> paths = graph.findPaths(sourceVertex, destVertex, hops, progressCallback, authorizations);
for (Path path : paths) {
List<ClientApiElement> clientApiElementPath = ClientApiConverter.toClientApi(graph.getVerticesInOrder(path, authorizations), workspaceId, authorizations);
List<ClientApiVertex> clientApiVertexPath = new ArrayList<ClientApiVertex>();
for (ClientApiElement e : clientApiElementPath) {
clientApiVertexPath.add((ClientApiVertex) e);
}
results.getPaths().add(clientApiVertexPath);
}
String resultsString = ClientApiConverter.clientApiToString(results);
JSONObject resultsJson = new JSONObject(resultsString);
longRunningProcessQueueItem.put("results", resultsJson);
longRunningProcessQueueItem.put("resultsCount", results.getPaths().size());
}