use of org.onebusaway.admin.model.json.VehiclePullout 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;
}
use of org.onebusaway.admin.model.json.VehiclePullout in project onebusaway-application-modules by camsys.
the class VehicleStatusServiceImpl method getVehicleDetail.
@Override
public VehicleDetail getVehicleDetail(String vehicleId) {
VehicleDetailBuilder builder = new VehicleDetailBuilder();
VehicleLastKnownRecord lastKnownRecord = getLastKnownRecordData(vehicleId);
if (lastKnownRecord != null) {
VehiclePullout pullout = getPulloutData(vehicleId);
String headSign = getHeadSign(lastKnownRecord.getDestinationSignCode());
String inferredHeadSign = getHeadSign(lastKnownRecord.getInferredDSC());
return builder.buildVehicleDetail(pullout, lastKnownRecord, headSign, inferredHeadSign);
}
return null;
}
Aggregations