Search in sources :

Example 1 with VehicleStatistics

use of org.onebusaway.admin.model.ui.VehicleStatistics in project onebusaway-application-modules by camsys.

the class VehicleStatusServiceImpl method getVehicleStatistics.

@Override
public VehicleStatistics getVehicleStatistics(String... parameters) {
    VehicleStatistics statistics = new VehicleStatistics();
    List<VehicleStatus> vehicleStatusRecords = cache.fetch();
    if (vehicleStatusRecords.isEmpty()) {
        // this should ideally never happen as statistics call should trigger after data
        // is loaded in the grid. Still get the records from web services if cache is empty to be
        // safe
        vehicleStatusRecords = getVehicleStatus(true);
    }
    List<VehicleStatus> vehiclesInEmergency = vehicleSearchService.searchVehiclesInEmergency(vehicleStatusRecords);
    List<VehicleStatus> vehiclesInRevenueService = vehicleSearchService.searchVehiclesInRevenueService(vehicleStatusRecords);
    List<VehicleStatus> vehiclesTracked = vehicleSearchService.searchVehiclesTracked(5, vehicleStatusRecords);
    statistics.setVehiclesInEmergency(vehiclesInEmergency.size());
    statistics.setVehiclesInRevenueService(vehiclesInRevenueService.size());
    statistics.setVehiclesTracked(vehiclesTracked.size());
    return statistics;
}
Also used : VehicleStatistics(org.onebusaway.admin.model.ui.VehicleStatistics) VehicleStatus(org.onebusaway.admin.model.ui.VehicleStatus)

Aggregations

VehicleStatistics (org.onebusaway.admin.model.ui.VehicleStatistics)1 VehicleStatus (org.onebusaway.admin.model.ui.VehicleStatus)1