private OrganisationLocation findDestination(SustainifyUser user) { for (OrganisationLocation location : user.getOrganisation().getLocations()) { if (this.location.equals(location.getId())) { return location; } } return user.getOrganisation().getLocations().iterator().next(); }
@Get public void get() { SustainifyUser user = sessionContext.getAuthentication().getUser(); OrganisationLocation destination = findDestination(user); error = false; try { List<Route> routes = routeService.findRoutesFor( user, destination, sessionContext.getArrival(), sessionContext.getDeparture()); List<ScoredRoute> scoredRoutes = Lists.newArrayList(); for (Route route : routes) { scoredRoutes.add(scoreService.scoreFor(route, user)); } sessionContext.setRoutes(scoredRoutes); sessionContext.setSelectedLocation(destination); } catch (Exception e) { LOGGER.error("Failed to find routes for " + user.getEmailAddress(), e); error = true; } }