Search in sources :

Example 1 with OutOfServiceAreaServiceException

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

the class TripsForAgencyAction method show.

public DefaultHttpHeaders show() throws IOException, ServiceException {
    if (!isVersion(V2))
        return setUnknownVersionResponse();
    if (hasErrors())
        return setValidationErrorsResponse();
    long time = SystemTime.currentTimeMillis();
    if (_time != null)
        time = _time.getTime();
    TripsForAgencyQueryBean query = new TripsForAgencyQueryBean();
    query.setAgencyId(_id);
    query.setTime(time);
    query.setMaxCount(_maxCount.getMaxCount());
    TripDetailsInclusionBean inclusion = query.getInclusion();
    inclusion.setIncludeTripBean(_includeTrip);
    inclusion.setIncludeTripStatus(_includeStatus);
    inclusion.setIncludeTripSchedule(_includeSchedule);
    BeanFactoryV2 factory = getBeanFactoryV2();
    try {
        ListBean<TripDetailsBean> trips = _service.getTripsForAgency(query);
        return setOkResponse(factory.getTripDetailsResponse(trips));
    } catch (OutOfServiceAreaServiceException ex) {
        return setOkResponse(factory.getEmptyList(TripDetailsV2Bean.class, true));
    }
}
Also used : TripsForAgencyQueryBean(org.onebusaway.transit_data.model.trips.TripsForAgencyQueryBean) OutOfServiceAreaServiceException(org.onebusaway.exceptions.OutOfServiceAreaServiceException) TripDetailsInclusionBean(org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean) TripDetailsBean(org.onebusaway.transit_data.model.trips.TripDetailsBean) BeanFactoryV2(org.onebusaway.api.model.transit.BeanFactoryV2)

Example 2 with OutOfServiceAreaServiceException

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

the class TripsForRouteAction method show.

public DefaultHttpHeaders show() throws IOException, ServiceException {
    if (!isVersion(V2))
        return setUnknownVersionResponse();
    if (hasErrors())
        return setValidationErrorsResponse();
    long time = SystemTime.currentTimeMillis();
    if (_time != 0)
        time = _time;
    TripsForRouteQueryBean query = new TripsForRouteQueryBean();
    query.setRouteId(_id);
    query.setTime(time);
    query.setMaxCount(_maxCount.getMaxCount());
    TripDetailsInclusionBean inclusion = query.getInclusion();
    inclusion.setIncludeTripBean(_includeTrip);
    inclusion.setIncludeTripSchedule(_includeSchedule);
    inclusion.setIncludeTripStatus(_includeStatus);
    BeanFactoryV2 factory = getBeanFactoryV2();
    try {
        ListBean<TripDetailsBean> trips = _service.getTripsForRoute(query);
        return setOkResponse(factory.getTripDetailsResponse(trips));
    } catch (OutOfServiceAreaServiceException ex) {
        return setOkResponse(factory.getEmptyList(TripDetailsV2Bean.class, true));
    }
}
Also used : OutOfServiceAreaServiceException(org.onebusaway.exceptions.OutOfServiceAreaServiceException) TripDetailsInclusionBean(org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean) TripsForRouteQueryBean(org.onebusaway.transit_data.model.trips.TripsForRouteQueryBean) TripDetailsBean(org.onebusaway.transit_data.model.trips.TripDetailsBean) BeanFactoryV2(org.onebusaway.api.model.transit.BeanFactoryV2)

Example 3 with OutOfServiceAreaServiceException

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

the class VehicleAction method show.

public DefaultHttpHeaders show() throws IOException, ServiceException {
    if (!isVersion(V2))
        return setUnknownVersionResponse();
    if (hasErrors())
        return setValidationErrorsResponse();
    long time = SystemTime.currentTimeMillis();
    if (_time != 0)
        time = _time;
    BeanFactoryV2 factory = getBeanFactoryV2();
    try {
        VehicleStatusBean vehicle = _service.getVehicleForAgency(_id, time);
        if (vehicle == null)
            return setResourceNotFoundResponse();
        return setOkResponse(factory.getVehicleStatusResponse(vehicle));
    } catch (OutOfServiceAreaServiceException ex) {
        return setOkResponse(factory.getEmptyList(VehicleStatusV2Bean.class, true));
    }
}
Also used : OutOfServiceAreaServiceException(org.onebusaway.exceptions.OutOfServiceAreaServiceException) BeanFactoryV2(org.onebusaway.api.model.transit.BeanFactoryV2) VehicleStatusBean(org.onebusaway.transit_data.model.VehicleStatusBean)

