@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); } } }
@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 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"); } }
private StopsBean getStopsByBounds(SearchQueryBean queryBean) throws ServiceException { CoordinateBounds bounds = queryBean.getBounds(); List<AgencyAndId> stopIds = _geospatialBeanService.getStopsByBounds(bounds); boolean limitExceeded = BeanServiceSupport.checkLimitExceeded(stopIds, queryBean.getMaxCount()); List<StopBean> stopBeans = new ArrayList<StopBean>(); for (AgencyAndId stopId : stopIds) { StopBean stopBean = _stopBeanService.getStopForId(stopId); if (stopBean == null) throw new ServiceException(); /** * If the stop doesn't have any routes actively serving it, don't include * it in the results */ if (stopBean.getRoutes().isEmpty()) continue; stopBeans.add(stopBean); } return constructResult(stopBeans, limitExceeded); }
private StopsBean getStopsByBounds(SearchQueryBean queryBean) throws ServiceException { CoordinateBounds bounds = queryBean.getBounds(); List<AgencyAndId> stopIds = _geospatialBeanService.getStopsByBounds(bounds); boolean limitExceeded = BeanServiceSupport.checkLimitExceeded(stopIds, queryBean.getMaxCount()); List<StopBean> stopBeans = new ArrayList<StopBean>(); for (AgencyAndId stopId : stopIds) { StopBean stopBean = _stopBeanService.getStopForId(stopId); if (stopBean == null) throw new ServiceException(); /** * If the stop doesn't have any routes actively serving it, don't include * it in the results */ if (stopBean.getRoutes().isEmpty()) continue; stopBeans.add(stopBean); } return constructResult(stopBeans, limitExceeded); }
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"); } }
@Override public List<AgencyWithCoverageBean> getAgenciesWithCoverage() throws ServiceException { Map<String, CoordinateBounds> agencyIdsAndCoverageAreas = _agencyService.getAgencyIdsAndCoverageAreas(); List<AgencyWithCoverageBean> beans = new ArrayList<AgencyWithCoverageBean>(); for (Map.Entry<String, CoordinateBounds> entry : agencyIdsAndCoverageAreas.entrySet()) { String agencyId = entry.getKey(); CoordinateBounds bounds = entry.getValue(); AgencyBean agencyBean = _agencyBeanService.getAgencyForId(agencyId); if (agencyBean == null) throw new ServiceException("agency not found: " + agencyId); AgencyWithCoverageBean bean = new AgencyWithCoverageBean(); bean.setAgency(agencyBean); bean.setLat((bounds.getMaxLat() + bounds.getMinLat()) / 2); bean.setLon((bounds.getMaxLon() + bounds.getMinLon()) / 2); bean.setLatSpan(bounds.getMaxLat() - bounds.getMinLat()); bean.setLonSpan(bounds.getMaxLon() - bounds.getMinLon()); beans.add(bean); } return beans; }
@Override public Object invoke(FederatedServiceCollection collection, Method method, Object[] args) throws ServiceException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { if (args.length == 0) { throw new ServiceException("unexpected number of arguments"); } SituationQueryBean query = (SituationQueryBean) args[0]; Set<String> agencyIds = new HashSet<String>(); if (query.getAffects() != null) { for (SituationQueryBean.AffectsBean affects : query.getAffects()) { if (affects.getAgencyId() != null) { agencyIds.add(affects.getAgencyId()); } addAgencyId(affects.getRouteId(), agencyIds); addAgencyId(affects.getTripId(), agencyIds); addAgencyId(affects.getStopId(), agencyIds); } } FederatedService service = collection.getServiceForAgencyIds(agencyIds); return method.invoke(service, args); }
public List<AgencyWithCoverageBean> getAgenciesWithCoverage() throws ServiceException { Map<String, CoordinateBounds> agencyIdsAndCoverageAreas = _agencyService.getAgencyIdsAndCoverageAreas(); List<AgencyWithCoverageBean> beans = new ArrayList<AgencyWithCoverageBean>(); for (Map.Entry<String, CoordinateBounds> entry : agencyIdsAndCoverageAreas.entrySet()) { String agencyId = entry.getKey(); CoordinateBounds bounds = entry.getValue(); AgencyBean agencyBean = _agencyBeanService.getAgencyForId(agencyId); if (agencyBean == null) throw new ServiceException("agency not found: " + agencyId); AgencyWithCoverageBean bean = new AgencyWithCoverageBean(); bean.setAgency(agencyBean); bean.setLat((bounds.getMaxLat() + bounds.getMinLat()) / 2); bean.setLon((bounds.getMaxLon() + bounds.getMinLon()) / 2); bean.setLatSpan(bounds.getMaxLat() - bounds.getMinLat()); bean.setLonSpan(bounds.getMaxLon() - bounds.getMinLon()); beans.add(bean); } return beans; }
_log.error("error executing stop search: query=" + query, e); e.printStackTrace(); throw new ServiceException();
throw new ServiceException("no arrival-departure found");
return handlerClass.newInstance(); } catch (Exception ex) { throw new ServiceException( "error creating FederatedServiceMethodInvocationHandler of type " + handlerClass, ex);
_log.error("error executing stop search: query=" + query, e); e.printStackTrace(); throw new ServiceException();
public MinTravelTimeToStopsBean getMinTravelTimeToStopsFrom(double lat, double lon, OneBusAwayConstraintsBean constraints) throws ServiceException { final CoordinatePoint p = new CoordinatePoint(lat, lon); final TripPlannerConstraints tpc = new TripPlannerConstraints(); if (constraints.hasMinDepartureTimeOfDay() && constraints.hasMaxDepartureTimeOfDay()) { Calendar c = Calendar.getInstance(); while (c.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) c.add(Calendar.DAY_OF_WEEK, 1); setSecondsOfDay(c, constraints.getMinDepartureTimeOfDay()); tpc.setMinDepartureTime(c.getTimeInMillis()); setSecondsOfDay(c, constraints.getMaxDepartureTimeOfDay()); tpc.setMaxDepartureTime(c.getTimeInMillis()); } else if (constraints.hasMinDepartureTime() && constraints.hasMaxDepartureTime()) { tpc.setMinDepartureTime(constraints.getMinDepartureTime()); tpc.setMaxDepartureTime(constraints.getMaxDepartureTime()); } else { throw new ServiceException("must specify departure time constraints"); } long maxTripDuration = constraints.getMaxTripDuration() * 60 * 1000; tpc.setMaxTripDuration(maxTripDuration); if (constraints.hasMaxTransfers()) tpc.setMaxTransferCount(constraints.getMaxTransfers()); Map<StopEntry, Long> results = _tripPlanner.getMinTravelTimeToStopsFrom(p, tpc); return getStopTravelTimesAsResultsBean(results, constraints); }