Search in sources :

Example 6 with TripDetailsInclusionBean

use of org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean in project onebusaway-application-modules by camsys.

the class ClosestStopForVehicleController method index.

@RequestMapping()
public ModelAndView index(@RequestParam() String vehicleId, @RequestParam() long time, @RequestParam(required = false) String format) {
    AgencyAndId vid = AgencyAndIdLibrary.convertFromString(vehicleId);
    if (time == 0)
        time = SystemTime.currentTimeMillis();
    if (time < 0)
        time = SystemTime.currentTimeMillis() - time * 1000;
    TripDetailsInclusionBean inclusion = new TripDetailsInclusionBean();
    inclusion.setIncludeTripBean(false);
    inclusion.setIncludeTripSchedule(false);
    inclusion.setIncludeTripStatus(true);
    TripDetailsBean details = _service.getTripForVehicle(vid, time, inclusion);
    if ("html".equals(format))
        return new ModelAndView("closest-stop-for-vehicle-html.jspx", "stopTime", details);
    else
        return new ModelAndView("closest-stop-for-vehicle-xml.jspx", "stopTime", details);
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) ModelAndView(org.springframework.web.servlet.ModelAndView) TripDetailsInclusionBean(org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean) TripDetailsBean(org.onebusaway.transit_data.model.trips.TripDetailsBean) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with TripDetailsInclusionBean

use of org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean in project onebusaway-application-modules by camsys.

the class RealtimeServiceImpl method getAllTripsForRoute.

/**
 * PRIVATE METHODS
 */
private ListBean<TripDetailsBean> getAllTripsForRoute(String routeId, long currentTime) {
    TripsForRouteQueryBean tripRouteQueryBean = new TripsForRouteQueryBean();
    tripRouteQueryBean.setRouteId(routeId);
    tripRouteQueryBean.setTime(currentTime);
    TripDetailsInclusionBean inclusionBean = new TripDetailsInclusionBean();
    inclusionBean.setIncludeTripBean(true);
    inclusionBean.setIncludeTripStatus(true);
    tripRouteQueryBean.setInclusion(inclusionBean);
    return _transitDataService.getTripsForRoute(tripRouteQueryBean);
}
Also used : TripDetailsInclusionBean(org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean) TripsForRouteQueryBean(org.onebusaway.transit_data.model.trips.TripsForRouteQueryBean)

Example 8 with TripDetailsInclusionBean

use of org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean in project onebusaway-application-modules by camsys.

the class TripDetailsAction method show.

public DefaultHttpHeaders show() throws ServiceException {
    if (!isVersion(V2))
        return setUnknownVersionResponse();
    if (hasErrors())
        return setValidationErrorsResponse();
    TripDetailsQueryBean query = new TripDetailsQueryBean();
    query.setTripId(_id);
    if (_serviceDate != null)
        query.setServiceDate(_serviceDate.getTime());
    query.setTime(_time.getTime());
    query.setVehicleId(_vehicleId);
    TripDetailsInclusionBean inclusion = query.getInclusion();
    inclusion.setIncludeTripBean(_includeTrip);
    inclusion.setIncludeTripSchedule(_includeSchedule);
    inclusion.setIncludeTripStatus(_includeStatus);
    TripDetailsBean trip = _service.getSingleTripDetails(query);
    if (trip == null)
        return setResourceNotFoundResponse();
    BeanFactoryV2 factory = getBeanFactoryV2();
    EntryWithReferencesBean<TripDetailsV2Bean> response = factory.getResponse(trip);
    return setOkResponse(response);
}
Also used : TripDetailsV2Bean(org.onebusaway.api.model.transit.TripDetailsV2Bean) TripDetailsQueryBean(org.onebusaway.transit_data.model.trips.TripDetailsQueryBean) TripDetailsInclusionBean(org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean) TripDetailsBean(org.onebusaway.transit_data.model.trips.TripDetailsBean) BeanFactoryV2(org.onebusaway.api.model.transit.BeanFactoryV2)

Example 9 with TripDetailsInclusionBean

use of org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean in project onebusaway-application-modules by camsys.