Example 4 with OutOfServiceAreaServiceException

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

the class RoutesForLocationAction method index.

public DefaultHttpHeaders index() throws IOException, ServiceException {
    int maxCount = _maxCount.getMaxCount();
    if (maxCount <= 0)
        addFieldError("maxCount", "must be greater than zero");
    if (hasErrors())
        return setValidationErrorsResponse();
    CoordinateBounds bounds = getSearchBounds();
    SearchQueryBean routesQuery = new SearchQueryBean();
    if (_query != null)
        routesQuery.setQuery(_query);
    routesQuery.setBounds(bounds);
    routesQuery.setMaxCount(maxCount);
    routesQuery.setType(EQueryType.BOUNDS_OR_CLOSEST);
    try {
        RoutesBean result = _service.getRoutes(routesQuery);
        return transformResult(result);
    } catch (OutOfServiceAreaServiceException ex) {
        return transformOutOfRangeResult();
    }
}
Also used : SearchQueryBean(org.onebusaway.transit_data.model.SearchQueryBean) RoutesBean(org.onebusaway.transit_data.model.RoutesBean) OutOfServiceAreaServiceException(org.onebusaway.exceptions.OutOfServiceAreaServiceException) CoordinateBounds(org.onebusaway.geospatial.model.CoordinateBounds)

Example 5 with OutOfServiceAreaServiceException

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

the class StopsWithinBoundsAction method execute.

@Override
public String execute() {
    if (_bounds == null) {
        return SUCCESS;
    }
    SearchQueryBean queryBean = new SearchQueryBean();
    queryBean.setType(SearchQueryBean.EQueryType.BOUNDS_OR_CLOSEST);
    queryBean.setBounds(_bounds);
    queryBean.setMaxCount(200);
    StopsBean stops = null;
    try {
        stops = _transitDataService.getStops(queryBean);
    } catch (OutOfServiceAreaServiceException e) {
        _log.error(" invalid results: ", e);
        return SUCCESS;
    }
    for (StopBean stop : stops.getStops()) {
        String agencyId = AgencyAndIdLibrary.convertFromString(stop.getId()).getAgencyId();
        if (_transitDataService.stopHasRevenueService(agencyId, stop.getId())) {
            _stops.add(new StopOnRoute(stop));
        }
    }
    return SUCCESS;
}
Also used : SearchQueryBean(org.onebusaway.transit_data.model.SearchQueryBean) OutOfServiceAreaServiceException(org.onebusaway.exceptions.OutOfServiceAreaServiceException) StopBean(org.onebusaway.transit_data.model.StopBean) StopOnRoute(org.onebusaway.enterprise.webapp.actions.api.model.StopOnRoute) StopsBean(org.onebusaway.transit_data.model.StopsBean)

Aggregations

OutOfServiceAreaServiceException (org.onebusaway.exceptions.OutOfServiceAreaServiceException)11 BeanFactoryV2 (org.onebusaway.api.model.transit.BeanFactoryV2)5 SearchQueryBean (org.onebusaway.transit_data.model.SearchQueryBean)5 CoordinateBounds (org.onebusaway.geospatial.model.CoordinateBounds)4 RouteBean (org.onebusaway.transit_data.model.RouteBean)3 RoutesBean (org.onebusaway.transit_data.model.RoutesBean)3 StopsForRouteBean (org.onebusaway.transit_data.model.StopsForRouteBean)3 TripDetailsBean (org.onebusaway.transit_data.model.trips.TripDetailsBean)3 TripDetailsInclusionBean (org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean)3 SearchResultCollection (org.onebusaway.presentation.model.SearchResultCollection)2 StopsBean (org.onebusaway.transit_data.model.StopsBean)2 VehicleStatusBean (org.onebusaway.transit_data.model.VehicleStatusBean)2 Matcher (java.util.regex.Matcher)1 StopOnRoute (org.onebusaway.enterprise.webapp.actions.api.model.StopOnRoute)1 RouteComparator (org.onebusaway.presentation.impl.RouteComparator)1 SearchResult (org.onebusaway.presentation.model.SearchResult)1 StopBean (org.onebusaway.transit_data.model.StopBean)1 TripsForAgencyQueryBean (org.onebusaway.transit_data.model.trips.TripsForAgencyQueryBean)1 TripsForBoundsQueryBean (org.onebusaway.transit_data.model.trips.TripsForBoundsQueryBean)1 TripsForRouteQueryBean (org.onebusaway.transit_data.model.trips.TripsForRouteQueryBean)1