Search in sources :

Example 1 with BeanFactoryV2

use of org.onebusaway.api.model.transit.BeanFactoryV2 in project onebusaway-application-modules by camsys.

the class TripAction method show.

public DefaultHttpHeaders show() throws ServiceException {
    if (!isVersion(V2))
        return setUnknownVersionResponse();
    if (hasErrors())
        return setValidationErrorsResponse();
    TripBean trip = _service.getTrip(_id);
    if (trip == null)
        return setResourceNotFoundResponse();
    BeanFactoryV2 factory = getBeanFactoryV2();
    EntryWithReferencesBean<TripV2Bean> response = factory.getResponse(trip);
    return setOkResponse(response);
}
Also used : TripV2Bean(org.onebusaway.api.model.transit.TripV2Bean) TripBean(org.onebusaway.transit_data.model.trips.TripBean) BeanFactoryV2(org.onebusaway.api.model.transit.BeanFactoryV2)

Example 2 with BeanFactoryV2

use of org.onebusaway.api.model.transit.BeanFactoryV2 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 3 with BeanFactoryV2

use of org.onebusaway.api.model.transit.BeanFactoryV2 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 4 with BeanFactoryV2

use of org.onebusaway.api.model.transit.BeanFactoryV2 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 5 with BeanFactoryV2

use of org.onebusaway.api.model.transit.BeanFactoryV2 in project onebusaway-application-modules by camsys.

the class RouteIdsForAgencyAction method show.

public DefaultHttpHeaders show() {
    if (hasErrors())
        return setValidationErrorsResponse();
    if (!isVersion(V2))
        return setUnknownVersionResponse();
    ListBean<String> routeIds = _service.getRouteIdsForAgencyId(_id);
    BeanFactoryV2 factory = getBeanFactoryV2();
    return setOkResponse(factory.getEntityIdsResponse(routeIds));
}
Also used : BeanFactoryV2(org.onebusaway.api.model.transit.BeanFactoryV2)

Aggregations

BeanFactoryV2 (org.onebusaway.api.model.transit.BeanFactoryV2)24 OutOfServiceAreaServiceException (org.onebusaway.exceptions.OutOfServiceAreaServiceException)5 TripDetailsBean (org.onebusaway.transit_data.model.trips.TripDetailsBean)5 TripDetailsInclusionBean (org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean)5 TripDetailsV2Bean (org.onebusaway.api.model.transit.TripDetailsV2Bean)2 VehicleStatusBean (org.onebusaway.transit_data.model.VehicleStatusBean)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 TimeBean (org.onebusaway.api.model.TimeBean)1 EntryWithReferencesBean (org.onebusaway.api.model.transit.EntryWithReferencesBean)1 RegisteredAlarmV2Bean (org.onebusaway.api.model.transit.RegisteredAlarmV2Bean)1 RouteV2Bean (org.onebusaway.api.model.transit.RouteV2Bean)1 TripV2Bean (org.onebusaway.api.model.transit.TripV2Bean)1 BlockInstanceV2Bean (org.onebusaway.api.model.transit.blocks.BlockInstanceV2Bean)1 BlockV2Bean (org.onebusaway.api.model.transit.blocks.BlockV2Bean)1 ArrivalAndDepartureBeanV1 (org.onebusaway.api.model.where.ArrivalAndDepartureBeanV1)1 StopWithArrivalsAndDeparturesBeanV1 (org.onebusaway.api.model.where.StopWithArrivalsAndDeparturesBeanV1)1 AlarmDetails (org.onebusaway.api.services.AlarmDetails)1 CoordinateBounds (org.onebusaway.geospatial.model.CoordinateBounds)1 EncodedPolylineBean (org.onebusaway.geospatial.model.EncodedPolylineBean)1