use of org.onebusaway.transit_data.model.SearchQueryBean in project onebusaway-application-modules by camsys.
the class RouteForNameAction method execute.
public String execute() throws Exception {
_log.debug("in RouteForName with routeName " + _routeName);
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();
sessionMap.put("navState", new Integer(DISPLAY_DATA));
logUserInteraction("route", _routeName);
if (routes.size() == 0) {
sessionMap.put("messageFromAction", getText(Messages.NO_ROUTES_WERE_FOUND));
sessionMap.put("backAction", "search-index");
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 getRoutesForBounds.
private List<RouteBean> getRoutesForBounds(CoordinateBounds bounds) {
if (bounds != null) {
SearchQueryBean queryBean = new SearchQueryBean();
queryBean.setType(SearchQueryBean.EQueryType.BOUNDS_OR_CLOSEST);
queryBean.setBounds(bounds);
queryBean.setMaxCount(Integer.MAX_VALUE);
RoutesBean routes = _transitDataService.getRoutes(queryBean);
return routes.getRoutes();
}
return new ArrayList<RouteBean>();
}
use of org.onebusaway.transit_data.model.SearchQueryBean in project onebusaway-application-modules by camsys.
the class StopsForLocationAction 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 searchQuery = new SearchQueryBean();
searchQuery.setBounds(bounds);
searchQuery.setMaxCount(maxCount);
searchQuery.setType(EQueryType.BOUNDS);
if (_query != null) {
searchQuery.setQuery(_query);
searchQuery.setType(EQueryType.BOUNDS_OR_CLOSEST);
}
try {
StopsBean result = _service.getStops(searchQuery);
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 StopByNumberAction method execute.
@Override
public String execute() throws ServiceException {
if (_text != null)
_text.trim();
if (_text == null || _text.length() == 0)
return INPUT;
String[] tokens = _text.trim().split("\\s+");
if (tokens.length == 0)
return INPUT;
CoordinateBounds serviceArea = _serviceAreaService.getServiceArea();
if (serviceArea == null) {
pushNextAction("stop-by-number", "text", _text);
return "query-default-search-location";
}
_stopQuery = tokens[0];
SearchQueryBean searchQuery = new SearchQueryBean();
searchQuery.setBounds(serviceArea);
searchQuery.setMaxCount(5);
searchQuery.setType(EQueryType.BOUNDS_OR_CLOSEST);
searchQuery.setQuery(_stopQuery);
StopsBean results = _transitDataService.getStops(searchQuery);
_stops = results.getStops();
int stopIndex = 0;
if (_stops.isEmpty()) {
return "noStopsFound";
} else if (_stops.size() > 1) {
if (0 <= _selectedIndex && _selectedIndex < _stops.size()) {
stopIndex = _selectedIndex;
} else {
pushNextAction("stop-by-number", "text", _text);
pushNextAction("handle-multi-selection");
return "multipleStopsFound";
}
}
StopBean stop = _stops.get(stopIndex);
_stopId = stop.getId();
_args = new String[tokens.length - 1];
System.arraycopy(tokens, 1, _args, 0, _args.length);
return "arrivals-and-departures";
}
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 {
CoordinateBounds bounds = getDefaultSearchArea();
if (bounds == null)
return NEEDS_DEFAULT_SEARCH_LOCATION;
if (_stopCode == null || _stopCode.length() == 0)
return INPUT;
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();
if (_stops.size() == 0) {
return "noStopsFound";
} else if (_stops.size() == 1) {
StopBean stop = _stops.get(0);
_stopIds = Arrays.asList(stop.getId());
return SUCCESS;
} else {
return "multipleStopsFound";
}
}
Aggregations