use of org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean in project onebusaway-application-modules by camsys.
the class VehicleLocationsAction method getAllTripsForRoute.
private ListBean<TripDetailsBean> getAllTripsForRoute(String routeId, long currentTime) {
TripsForRouteQueryBean query = new TripsForRouteQueryBean();
query.setRouteId(routeId);
query.setTime(currentTime);
TripDetailsInclusionBean inclusionBean = new TripDetailsInclusionBean();
inclusionBean.setIncludeTripBean(true);
inclusionBean.setIncludeTripStatus(true);
query.setInclusion(inclusionBean);
return _transitDataService.getTripsForRoute(query);
}
use of org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean in project onebusaway-application-modules by camsys.
the class VehicleLocationsAction method getAllTripsForAgency.
private ListBean<TripDetailsBean> getAllTripsForAgency(String agencyId, long currentTime) {
TripsForAgencyQueryBean query = new TripsForAgencyQueryBean();
query.setAgencyId(agencyId);
query.setTime(currentTime);
TripDetailsInclusionBean inclusionBean = new TripDetailsInclusionBean();
inclusionBean.setIncludeTripBean(true);
inclusionBean.setIncludeTripStatus(true);
query.setInclusion(inclusionBean);
return _transitDataService.getTripsForAgency(query);
}
use of org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean in project onebusaway-application-modules by camsys.
the class MetricResource method getScheduledTrips.
protected int getScheduledTrips(String agencyId, String routeId) {
Set<TripDetailsBean> agencyTrips = new HashSet<TripDetailsBean>();
TripsForBoundsQueryBean query = new TripsForBoundsQueryBean();
List<CoordinateBounds> allBounds = getTDS().getAgencyIdsWithCoverageArea().get(agencyId);
for (CoordinateBounds bounds : allBounds) {
query.setBounds(bounds);
query.setTime(SystemTime.currentTimeMillis());
query.setMaxCount(Integer.MAX_VALUE);
TripDetailsInclusionBean inclusion = query.getInclusion();
inclusion.setIncludeTripBean(true);
ListBean<TripDetailsBean> allTrips = getTDS().getTripsForBounds(query);
if (allTrips == null) {
continue;
}
_log.debug("allTrips size=" + allTrips.getList().size());
AgencyAndId routeAndId = new AgencyAndId(agencyId, routeId);
for (TripDetailsBean trip : allTrips.getList()) {
if (trip.getTripId().startsWith(agencyId)) {
if (routeId == null || routeAndId.toString().equals(trip.getTrip().getRoute().getId())) {
agencyTrips.add(trip);
}
}
}
}
return agencyTrips.size();
}
use of org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean 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