use of org.onebusaway.transit_data.model.problems.TripProblemReportBean in project onebusaway-application-modules by camsys.
the class UserReportingServiceImpl method getRecordAsBean.
private TripProblemReportBean getRecordAsBean(TripProblemReportRecord record) {
AgencyAndId stopId = record.getStopId();
AgencyAndId tripId = record.getTripId();
TripProblemReportBean bean = new TripProblemReportBean();
bean.setCode(record.getCode());
bean.setId(record.getId());
bean.setServiceDate(record.getServiceDate());
bean.setStatus(record.getStatus());
bean.setLabel(record.getLabel());
bean.setStopId(AgencyAndIdLibrary.convertToString(stopId));
bean.setTime(record.getTime());
bean.setTripId(AgencyAndIdLibrary.convertToString(tripId));
bean.setUserComment(record.getUserComment());
bean.setUserLat(record.getUserLat());
bean.setUserLon(record.getUserLon());
bean.setUserLocationAccuracy(record.getUserLocationAccuracy());
bean.setUserOnVehicle(record.isUserOnVehicle());
bean.setUserVehicleNumber(record.getUserVehicleNumber());
bean.setPredicted(record.isPredicted());
bean.setVehicleId(AgencyAndIdLibrary.convertToString(record.getVehicleId()));
bean.setDistanceAlongBlock(record.getDistanceAlongBlock());
bean.setScheduleDeviation(record.getScheduleDeviation());
bean.setVehicleLat(record.getVehicleLat());
bean.setVehicleLon(record.getVehicleLon());
if (stopId != null) {
try {
bean.setStop(_stopBeanService.getStopForId(stopId));
} catch (NoSuchStopServiceException ex) {
}
}
if (tripId != null) {
bean.setTrip(_tripBeanService.getTripForId(tripId));
}
if (tripId != null && stopId != null) {
TripEntry trip = _graph.getTripEntryForId(tripId);
StopEntry stop = _graph.getStopEntryForId(stopId);
if (trip != null && stop != null) {
AgencyAndId vehicleId = record.getMatchedVehicleId();
if (vehicleId == null)
vehicleId = record.getVehicleId();
ArrivalAndDepartureQuery query = new ArrivalAndDepartureQuery();
query.setStop(stop);
query.setStopSequence(-1);
query.setTrip(trip);
query.setServiceDate(record.getServiceDate());
query.setVehicleId(vehicleId);
query.setTime(record.getTime());
ArrivalAndDepartureInstance instance = _arrivalAndDepartureService.getArrivalAndDepartureForStop(query);
if (instance != null) {
StopTimeInstance sti = instance.getStopTimeInstance();
StopTimeInstanceBean stopTimeBean = _stopTimeBeanService.getStopTimeInstanceAsBean(sti);
bean.setStopTime(stopTimeBean);
}
}
}
return bean;
}
Aggregations