use of org.onebusaway.transit_data.model.trips.TripDetailsBean in project onebusaway-application-modules by camsys.
the class VehicleStatusBeanServiceImpl method getStatusAsBean.
/**
**
*
***
*/
private VehicleStatusBean getStatusAsBean(VehicleStatus status, long time) {
VehicleLocationRecord record = status.getRecord();
VehicleStatusBean bean = new VehicleStatusBean();
bean.setLastUpdateTime(record.getTimeOfRecord());
bean.setLastLocationUpdateTime(record.getTimeOfLocationUpdate());
EVehiclePhase phase = record.getPhase();
if (phase != null)
bean.setPhase(phase.toLabel());
bean.setStatus(record.getStatus());
if (record.isCurrentLocationSet())
bean.setLocation(new CoordinatePoint(record.getCurrentLocationLat(), record.getCurrentLocationLon()));
bean.setVehicleId(AgencyAndIdLibrary.convertToString(record.getVehicleId()));
TripDetailsBean details = _tripDetailsBeanService.getTripForVehicle(record.getVehicleId(), time, new TripDetailsInclusionBean(true, false, true));
if (details != null && details.getStatus() != null) {
bean.setTrip(details.getTrip());
bean.setTripStatus(details.getStatus());
}
List<VehicleLocationRecord> allRecords = status.getAllRecords();
if (!CollectionsLibrary.isEmpty(allRecords)) {
List<VehicleLocationRecordBean> allRecordBeans = new ArrayList<VehicleLocationRecordBean>();
bean.setAllRecords(allRecordBeans);
for (VehicleLocationRecord r : allRecords) {
VehicleLocationRecordBean rBean = getVehicleLocationRecordAsBean(r);
allRecordBeans.add(rBean);
}
}
return bean;
}
Aggregations