Search in sources :

Example 1 with InternalErrorServiceException

use of org.onebusaway.exceptions.InternalErrorServiceException in project onebusaway-application-modules by camsys.

the class RouteServiceImpl method getRouteCollectionIdsForStop.

@Override
@Cacheable
public Set<AgencyAndId> getRouteCollectionIdsForStop(AgencyAndId stopId) {
    StopEntry stopEntry = _transitGraphDao.getStopEntryForId(stopId);
    if (stopEntry == null)
        throw new InternalErrorServiceException("no such stop: id=" + stopId);
    Set<AgencyAndId> routeCollectionIds = new HashSet<AgencyAndId>();
    List<BlockStopTimeIndex> indices = _blockIndexService.getStopTimeIndicesForStop(stopEntry);
    for (BlockStopTimeIndex blockStopTimeIndex : indices) {
        for (BlockTripEntry blockTrip : blockStopTimeIndex.getTrips()) {
            TripEntry trip = blockTrip.getTrip();
            routeCollectionIds.add(trip.getRouteCollection().getId());
        }
    }
    List<FrequencyBlockStopTimeIndex> frequencyIndices = _blockIndexService.getFrequencyStopTimeIndicesForStop(stopEntry);
    for (FrequencyBlockStopTimeIndex blockStopTimeIndex : frequencyIndices) {
        for (BlockTripEntry blockTrip : blockStopTimeIndex.getTrips()) {
            TripEntry trip = blockTrip.getTrip();
            routeCollectionIds.add(trip.getRouteCollection().getId());
        }
    }
    return routeCollectionIds;
}
Also used : InternalErrorServiceException(org.onebusaway.exceptions.InternalErrorServiceException) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) FrequencyBlockStopTimeIndex(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockStopTimeIndex) BlockStopTimeIndex(org.onebusaway.transit_data_federation.services.blocks.BlockStopTimeIndex) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) FrequencyBlockStopTimeIndex(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockStopTimeIndex) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) TripEntry(org.onebusaway.transit_data_federation.services.transit_graph.TripEntry) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) HashSet(java.util.HashSet) Cacheable(org.onebusaway.container.cache.Cacheable)

Aggregations

HashSet (java.util.HashSet)1 Cacheable (org.onebusaway.container.cache.Cacheable)1 InternalErrorServiceException (org.onebusaway.exceptions.InternalErrorServiceException)1 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)1 BlockStopTimeIndex (org.onebusaway.transit_data_federation.services.blocks.BlockStopTimeIndex)1 FrequencyBlockStopTimeIndex (org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockStopTimeIndex)1 BlockTripEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry)1 StopEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopEntry)1 TripEntry (org.onebusaway.transit_data_federation.services.transit_graph.TripEntry)1