use of org.onebusaway.transit_data.model.SearchQueryBean in project onebusaway-application-modules by camsys.
the class RouteForNameAction method execute.
@Override
public String execute() throws Exception {
CoordinateBounds bounds = getDefaultSearchArea();
if (bounds == null)
return NEEDS_DEFAULT_SEARCH_LOCATION;
if (_routeName == null || _routeName.length() == 0)
return INPUT;
SearchQueryBean routesQuery = new SearchQueryBean();
routesQuery.setBounds(bounds);
routesQuery.setMaxCount(10);
routesQuery.setQuery(_routeName);
routesQuery.setType(EQueryType.BOUNDS_OR_CLOSEST);
RoutesBean routesBean = _transitDataService.getRoutes(routesQuery);
List<RouteBean> routes = routesBean.getRoutes();
if (routes.size() == 0) {
return "noRoutesFound";
} else if (routes.size() == 1) {
_route = routes.get(0);
return SUCCESS;
} else {
_routes = routes;
return "multipleRoutesFound";
}
}
use of org.onebusaway.transit_data.model.SearchQueryBean in project onebusaway-application-modules by camsys.
the class RealtimeServiceV2Impl method getStopsForBounds.
private List<StopBean> getStopsForBounds(CoordinateBounds bounds) {
if (bounds != null) {
SearchQueryBean queryBean = new SearchQueryBean();
queryBean.setType(SearchQueryBean.EQueryType.BOUNDS_OR_CLOSEST);
queryBean.setBounds(bounds);
queryBean.setMaxCount(Integer.MAX_VALUE);
StopsBean stops = _transitDataService.getStops(queryBean);
return stops.getStops();
}
return new ArrayList<StopBean>();
}
use of org.onebusaway.transit_data.model.SearchQueryBean in project onebusaway-application-modules by camsys.
the class RoutesForLocationAction method index.
public DefaultHttpHeaders index() throws IOException, ServiceException {
int maxCount = _maxCount.getMaxCount();
if (maxCount <= 0)
addFieldError("maxCount", "must be greater than zero");
if (hasErrors())
return setValidationErrorsResponse();
CoordinateBounds bounds = getSearchBounds();
SearchQueryBean routesQuery = new SearchQueryBean();
if (_query != null)
routesQuery.setQuery(_query);
routesQuery.setBounds(bounds);
routesQuery.setMaxCount(maxCount);
routesQuery.setType(EQueryType.BOUNDS_OR_CLOSEST);
try {
RoutesBean result = _service.getRoutes(routesQuery);
return transformResult(result);
} catch (OutOfServiceAreaServiceException ex) {
return transformOutOfRangeResult();
}
}
use of org.onebusaway.transit_data.model.SearchQueryBean in project onebusaway-application-modules by camsys.
the class StopForCodeAction method execute.
public String execute() throws Exception {
_log.info("in stop for code");
CoordinateBounds bounds = getDefaultSearchArea();
if (bounds == null)
return NEEDS_DEFAULT_SEARCH_LOCATION;
if (_stopCode == null || _stopCode.length() == 0)
return INPUT;
if (_stop != null) {
_stops = Arrays.asList(_stop);
} else {
_log.info("searching on stopCode=" + _stopCode);
SearchQueryBean searchQuery = new SearchQueryBean();
searchQuery.setBounds(bounds);
searchQuery.setMaxCount(5);
searchQuery.setType(EQueryType.BOUNDS_OR_CLOSEST);
searchQuery.setQuery(_stopCode);
StopsBean stopsBean = _transitDataService.getStops(searchQuery);
_stops = stopsBean.getStops();
}
logUserInteraction("query", _stopCode);
if (_stops.size() == 0) {
sessionMap.put("messageFromAction", getText(Messages.NO_STOPS_WERE_FOUND));
sessionMap.put("backAction", "stops-index");
return "noStopsFound";
} else if (_stops.size() == 1) {
StopBean stop = _stops.get(0);
_stopIds = Arrays.asList(stop.getId());
return SUCCESS;
} else {
sessionMap.put("stops", _stops);
return "multipleStopsFound";
}
}
use of org.onebusaway.transit_data.model.SearchQueryBean in project onebusaway-application-modules by camsys.
the class StopsWithinBoundsAction method execute.
@Override
public String execute() {
if (_bounds == null) {
return SUCCESS;
}
SearchQueryBean queryBean = new SearchQueryBean();
queryBean.setType(SearchQueryBean.EQueryType.BOUNDS_OR_CLOSEST);
queryBean.setBounds(_bounds);
queryBean.setMaxCount(200);
StopsBean stops = null;
try {
stops = _transitDataService.getStops(queryBean);
} catch (OutOfServiceAreaServiceException e) {
_log.error(" invalid results: ", e);
return SUCCESS;
}
for (StopBean stop : stops.getStops()) {
String agencyId = AgencyAndIdLibrary.convertFromString(stop.getId()).getAgencyId();
if (_transitDataService.stopHasRevenueService(agencyId, stop.getId())) {
_stops.add(new StopOnRoute(stop));
}
}
return SUCCESS;
}
Aggregations