use of org.onebusaway.api.model.transit.BeanFactoryV2 in project onebusaway-application-modules by camsys.
the class TripAction method show.
public DefaultHttpHeaders show() throws ServiceException {
if (!isVersion(V2))
return setUnknownVersionResponse();
if (hasErrors())
return setValidationErrorsResponse();
TripBean trip = _service.getTrip(_id);
if (trip == null)
return setResourceNotFoundResponse();
BeanFactoryV2 factory = getBeanFactoryV2();
EntryWithReferencesBean<TripV2Bean> response = factory.getResponse(trip);
return setOkResponse(response);
}
use of org.onebusaway.api.model.transit.BeanFactoryV2 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.api.model.transit.BeanFactoryV2 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.api.model.transit.BeanFactoryV2 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.api.model.transit.BeanFactoryV2 in project onebusaway-application-modules by camsys.
the class RouteIdsForAgencyAction method show.
public DefaultHttpHeaders show() {
if (hasErrors())
return setValidationErrorsResponse();
if (!isVersion(V2))
return setUnknownVersionResponse();
ListBean<String> routeIds = _service.getRouteIdsForAgencyId(_id);
BeanFactoryV2 factory = getBeanFactoryV2();
return setOkResponse(factory.getEntityIdsResponse(routeIds));
}
Aggregations