Search in sources :

Example 1 with VehiclePullout

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;
}
Also used : VehicleStatusBuilder(org.onebusaway.admin.util.VehicleStatusBuilder) VehiclePullout(org.onebusaway.admin.model.json.VehiclePullout) VehicleLastKnownRecord(org.onebusaway.admin.model.json.VehicleLastKnownRecord) VehicleStatus(org.onebusaway.admin.model.ui.VehicleStatus)

Example 2 with VehiclePullout

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;
}
Also used : VehicleDetailBuilder(org.onebusaway.admin.util.VehicleDetailBuilder) VehiclePullout(org.onebusaway.admin.model.json.VehiclePullout) VehicleLastKnownRecord(org.onebusaway.admin.model.json.VehicleLastKnownRecord)

Aggregations

VehicleLastKnownRecord (org.onebusaway.admin.model.json.VehicleLastKnownRecord)2 VehiclePullout (org.onebusaway.admin.model.json.VehiclePullout)2 VehicleStatus (org.onebusaway.admin.model.ui.VehicleStatus)1 VehicleDetailBuilder (org.onebusaway.admin.util.VehicleDetailBuilder)1 VehicleStatusBuilder (org.onebusaway.admin.util.VehicleStatusBuilder)1