use of org.onebusaway.transit_data.model.ListBean in project onebusaway-application-modules by camsys.
the class TripStatusBeanServiceImpl method getTripsForId.
@Override
public ListBean<TripDetailsBean> getTripsForId(TripDetailsQueryBean query) {
AgencyAndId tripId = AgencyAndIdLibrary.convertFromString(query.getTripId());
long serviceDate = query.getServiceDate();
AgencyAndId vehicleId = AgencyAndIdLibrary.convertFromString(query.getVehicleId());
long time = query.getTime();
TripEntry tripEntry = _transitGraphDao.getTripEntryForId(tripId);
if (tripEntry == null)
return new ListBean<TripDetailsBean>();
Map<BlockInstance, List<BlockLocation>> locationsByInstance = _blockStatusService.getBlocks(tripEntry.getBlock().getId(), serviceDate, vehicleId, time);
List<TripDetailsBean> tripDetails = new ArrayList<TripDetailsBean>();
for (Map.Entry<BlockInstance, List<BlockLocation>> entry : locationsByInstance.entrySet()) {
BlockInstance blockInstance = entry.getKey();
List<BlockLocation> locations = entry.getValue();
BlockTripInstance blockTripInstance = BlockTripInstanceLibrary.getBlockTripInstance(blockInstance, tripId);
if (blockTripInstance == null)
throw new IllegalStateException("expected blockTrip for trip=" + tripEntry + " and block=" + blockInstance);
/**
* If we have no locations for the specified block instance, it means the
* block is not currently active. But we can still attempt to construct a
* trip details
*/
if (locations.isEmpty()) {
TripDetailsBean details = getTripEntryAndBlockLocationAsTripDetails(blockTripInstance, null, query.getInclusion(), time);
tripDetails.add(details);
} else {
for (BlockLocation location : locations) {
TripDetailsBean details = getBlockLocationAsTripDetails(blockTripInstance, location, query.getInclusion(), time);
tripDetails.add(details);
}
}
}
return new ListBean<TripDetailsBean>(tripDetails, false);
}
use of org.onebusaway.transit_data.model.ListBean in project onebusaway-application-modules by camsys.
the class TripStatusBeanServiceImpl method getBlockLocationsAsTripDetails.
/**
**
* Private Methods
***
*/
private ListBean<TripDetailsBean> getBlockLocationsAsTripDetails(List<BlockLocation> locations, TripDetailsInclusionBean inclusion, long time) {
List<TripDetailsBean> tripDetails = new ArrayList<TripDetailsBean>();
for (BlockLocation location : locations) {
TripDetailsBean details = getBlockLocationAsTripDetails(location.getActiveTripInstance(), location, inclusion, time);
tripDetails.add(details);
}
return new ListBean<TripDetailsBean>(tripDetails, false);
}
use of org.onebusaway.transit_data.model.ListBean in project onebusaway-application-modules by camsys.
the class VehicleStatusBeanServiceImpl method getAllVehiclesForAgency.
@Override
public ListBean<VehicleStatusBean> getAllVehiclesForAgency(String agencyId, long time) {
List<VehicleStatus> statuses = _vehicleStatusService.getAllVehicleStatuses();
List<VehicleStatusBean> beans = new ArrayList<VehicleStatusBean>();
for (VehicleStatus status : statuses) {
AgencyAndId vid = status.getVehicleId();
if (!vid.getAgencyId().equals(agencyId))
continue;
VehicleStatusBean bean = getStatusAsBean(status, time);
beans.add(bean);
}
return new ListBean<VehicleStatusBean>(beans, false);
}
use of org.onebusaway.transit_data.model.ListBean in project onebusaway-application-modules by camsys.
the class VehicleStatusBeanServiceImpl method getVehicleLocations.
@Override
public ListBean<VehicleLocationRecordBean> getVehicleLocations(VehicleLocationRecordQueryBean query) {
AgencyAndId blockId = AgencyAndIdLibrary.convertFromString(query.getBlockId());
AgencyAndId tripId = AgencyAndIdLibrary.convertFromString(query.getTripId());
AgencyAndId vehicleId = AgencyAndIdLibrary.convertFromString(query.getVehicleId());
List<BlockLocationRecord> records = _blockLocationRecordDao.getBlockLocationRecords(blockId, tripId, vehicleId, query.getServiceDate(), query.getFromTime(), query.getToTime(), 1000);
List<VehicleLocationRecordBean> beans = new ArrayList<VehicleLocationRecordBean>(records.size());
for (BlockLocationRecord record : records) {
VehicleLocationRecordBean bean = getBlockLocationRecordAsVehicleLocationRecord(record);
beans.add(bean);
}
return new ListBean<VehicleLocationRecordBean>(beans, false);
}
use of org.onebusaway.transit_data.model.ListBean in project onebusaway-application-modules by camsys.
the class RoutesBeanServiceImpl method getRoutesForAgencyId.
@Cacheable
@Override
public ListBean<RouteBean> getRoutesForAgencyId(String agencyId) {
AgencyEntry agency = _graphDao.getAgencyForId(agencyId);
if (agency == null)
throw new NoSuchAgencyServiceException(agencyId);
List<RouteBean> routes = new ArrayList<RouteBean>();
for (RouteCollectionEntry routeCollection : agency.getRouteCollections()) {
AgencyAndId routeId = routeCollection.getId();
RouteBean route = _routeBeanService.getRouteForId(routeId);
routes.add(route);
}
return new ListBean<RouteBean>(routes, false);
}
Aggregations