use of org.onebusaway.api.model.transit.BeanFactoryV2 in project onebusaway-application-modules by camsys.
the class RoutesForAgencyAction method show.
public DefaultHttpHeaders show() {
if (hasErrors())
return setValidationErrorsResponse();
if (!isVersion(V2))
return setUnknownVersionResponse();
ListBean<RouteBean> routes = _service.getRoutesForAgencyId(_id);
BeanFactoryV2 factory = getBeanFactoryV2();
List<RouteV2Bean> beans = new ArrayList<RouteV2Bean>();
for (RouteBean route : routes.getList()) beans.add(factory.getRoute(route));
return setOkResponse(factory.list(beans, false));
}
use of org.onebusaway.api.model.transit.BeanFactoryV2 in project onebusaway-application-modules by camsys.
the class ScheduleForStopAction method show.
public DefaultHttpHeaders show() throws ServiceException {
if (hasErrors())
return setValidationErrorsResponse();
StopScheduleBean stopSchedule = _service.getScheduleForStop(_id, _date);
BeanFactoryV2 factory = getBeanFactoryV2();
return setOkResponse(factory.getResponse(stopSchedule));
}
use of org.onebusaway.api.model.transit.BeanFactoryV2 in project onebusaway-application-modules by camsys.
the class StopIdsForAgencyAction method show.
public DefaultHttpHeaders show() {
if (hasErrors())
return setValidationErrorsResponse();
if (!isVersion(V2))
return setUnknownVersionResponse();
ListBean<String> stopIds = _service.getStopIdsForAgencyId(_id);
BeanFactoryV2 factory = getBeanFactoryV2();
return setOkResponse(factory.getEntityIdsResponse(stopIds));
}
use of org.onebusaway.api.model.transit.BeanFactoryV2 in project onebusaway-application-modules by camsys.
the class ArrivalsAndDeparturesForStopAction method show.
public DefaultHttpHeaders show() throws ServiceException {
if (hasErrors())
return setValidationErrorsResponse();
if (_query.getTime() == 0)
_query.setTime(SystemTime.currentTimeMillis());
StopWithArrivalsAndDeparturesBean result = _service.getStopWithArrivalsAndDepartures(_id, _query);
if (result == null)
return setResourceNotFoundResponse();
if (isVersion(V1)) {
// Convert data to v1 form
List<ArrivalAndDepartureBeanV1> arrivals = getArrivalsAsV1(result);
StopWithArrivalsAndDeparturesBeanV1 v1 = new StopWithArrivalsAndDeparturesBeanV1(result.getStop(), arrivals, result.getNearbyStops());
return setOkResponse(v1);
} else if (isVersion(V2)) {
BeanFactoryV2 factory = getBeanFactoryV2();
return setOkResponse(factory.getResponse(result));
} else {
return setUnknownVersionResponse();
}
}
use of org.onebusaway.api.model.transit.BeanFactoryV2 in project onebusaway-application-modules by camsys.
the class BlockAction method show.
public DefaultHttpHeaders show() throws ServiceException {
if (!isVersion(V2))
return setUnknownVersionResponse();
if (hasErrors())
return setValidationErrorsResponse();
BlockBean block = _service.getBlockForId(_id);
if (block == null)
return setResourceNotFoundResponse();
BeanFactoryV2 factory = getBeanFactoryV2();
EntryWithReferencesBean<BlockV2Bean> response = factory.getBlockResponse(block);
return setOkResponse(response);
}
Aggregations