use of org.onebusaway.transit_data_federation.services.transit_graph.RouteEntry in project onebusaway-application-modules by camsys.
the class GtfsRealtimeEntitySource method getRouteId.
/**
* Given a route id without an agency prefix, we attempt to find a
* {@link RouteEntry} with the specified id by cycling through the set of
* agency ids specified in {@link #setAgencyIds(List)}. If a
* {@link RouteEntry} is found, we return the id of the parent
* {@link RouteCollectionEntry} as the matching id. This is to deal with the
* fact that while GTFS deals with underlying routes, internally OneBusAway
* mostly deals with RouteCollections.
*
* If no route is found in the {@link TransitGraphDao} with the specified id
* for any of the configured agencies, a {@link Id} will be constructed with
* the first agency id from the agency list.
*
* @param routeId
* @return an Id for {@link RouteCollectionEntry} with a matching
* {@link RouteEntry} id
*/
public Id getRouteId(String routeId) {
for (String agencyId : _agencyIds) {
AgencyAndId id = new AgencyAndId(agencyId, routeId);
RouteEntry route = _transitGraphDao.getRouteForId(id);
if (route != null)
return ServiceAlertLibrary.id(route.getParent().getId());
}
try {
AgencyAndId id = AgencyAndId.convertFromString(routeId);
RouteEntry route = _transitGraphDao.getRouteForId(id);
if (route != null)
return ServiceAlertLibrary.id(route.getParent().getId());
} catch (IllegalArgumentException ex) {
}
_log.warn("route not found with id \"{}\"", routeId);
AgencyAndId id = new AgencyAndId(_agencyIds.get(0), routeId);
return ServiceAlertLibrary.id(id);
}
Aggregations