use of org.onebusaway.transit_data.model.trips.TripForVehicleQueryBean in project onebusaway-application-modules by camsys.
the class RealtimeServiceV2Impl method getVehicleActivityForVehicle.
@Override
public VehicleActivityStructure getVehicleActivityForVehicle(String vehicleId, int maximumOnwardCalls, DetailLevel detailLevel, long currentTime) {
TripForVehicleQueryBean query = new TripForVehicleQueryBean();
query.setTime(new Date(currentTime));
query.setVehicleId(vehicleId);
TripDetailsInclusionBean inclusion = new TripDetailsInclusionBean();
inclusion.setIncludeTripStatus(true);
inclusion.setIncludeTripBean(true);
query.setInclusion(inclusion);
TripDetailsBean tripDetailsForCurrentTrip = _transitDataService.getTripDetailsForVehicleAndTime(query);
if (tripDetailsForCurrentTrip != null) {
if (!_presentationService.include(tripDetailsForCurrentTrip.getStatus()))
return null;
VehicleActivityStructure output = new VehicleActivityStructure();
output.setRecordedAtTime(DateUtil.toXmlGregorianCalendar(tripDetailsForCurrentTrip.getStatus().getLastUpdateTime()));
List<TimepointPredictionRecord> timePredictionRecords = null;
timePredictionRecords = _transitDataService.getPredictionRecordsForTrip(AgencyAndId.convertFromString(vehicleId).getAgencyId(), tripDetailsForCurrentTrip.getStatus());
output.setMonitoredVehicleJourney(new MonitoredVehicleJourney());
SiriSupportV2.fillMonitoredVehicleJourney(output.getMonitoredVehicleJourney(), tripDetailsForCurrentTrip.getTrip(), tripDetailsForCurrentTrip.getStatus(), null, OnwardCallsMode.VEHICLE_MONITORING, _presentationService, _transitDataService, maximumOnwardCalls, timePredictionRecords, tripDetailsForCurrentTrip.getStatus().isPredicted(), detailLevel, currentTime, null);
return output;
}
return null;
}
use of org.onebusaway.transit_data.model.trips.TripForVehicleQueryBean in project onebusaway-application-modules by camsys.
the class RealtimeServiceImpl method getVehicleActivityForVehicle.
@Override
public VehicleActivityStructure getVehicleActivityForVehicle(String vehicleId, int maximumOnwardCalls, long currentTime, String tripId) {
TripForVehicleQueryBean query = new TripForVehicleQueryBean();
query.setTime(new Date(currentTime));
query.setVehicleId(vehicleId);
TripDetailsInclusionBean inclusion = new TripDetailsInclusionBean();
inclusion.setIncludeTripStatus(true);
inclusion.setIncludeTripBean(true);
query.setInclusion(inclusion);
TripDetailsBean tripDetailsForCurrentTrip = _transitDataService.getTripDetailsForVehicleAndTime(query);
if (tripDetailsForCurrentTrip == null) {
TripDetailsQueryBean detailsQuery = new TripDetailsQueryBean();
detailsQuery.setTime(currentTime);
detailsQuery.setTripId(tripId);
tripDetailsForCurrentTrip = _transitDataService.getSingleTripDetails(detailsQuery);
}
if (tripDetailsForCurrentTrip == null || !_presentationService.include(tripDetailsForCurrentTrip.getStatus()))
return null;
VehicleActivityStructure output = new VehicleActivityStructure();
// Check for Realtime Data
if (!tripDetailsForCurrentTrip.getStatus().isPredicted()) {
output.setRecordedAtTime(new Date(getTime()));
} else {
output.setRecordedAtTime(new Date(tripDetailsForCurrentTrip.getStatus().getLastUpdateTime()));
}
List<TimepointPredictionRecord> timePredictionRecords = null;
timePredictionRecords = _transitDataService.getPredictionRecordsForTrip(AgencyAndId.convertFromString(vehicleId).getAgencyId(), tripDetailsForCurrentTrip.getStatus());
output.setMonitoredVehicleJourney(new MonitoredVehicleJourney());
SiriSupport.fillMonitoredVehicleJourney(output.getMonitoredVehicleJourney(), tripDetailsForCurrentTrip.getTrip(), tripDetailsForCurrentTrip.getStatus(), null, OnwardCallsMode.VEHICLE_MONITORING, _presentationService, _transitDataService, maximumOnwardCalls, timePredictionRecords, tripDetailsForCurrentTrip.getStatus().isPredicted(), currentTime, false);
return output;
}
use of org.onebusaway.transit_data.model.trips.TripForVehicleQueryBean 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);
}
Aggregations