Search in sources :

Example 1 with NoSuchTripServiceException

use of org.onebusaway.exceptions.NoSuchTripServiceException in project onebusaway-application-modules by camsys.

the class TransitDataServiceTemplateImpl method createArrivalAndDepartureQuery.

protected ArrivalAndDepartureQuery createArrivalAndDepartureQuery(ArrivalAndDepartureForStopQueryBean query) {
    ArrivalAndDepartureQuery adQuery = new ArrivalAndDepartureQuery();
    AgencyAndId stopId = AgencyAndIdLibrary.convertFromString(query.getStopId());
    StopEntry stop = _transitGraphDao.getStopEntryForId(stopId, true);
    AgencyAndId tripId = AgencyAndIdLibrary.convertFromString(query.getTripId());
    TripEntry trip = _transitGraphDao.getTripEntryForId(tripId);
    if (trip == null)
        throw new NoSuchTripServiceException(query.getTripId());
    adQuery.setStop(stop);
    adQuery.setStopSequence(query.getStopSequence());
    adQuery.setTrip(trip);
    adQuery.setServiceDate(query.getServiceDate());
    adQuery.setVehicleId(AgencyAndIdLibrary.convertFromString(query.getVehicleId()));
    adQuery.setTime(query.getTime());
    return adQuery;
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) NoSuchTripServiceException(org.onebusaway.exceptions.NoSuchTripServiceException) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) TripEntry(org.onebusaway.transit_data_federation.services.transit_graph.TripEntry)

Example 2 with NoSuchTripServiceException

use of org.onebusaway.exceptions.NoSuchTripServiceException 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)

Aggregations

NoSuchTripServiceException (org.onebusaway.exceptions.NoSuchTripServiceException)2 Date (java.util.Date)1 Actions (org.apache.struts2.convention.annotation.Actions)1 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)1 TripStopTimesBean (org.onebusaway.transit_data.model.TripStopTimesBean)1 TripDetailsQueryBean (org.onebusaway.transit_data.model.trips.TripDetailsQueryBean)1 StopEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopEntry)1 TripEntry (org.onebusaway.transit_data_federation.services.transit_graph.TripEntry)1