@Override public FederatedService getServiceForAgencyId(String agencyId) throws ServiceAreaServiceException { FederatedService provider = _servicesByAgencyId.get(agencyId); if (provider == null) throw new NoSuchAgencyServiceException(agencyId); return provider; }
private FederatedService getProviderFromProviders( Set<FederatedService> providers) throws OutOfServiceAreaServiceException, MultipleServiceAreasServiceException { if (providers.size() == 1) return providers.iterator().next(); if (providers.size() == 0) throw new OutOfServiceAreaServiceException(); throw new MultipleServiceAreasServiceException(); }
/** * @param entityId * @return the agencyId from an "agencyId_entityId" string representation * @throws InvalidArgumentServiceException on a parse error */ public static String getAgencyIdFromEntityId(String entityId) throws InvalidArgumentServiceException { int index = entityId.indexOf('_'); if (index == -1) throw new InvalidArgumentServiceException("entityId", "badEntityId"); return entityId.substring(0, index); } }
private SearchResult<AgencyAndId> searchForRoutes(SearchQueryBean query) throws ServiceException, InvalidArgumentServiceException { try { return _searchService.searchForRoutesByShortName(query.getQuery(), query.getMaxCount() + 1, MIN_SEARCH_SCORE); } catch (IOException e) { throw new ServiceException(); } catch (ParseException e) { throw new InvalidArgumentServiceException("query", "queryParseError"); } }
@Around("execution(* org.onebusaway.transit_data_federation.impl.federated.TransitDataServiceImpl.*(..))") public Object doBasicProfiling(ProceedingJoinPoint pjp) throws Throwable { try { return pjp.proceed(); } catch (ServiceException ex) { throw ex; } catch (Throwable ex) { _log.error("error executing TransitDataService method", ex); throw new ServiceException(ex); } } }
/**** * Private Methods ****/ private void checkForEmptyResult() { if (_result == null) { if (_stopIds.size() == 1) throw new NoSuchStopServiceException(_stopIds.get(0)); else throw new NoSuchStopServiceException(_stopIds.toString()); } }
protected void checkBounds(CoordinateBounds cb) { if (cb == null) { return; } Collection<CoordinateBounds> allAgencyBounds = _agencyService.getAgencyIdsAndCoverageAreas().values(); for (CoordinateBounds agencyBounds : allAgencyBounds) { if (agencyBounds.intersects(cb)) { return; } } throw new OutOfServiceAreaServiceException(); }
protected ArrivalAndDepartureQuery createArrivalAndDepartureQuery( ArrivalAndDepartureForStopQueryBean query) { ArrivalAndDepartureQuery adQuery = new ArrivalAndDepartureQuery(); AgencyAndId stopId = AgencyAndIdLibrary.convertFromString(query.getStopId()); StopEntry stop = _transitGraphDao.getStopEntryForId(stopId, true); AgencyAndId tripId = AgencyAndIdLibrary.convertFromString(query.getTripId()); TripEntry trip = _transitGraphDao.getTripEntryForId(tripId); if (trip == null) throw new NoSuchTripServiceException(query.getTripId()); adQuery.setStop(stop); adQuery.setStopSequence(query.getStopSequence()); adQuery.setTrip(trip); adQuery.setServiceDate(query.getServiceDate()); adQuery.setVehicleId(AgencyAndIdLibrary.convertFromString(query.getVehicleId())); adQuery.setTime(query.getTime()); return adQuery; }
private SearchResult<AgencyAndId> searchForRoutes(SearchQueryBean query) throws ServiceException, InvalidArgumentServiceException { try { return _searchService.searchForRoutesByName(query.getQuery(), query.getMaxCount() + 1, query.getMinScoreToKeep()); } catch (IOException e) { throw new ServiceException(); } catch (ParseException e) { throw new InvalidArgumentServiceException("query", "queryParseError"); } }
private FederatedService getProviderFromProviders( Set<FederatedService> providers) throws OutOfServiceAreaServiceException, MultipleServiceAreasServiceException { if (providers.size() == 1) return providers.iterator().next(); if (providers.size() == 0) throw new OutOfServiceAreaServiceException(); throw new MultipleServiceAreasServiceException(); }
@Override public FederatedService getServiceForAgencyId(String agencyId) throws ServiceAreaServiceException { FederatedService provider = _servicesByAgencyId.get(agencyId); if (provider == null) throw new NoSuchAgencyServiceException(agencyId); return provider; }
@Around("execution(* org.onebusaway.transit_data_federation.impl.federated.TransitDataServiceImpl.*(..))") public Object doBasicProfiling(ProceedingJoinPoint pjp) throws Throwable { try { return pjp.proceed(); } catch (ServiceException ex) { throw ex; } catch (Throwable ex) { if (!(ex instanceof NoSuchStopServiceException)) { // quiet the logs on no such stop service _log.error("error executing TransitDataService method", ex); } throw new ServiceException(ex); } } }
/**** * Private Methods ****/ private void checkForEmptyResult() { if (_result == null) { if (_stopIds.size() == 1) throw new NoSuchStopServiceException(_stopIds.get(0)); else throw new NoSuchStopServiceException(_stopIds.toString()); } }
/** * @param entityId * @return the agencyId from an "agencyId_entityId" string representation * @throws InvalidArgumentServiceException on a parse error */ public static String getAgencyIdFromEntityId(String entityId) throws InvalidArgumentServiceException { int index = entityId.indexOf('_'); if (index == -1) throw new InvalidArgumentServiceException("entityId", "badEntityId"); return entityId.substring(0, index); } }
@Override public FederatedService getServiceForLocations(List<CoordinatePoint> points) throws ServiceAreaServiceException { FederatedService service = null; for (CoordinatePoint point : points) { FederatedService provider = getServiceForLocation(point.getLat(), point.getLon()); if (service == null) { service = provider; } else if (service != provider) { throw new MultipleServiceAreasServiceException(); } } if (service == null) throw new OutOfServiceAreaServiceException(); return service; }
@Override public FederatedService getServiceForAgencyIds(Iterable<String> agencyIds) throws ServiceAreaServiceException { Set<FederatedService> providers = new HashSet<FederatedService>(); for (String id : agencyIds) { FederatedService provider = getServiceForAgencyId(id); if (provider == null) throw new NoSuchAgencyServiceException(id); providers.add(provider); } return getProviderFromProviders(providers); }
@Override public StopEntry getStopEntryForId(AgencyAndId id, boolean throwExceptionIfNotFound) { StopEntry stop = _graph.getStopEntryForId(id); if (stop == null && throwExceptionIfNotFound) throw new NoSuchStopServiceException( AgencyAndIdLibrary.convertToString(id)); return stop; }
@Override public FederatedService getServiceForAgencyIds(Iterable<String> agencyIds) throws ServiceAreaServiceException { Set<FederatedService> providers = new HashSet<FederatedService>(); for (String id : agencyIds) { FederatedService provider = getServiceForAgencyId(id); if (provider == null) throw new NoSuchAgencyServiceException(id); providers.add(provider); } return getProviderFromProviders(providers); }
@Cacheable public TimeZone getTimeZoneForAgencyId(String agencyId) { AgencyNarrative narrative = _narrativeService.getAgencyForId(agencyId); if (narrative == null) throw new NoSuchAgencyServiceException(agencyId); return TimeZone.getTimeZone(narrative.getTimezone()); }
@Cacheable public TimeZone getTimeZoneForAgencyId(String agencyId) { Agency agency = _dao.getAgencyForId(agencyId); if (agency == null) throw new NoSuchAgencyServiceException(agencyId); return TimeZone.getTimeZone(agency.getTimezone()); }