use of org.onebusaway.enterprise.webapp.actions.api.model.StopOnRoute in project onebusaway-application-modules by camsys.
the class StopsOnRouteForDirectionAction method execute.
@Override
public String execute() {
if (_routeId == null) {
return SUCCESS;
}
StopsForRouteBean stopsForRoute = _transitDataService.getStopsForRoute(_routeId);
// create stop ID->stop bean map
Map<String, StopBean> stopIdToStopBeanMap = new HashMap<String, StopBean>();
for (StopBean stopBean : stopsForRoute.getStops()) {
stopIdToStopBeanMap.put(stopBean.getId(), stopBean);
}
// break up stops into destinations
List<StopGroupingBean> stopGroupings = stopsForRoute.getStopGroupings();
for (StopGroupingBean stopGroupingBean : stopGroupings) {
for (StopGroupBean stopGroupBean : stopGroupingBean.getStopGroups()) {
NameBean name = stopGroupBean.getName();
String type = name.getType();
if (!type.equals("destination") || !stopGroupBean.getId().equals(_directionId))
continue;
if (!stopGroupBean.getStopIds().isEmpty()) {
for (String stopId : stopGroupBean.getStopIds()) {
String agencyId = AgencyAndIdLibrary.convertFromString(_routeId).getAgencyId();
if (_transitDataService.stopHasRevenueServiceOnRoute(agencyId, stopId, stopsForRoute.getRoute().getId(), stopGroupBean.getId())) {
_stops.add(new StopOnRoute(stopIdToStopBeanMap.get(stopId)));
}
}
}
}
}
return SUCCESS;
}
use of org.onebusaway.enterprise.webapp.actions.api.model.StopOnRoute 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