use of org.onebusaway.api.model.transit.BeanFactoryV2 in project onebusaway-application-modules by camsys.
the class TripDetailsAction method show.
public DefaultHttpHeaders show() throws ServiceException {
if (!isVersion(V2))
return setUnknownVersionResponse();
if (hasErrors())
return setValidationErrorsResponse();
TripDetailsQueryBean query = new TripDetailsQueryBean();
query.setTripId(_id);
if (_serviceDate != null)
query.setServiceDate(_serviceDate.getTime());
query.setTime(_time.getTime());
query.setVehicleId(_vehicleId);
TripDetailsInclusionBean inclusion = query.getInclusion();
inclusion.setIncludeTripBean(_includeTrip);
inclusion.setIncludeTripSchedule(_includeSchedule);
inclusion.setIncludeTripStatus(_includeStatus);
TripDetailsBean trip = _service.getSingleTripDetails(query);
if (trip == null)
return setResourceNotFoundResponse();
BeanFactoryV2 factory = getBeanFactoryV2();
EntryWithReferencesBean<TripDetailsV2Bean> response = factory.getResponse(trip);
return setOkResponse(response);
}
use of org.onebusaway.api.model.transit.BeanFactoryV2 in project onebusaway-application-modules by camsys.
the class TripForVehicleAction method show.
public DefaultHttpHeaders show() throws ServiceException {
if (!isVersion(V2))
return setUnknownVersionResponse();
if (hasErrors())
return setValidationErrorsResponse();
TripForVehicleQueryBean query = new TripForVehicleQueryBean();
query.setVehicleId(_id);
query.setTime(_time);
TripDetailsInclusionBean inclusion = query.getInclusion();
inclusion.setIncludeTripBean(_includeTrip);
inclusion.setIncludeTripSchedule(_includeSchedule);
inclusion.setIncludeTripStatus(_includeStatus);
TripDetailsBean trip = _service.getTripDetailsForVehicleAndTime(query);
if (trip == null)
return setResourceNotFoundResponse();
BeanFactoryV2 factory = getBeanFactoryV2();
EntryWithReferencesBean<TripDetailsV2Bean> response = factory.getResponse(trip);
return setOkResponse(response);
}
use of org.onebusaway.api.model.transit.BeanFactoryV2 in project onebusaway-application-modules by camsys.
the class TripsForLocationAction method index.
public DefaultHttpHeaders index() throws IOException, ServiceException {
if (!isVersion(V2))
return setUnknownVersionResponse();
if (hasErrors())
return setValidationErrorsResponse();
CoordinateBounds bounds = _searchBoundsFactory.createBounds();
long time = SystemTime.currentTimeMillis();
if (_time != 0)
time = _time;
TripsForBoundsQueryBean query = new TripsForBoundsQueryBean();
query.setBounds(bounds);
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.getTripsForBounds(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 VehicleLocationRecordForVehicleAction method show.
public DefaultHttpHeaders show() throws IOException, ServiceException {
if (!isVersion(V2))
return setUnknownVersionResponse();
if (hasErrors())
return setValidationErrorsResponse();
BeanFactoryV2 factory = getBeanFactoryV2();
VehicleLocationRecordBean record = _service.getVehicleLocationRecordForVehicleId(_id, _time);
if (record == null)
return setResourceNotFoundResponse();
return setOkResponse(factory.entry(factory.getVehicleLocationRecord(record)));
}
use of org.onebusaway.api.model.transit.BeanFactoryV2 in project onebusaway-application-modules by camsys.
the class ApiActionSupport method getBeanFactoryV2.
protected BeanFactoryV2 getBeanFactoryV2(MaxCountSupport maxCount) {
BeanFactoryV2 factory = getBeanFactoryV2();
factory.setMaxCount(maxCount);
return factory;
}
Aggregations