use of org.onebusaway.exceptions.OutOfServiceAreaServiceException in project onebusaway-application-modules by camsys.
the class TripsForAgencyAction method show.
public DefaultHttpHeaders show() throws IOException, ServiceException {
if (!isVersion(V2))
return setUnknownVersionResponse();
if (hasErrors())
return setValidationErrorsResponse();
long time = SystemTime.currentTimeMillis();
if (_time != null)
time = _time.getTime();
TripsForAgencyQueryBean query = new TripsForAgencyQueryBean();
query.setAgencyId(_id);
query.setTime(time);
query.setMaxCount(_maxCount.getMaxCount());
TripDetailsInclusionBean inclusion = query.getInclusion();
inclusion.setIncludeTripBean(_includeTrip);
inclusion.setIncludeTripStatus(_includeStatus);
inclusion.setIncludeTripSchedule(_includeSchedule);
BeanFactoryV2 factory = getBeanFactoryV2();
try {
ListBean<TripDetailsBean> trips = _service.getTripsForAgency(query);
return setOkResponse(factory.getTripDetailsResponse(trips));
} catch (OutOfServiceAreaServiceException ex) {
return setOkResponse(factory.getEmptyList(TripDetailsV2Bean.class, true));
}
}
use of org.onebusaway.exceptions.OutOfServiceAreaServiceException in project onebusaway-application-modules by camsys.
the class TripsForRouteAction method show.
public DefaultHttpHeaders show() throws IOException, ServiceException {
if (!isVersion(V2))
return setUnknownVersionResponse();
if (hasErrors())
return setValidationErrorsResponse();
long time = SystemTime.currentTimeMillis();
if (_time != 0)
time = _time;
TripsForRouteQueryBean query = new TripsForRouteQueryBean();
query.setRouteId(_id);
query.setTime(time);
query.setMaxCount(_maxCount.getMaxCount());
TripDetailsInclusionBean inclusion = query.getInclusion();
inclusion.setIncludeTripBean(_includeTrip);
inclusion.setIncludeTripSchedule(_includeSchedule);
inclusion.setIncludeTripStatus(_includeStatus);
BeanFactoryV2 factory = getBeanFactoryV2();
try {
ListBean<TripDetailsBean> trips = _service.getTripsForRoute(query);
return setOkResponse(factory.getTripDetailsResponse(trips));
} catch (OutOfServiceAreaServiceException ex) {
return setOkResponse(factory.getEmptyList(TripDetailsV2Bean.class, true));
}
}
use of org.onebusaway.exceptions.OutOfServiceAreaServiceException in project onebusaway-application-modules by camsys.
the class VehicleAction method show.
public DefaultHttpHeaders show() throws IOException, ServiceException {
if (!isVersion(V2))
return setUnknownVersionResponse();
if (hasErrors())
return setValidationErrorsResponse();
long time = SystemTime.currentTimeMillis();
if (_time != 0)
time = _time;
BeanFactoryV2 factory = getBeanFactoryV2();
try {
VehicleStatusBean vehicle = _service.getVehicleForAgency(_id, time);
if (vehicle == null)
return setResourceNotFoundResponse();
return setOkResponse(factory.getVehicleStatusResponse(vehicle));
} catch (OutOfServiceAreaServiceException ex) {
return setOkResponse(factory.getEmptyList(VehicleStatusV2Bean.class, true));
}
}
use of org.onebusaway.exceptions.OutOfServiceAreaServiceException 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.exceptions.OutOfServiceAreaServiceException 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