Search in sources :

Example 6 with BeanFactoryV2

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

the class RoutesForAgencyAction method show.

public DefaultHttpHeaders show() {
    if (hasErrors())
        return setValidationErrorsResponse();
    if (!isVersion(V2))
        return setUnknownVersionResponse();
    ListBean<RouteBean> routes = _service.getRoutesForAgencyId(_id);
    BeanFactoryV2 factory = getBeanFactoryV2();
    List<RouteV2Bean> beans = new ArrayList<RouteV2Bean>();
    for (RouteBean route : routes.getList()) beans.add(factory.getRoute(route));
    return setOkResponse(factory.list(beans, false));
}
Also used : RouteBean(org.onebusaway.transit_data.model.RouteBean) ArrayList(java.util.ArrayList) RouteV2Bean(org.onebusaway.api.model.transit.RouteV2Bean) BeanFactoryV2(org.onebusaway.api.model.transit.BeanFactoryV2)

Example 7 with BeanFactoryV2

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

the class ScheduleForStopAction method show.

public DefaultHttpHeaders show() throws ServiceException {
    if (hasErrors())
        return setValidationErrorsResponse();
    StopScheduleBean stopSchedule = _service.getScheduleForStop(_id, _date);
    BeanFactoryV2 factory = getBeanFactoryV2();
    return setOkResponse(factory.getResponse(stopSchedule));
}
Also used : StopScheduleBean(org.onebusaway.transit_data.model.StopScheduleBean) BeanFactoryV2(org.onebusaway.api.model.transit.BeanFactoryV2)

Example 8 with BeanFactoryV2

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

the class StopIdsForAgencyAction method show.

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

Example 9 with BeanFactoryV2

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

the class ArrivalsAndDeparturesForStopAction method show.

public DefaultHttpHeaders show() throws ServiceException {
    if (hasErrors())
        return setValidationErrorsResponse();
    if (_query.getTime() == 0)
        _query.setTime(SystemTime.currentTimeMillis());
    StopWithArrivalsAndDeparturesBean result = _service.getStopWithArrivalsAndDepartures(_id, _query);
    if (result == null)
        return setResourceNotFoundResponse();
    if (isVersion(V1)) {
        // Convert data to v1 form
        List<ArrivalAndDepartureBeanV1> arrivals = getArrivalsAsV1(result);
        StopWithArrivalsAndDeparturesBeanV1 v1 = new StopWithArrivalsAndDeparturesBeanV1(result.getStop(), arrivals, result.getNearbyStops());
        return setOkResponse(v1);
    } else if (isVersion(V2)) {
        BeanFactoryV2 factory = getBeanFactoryV2();
        return setOkResponse(factory.getResponse(result));
    } else {
        return setUnknownVersionResponse();
    }
}
Also used : StopWithArrivalsAndDeparturesBean(org.onebusaway.transit_data.model.StopWithArrivalsAndDeparturesBean) ArrivalAndDepartureBeanV1(org.onebusaway.api.model.where.ArrivalAndDepartureBeanV1) StopWithArrivalsAndDeparturesBeanV1(org.onebusaway.api.model.where.StopWithArrivalsAndDeparturesBeanV1) BeanFactoryV2(org.onebusaway.api.model.transit.BeanFactoryV2)

Example 10 with BeanFactoryV2

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

the class BlockAction method show.

public DefaultHttpHeaders show() throws ServiceException {
    if (!isVersion(V2))
        return setUnknownVersionResponse();
    if (hasErrors())
        return setValidationErrorsResponse();
    BlockBean block = _service.getBlockForId(_id);
    if (block == null)
        return setResourceNotFoundResponse();
    BeanFactoryV2 factory = getBeanFactoryV2();
    EntryWithReferencesBean<BlockV2Bean> response = factory.getBlockResponse(block);
    return setOkResponse(response);
}
Also used : BlockV2Bean(org.onebusaway.api.model.transit.blocks.BlockV2Bean) BlockBean(org.onebusaway.transit_data.model.blocks.BlockBean) 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