use of org.onebusaway.admin.util.VehicleStatusBuilder in project onebusaway-application-modules by camsys.
the class VehicleStatusServiceImpl method getVehicleStatus.
@Override
public List<VehicleStatus> getVehicleStatus(boolean loadNew) {
List<VehicleStatus> vehicleStatusRecords = null;
// Load new data only if asked explicitly
if (loadNew) {
VehicleStatusBuilder builder = new VehicleStatusBuilder();
// get last known record data from operational API
List<VehicleLastKnownRecord> vehicleLastKnownRecords = getLastKnownRecordData();
// get vehicle pipo data
Map<String, VehiclePullout> vehiclePullouts = getPulloutData();
vehicleStatusRecords = new ArrayList<VehicleStatus>();
// Build vehicle status objects by getting the required fields from both collections
for (VehicleLastKnownRecord lastknownRecord : vehicleLastKnownRecords) {
VehiclePullout pullout = vehiclePullouts.get(lastknownRecord.getVehicleId());
VehicleStatus vehicleStatus = builder.buildVehicleStatus(pullout, lastknownRecord);
vehicleStatusRecords.add(vehicleStatus);
}
// Add these records to the cache
cache.add(vehicleStatusRecords);
} else {
// return data from the cache to improve performance
vehicleStatusRecords = cache.fetch();
}
return vehicleStatusRecords;
}
Aggregations