Search in sources :

Example 1 with TripDetailsQueryBean

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

the class TripAction method execute.

@Override
@Actions({ @Action(value = "/where/trip"), @Action(value = "/where/iphone/trip") })
public String execute() throws ServiceException {
    if (_id == null)
        return INPUT;
    if (_time == null)
        _time = new Date();
    TripDetailsQueryBean query = new TripDetailsQueryBean();
    query.setTripId(_id);
    if (_serviceDate != null)
        query.setServiceDate(_serviceDate.getTime());
    query.setVehicleId(_vehicleId);
    query.setTime(_time.getTime());
    _tripDetails = _service.getSingleTripDetails(query);
    if (_tripDetails == null)
        throw new NoSuchTripServiceException(_id);
    TripStopTimesBean stopTimes = _tripDetails.getSchedule();
    _timeZone = TimeZone.getTimeZone(stopTimes.getTimeZone());
    _actualServiceDate = getActualServiceDate();
    return SUCCESS;
}
Also used : TripDetailsQueryBean(org.onebusaway.transit_data.model.trips.TripDetailsQueryBean) NoSuchTripServiceException(org.onebusaway.exceptions.NoSuchTripServiceException) TripStopTimesBean(org.onebusaway.transit_data.model.TripStopTimesBean) Date(java.util.Date) Actions(org.apache.struts2.convention.annotation.Actions)

Example 2 with TripDetailsQueryBean

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

the class RealtimeServiceImpl method getVehicleActivityForVehicle.

@Override
public VehicleActivityStructure getVehicleActivityForVehicle(String vehicleId, int maximumOnwardCalls, long currentTime, String tripId) {
    TripForVehicleQueryBean query = new TripForVehicleQueryBean();
    query.setTime(new Date(currentTime));
    query.setVehicleId(vehicleId);
    TripDetailsInclusionBean inclusion = new TripDetailsInclusionBean();
    inclusion.setIncludeTripStatus(true);
    inclusion.setIncludeTripBean(true);
    query.setInclusion(inclusion);
    TripDetailsBean tripDetailsForCurrentTrip = _transitDataService.getTripDetailsForVehicleAndTime(query);
    if (tripDetailsForCurrentTrip == null) {
        TripDetailsQueryBean detailsQuery = new TripDetailsQueryBean();
        detailsQuery.setTime(currentTime);
        detailsQuery.setTripId(tripId);
        tripDetailsForCurrentTrip = _transitDataService.getSingleTripDetails(detailsQuery);
    }
    if (tripDetailsForCurrentTrip == null || !_presentationService.include(tripDetailsForCurrentTrip.getStatus()))
        return null;
    VehicleActivityStructure output = new VehicleActivityStructure();
    // Check for Realtime Data
    if (!tripDetailsForCurrentTrip.getStatus().isPredicted()) {
        output.setRecordedAtTime(new Date(getTime()));
    } else {
        output.setRecordedAtTime(new Date(tripDetailsForCurrentTrip.getStatus().getLastUpdateTime()));
    }
    List<TimepointPredictionRecord> timePredictionRecords = null;
    timePredictionRecords = _transitDataService.getPredictionRecordsForTrip(AgencyAndId.convertFromString(vehicleId).getAgencyId(), tripDetailsForCurrentTrip.getStatus());
    output.setMonitoredVehicleJourney(new MonitoredVehicleJourney());
    SiriSupport.fillMonitoredVehicleJourney(output.getMonitoredVehicleJourney(), tripDetailsForCurrentTrip.getTrip(), tripDetailsForCurrentTrip.getStatus(), null, OnwardCallsMode.VEHICLE_MONITORING, _presentationService, _transitDataService, maximumOnwardCalls, timePredictionRecords, tripDetailsForCurrentTrip.getStatus().isPredicted(), currentTime, false);
    return output;
}
Also used : TripForVehicleQueryBean(org.onebusaway.transit_data.model.trips.TripForVehicleQueryBean) TripDetailsQueryBean(org.onebusaway.transit_data.model.trips.TripDetailsQueryBean) TimepointPredictionRecord(org.onebusaway.realtime.api.TimepointPredictionRecord) TripDetailsInclusionBean(org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean) VehicleActivityStructure(uk.org.siri.siri.VehicleActivityStructure) Date(java.util.Date) TripDetailsBean(org.onebusaway.transit_data.model.trips.TripDetailsBean) MonitoredVehicleJourney(uk.org.siri.siri.VehicleActivityStructure.MonitoredVehicleJourney)

Example 3 with TripDetailsQueryBean

use of org.onebusaway.transit_data.model.trips.TripDetailsQueryBean 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)

Aggregations

TripDetailsQueryBean (org.onebusaway.transit_data.model.trips.TripDetailsQueryBean)3 Date (java.util.Date)2 TripDetailsBean (org.onebusaway.transit_data.model.trips.TripDetailsBean)2 TripDetailsInclusionBean (org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean)2 Actions (org.apache.struts2.convention.annotation.Actions)1 BeanFactoryV2 (org.onebusaway.api.model.transit.BeanFactoryV2)1 TripDetailsV2Bean (org.onebusaway.api.model.transit.TripDetailsV2Bean)1 NoSuchTripServiceException (org.onebusaway.exceptions.NoSuchTripServiceException)1 TimepointPredictionRecord (org.onebusaway.realtime.api.TimepointPredictionRecord)1 TripStopTimesBean (org.onebusaway.transit_data.model.TripStopTimesBean)1 TripForVehicleQueryBean (org.onebusaway.transit_data.model.trips.TripForVehicleQueryBean)1 VehicleActivityStructure (uk.org.siri.siri.VehicleActivityStructure)1 MonitoredVehicleJourney (uk.org.siri.siri.VehicleActivityStructure.MonitoredVehicleJourney)1