Search in sources :

Example 1 with ArrivalAndDepartureBeanV1

use of org.onebusaway.api.model.where.ArrivalAndDepartureBeanV1 in project onebusaway-application-modules by camsys.

the class ArrivalsAndDeparturesForStopAction method getArrivalsAsV1.

private List<ArrivalAndDepartureBeanV1> getArrivalsAsV1(StopWithArrivalsAndDeparturesBean result) {
    List<ArrivalAndDepartureBeanV1> v1s = new ArrayList<ArrivalAndDepartureBeanV1>();
    for (ArrivalAndDepartureBean bean : result.getArrivalsAndDepartures()) {
        TripBean trip = bean.getTrip();
        RouteBean route = trip.getRoute();
        StopBean stop = bean.getStop();
        ArrivalAndDepartureBeanV1 v1 = new ArrivalAndDepartureBeanV1();
        v1.setPredictedArrivalTime(bean.getPredictedArrivalTime());
        v1.setPredictedDepartureTime(bean.getPredictedDepartureTime());
        v1.setRouteId(route.getId());
        if (trip.getRouteShortName() != null)
            v1.setRouteShortName(trip.getRouteShortName());
        else
            v1.setRouteShortName(route.getShortName());
        v1.setScheduledArrivalTime(bean.getScheduledArrivalTime());
        v1.setScheduledDepartureTime(bean.getScheduledDepartureTime());
        v1.setStatus(bean.getStatus());
        v1.setStopId(stop.getId());
        v1.setTripHeadsign(trip.getTripHeadsign());
        v1.setTripId(trip.getId());
        v1s.add(v1);
    }
    return v1s;
}
Also used : RouteBean(org.onebusaway.transit_data.model.RouteBean) ArrivalAndDepartureBeanV1(org.onebusaway.api.model.where.ArrivalAndDepartureBeanV1) ArrayList(java.util.ArrayList) TripBean(org.onebusaway.transit_data.model.trips.TripBean) StopBean(org.onebusaway.transit_data.model.StopBean) ArrivalAndDepartureBean(org.onebusaway.transit_data.model.ArrivalAndDepartureBean)

Example 2 with ArrivalAndDepartureBeanV1

use of org.onebusaway.api.model.where.ArrivalAndDepartureBeanV1 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)

Aggregations

ArrivalAndDepartureBeanV1 (org.onebusaway.api.model.where.ArrivalAndDepartureBeanV1)2 ArrayList (java.util.ArrayList)1 BeanFactoryV2 (org.onebusaway.api.model.transit.BeanFactoryV2)1 StopWithArrivalsAndDeparturesBeanV1 (org.onebusaway.api.model.where.StopWithArrivalsAndDeparturesBeanV1)1 ArrivalAndDepartureBean (org.onebusaway.transit_data.model.ArrivalAndDepartureBean)1 RouteBean (org.onebusaway.transit_data.model.RouteBean)1 StopBean (org.onebusaway.transit_data.model.StopBean)1 StopWithArrivalsAndDeparturesBean (org.onebusaway.transit_data.model.StopWithArrivalsAndDeparturesBean)1 TripBean (org.onebusaway.transit_data.model.trips.TripBean)1