the class TripForVehicleAction method show.

public DefaultHttpHeaders show() throws ServiceException {
    if (!isVersion(V2))
        return setUnknownVersionResponse();
    if (hasErrors())
        return setValidationErrorsResponse();
    TripForVehicleQueryBean query = new TripForVehicleQueryBean();
    query.setVehicleId(_id);
    query.setTime(_time);
    TripDetailsInclusionBean inclusion = query.getInclusion();
    inclusion.setIncludeTripBean(_includeTrip);
    inclusion.setIncludeTripSchedule(_includeSchedule);
    inclusion.setIncludeTripStatus(_includeStatus);
    TripDetailsBean trip = _service.getTripDetailsForVehicleAndTime(query);
    if (trip == null)
        return setResourceNotFoundResponse();
    BeanFactoryV2 factory = getBeanFactoryV2();
    EntryWithReferencesBean<TripDetailsV2Bean> response = factory.getResponse(trip);
    return setOkResponse(response);
}
Also used : TripForVehicleQueryBean(org.onebusaway.transit_data.model.trips.TripForVehicleQueryBean) TripDetailsV2Bean(org.onebusaway.api.model.transit.TripDetailsV2Bean) TripDetailsInclusionBean(org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean) TripDetailsBean(org.onebusaway.transit_data.model.trips.TripDetailsBean) BeanFactoryV2(org.onebusaway.api.model.transit.BeanFactoryV2)

Example 10 with TripDetailsInclusionBean

use of org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean in project onebusaway-application-modules by camsys.

the class TripsForLocationAction method index.

public DefaultHttpHeaders index() throws IOException, ServiceException {
    if (!isVersion(V2))
        return setUnknownVersionResponse();
    if (hasErrors())
        return setValidationErrorsResponse();
    CoordinateBounds bounds = _searchBoundsFactory.createBounds();
    long time = SystemTime.currentTimeMillis();
    if (_time != 0)
        time = _time;
    TripsForBoundsQueryBean query = new TripsForBoundsQueryBean();
    query.setBounds(bounds);
    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.getTripsForBounds(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) TripsForBoundsQueryBean(org.onebusaway.transit_data.model.trips.TripsForBoundsQueryBean) TripDetailsBean(org.onebusaway.transit_data.model.trips.TripDetailsBean) CoordinateBounds(org.onebusaway.geospatial.model.CoordinateBounds) BeanFactoryV2(org.onebusaway.api.model.transit.BeanFactoryV2)

Aggregations

TripDetailsInclusionBean (org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean)14 TripDetailsBean (org.onebusaway.transit_data.model.trips.TripDetailsBean)10 BeanFactoryV2 (org.onebusaway.api.model.transit.BeanFactoryV2)5 TripsForRouteQueryBean (org.onebusaway.transit_data.model.trips.TripsForRouteQueryBean)4 OutOfServiceAreaServiceException (org.onebusaway.exceptions.OutOfServiceAreaServiceException)3 TripForVehicleQueryBean (org.onebusaway.transit_data.model.trips.TripForVehicleQueryBean)3 Date (java.util.Date)2 TripDetailsV2Bean (org.onebusaway.api.model.transit.TripDetailsV2Bean)2 CoordinateBounds (org.onebusaway.geospatial.model.CoordinateBounds)2 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)2 TimepointPredictionRecord (org.onebusaway.realtime.api.TimepointPredictionRecord)2 TripDetailsQueryBean (org.onebusaway.transit_data.model.trips.TripDetailsQueryBean)2 TripsForAgencyQueryBean (org.onebusaway.transit_data.model.trips.TripsForAgencyQueryBean)2 TripsForBoundsQueryBean (org.onebusaway.transit_data.model.trips.TripsForBoundsQueryBean)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 CoordinatePoint (org.onebusaway.geospatial.model.CoordinatePoint)1 EVehiclePhase (org.onebusaway.realtime.api.EVehiclePhase)1 VehicleLocationRecord (org.onebusaway.realtime.api.VehicleLocationRecord)1 VehicleStatusBean (org.onebusaway.transit_data.model.VehicleStatusBean)1