Search in sources :

Example 1 with NoSuchStopServiceException

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

the class ScheduleAction method execute.

@Override
@Actions({ @Action(value = "/where/schedule") })
public String execute() throws Exception {
    if (_date == null)
        _date = new Date();
    if (_id == null)
        return INPUT;
    _result = _service.getScheduleForStop(_id, _date);
    if (_result == null)
        throw new NoSuchStopServiceException(_id);
    StopCalendarDaysBean days = _result.getCalendarDays();
    String tzName = days.getTimeZone();
    _timeZone = TimeZone.getTimeZone(tzName);
    if (_timeZone == null)
        _timeZone = TimeZone.getDefault();
    filterResults();
    return SUCCESS;
}
Also used : StopCalendarDaysBean(org.onebusaway.transit_data.model.StopCalendarDaysBean) NoSuchStopServiceException(org.onebusaway.exceptions.NoSuchStopServiceException) Date(java.util.Date) Actions(org.apache.struts2.convention.annotation.Actions)

Example 2 with NoSuchStopServiceException

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

the class NameBasedNotificationStrategyImpl method summarizeStop.

@Override
public String summarizeStop(String stopIdStr) {
    // return the stop name
    try {
        AgencyAndId routeId = AgencyAndIdLibrary.convertFromString(stopIdStr);
        StopBean stop = _tds.getStop(routeId.toString());
        if (stop == null || stop.getName() == null)
            return stopIdStr;
        return stop.getName();
    } catch (IllegalStateException ise) {
        // invalid id -- return it as is
        return stopIdStr;
    } catch (NoSuchStopServiceException nsse) {
        // something went wrong
        _log.error("couldn't find stop for stopId=|" + stopIdStr + "|");
        return stopIdStr;
    }
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) NoSuchStopServiceException(org.onebusaway.exceptions.NoSuchStopServiceException) StopBean(org.onebusaway.transit_data.model.StopBean)

Example 3 with NoSuchStopServiceException

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

the class UserReportingServiceImpl method getRecordAsBean.

private StopProblemReportBean getRecordAsBean(StopProblemReportRecord record) {
    AgencyAndId stopId = record.getStopId();
    StopProblemReportBean bean = new StopProblemReportBean();
    bean.setCode(record.getCode());
    bean.setId(record.getId());
    bean.setStatus(record.getStatus());
    bean.setStopId(AgencyAndIdLibrary.convertToString(stopId));
    bean.setTime(record.getTime());
    bean.setUserComment(record.getUserComment());
    if (record.getUserLat() != null)
        bean.setUserLat(record.getUserLat());
    if (record.getUserLon() != null)
        bean.setUserLon(record.getUserLon());
    if (record.getUserLocationAccuracy() != null)
        bean.setUserLocationAccuracy(record.getUserLocationAccuracy());
    if (stopId != null) {
        try {
            bean.setStop(_stopBeanService.getStopForId(stopId));
        } catch (NoSuchStopServiceException ex) {
        }
    }
    return bean;
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) StopProblemReportBean(org.onebusaway.transit_data.model.problems.StopProblemReportBean) NoSuchStopServiceException(org.onebusaway.exceptions.NoSuchStopServiceException)

Example 4 with NoSuchStopServiceException

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

the class UserReportingServiceImpl method getRecordAsBean.

private TripProblemReportBean getRecordAsBean(TripProblemReportRecord record) {
    AgencyAndId stopId = record.getStopId();
    AgencyAndId tripId = record.getTripId();
    TripProblemReportBean bean = new TripProblemReportBean();
    bean.setCode(record.getCode());
    bean.setId(record.getId());
    bean.setServiceDate(record.getServiceDate());
    bean.setStatus(record.getStatus());
    bean.setLabel(record.getLabel());
    bean.setStopId(AgencyAndIdLibrary.convertToString(stopId));
    bean.setTime(record.getTime());
    bean.setTripId(AgencyAndIdLibrary.convertToString(tripId));
    bean.setUserComment(record.getUserComment());
    bean.setUserLat(record.getUserLat());
    bean.setUserLon(record.getUserLon());
    bean.setUserLocationAccuracy(record.getUserLocationAccuracy());
    bean.setUserOnVehicle(record.isUserOnVehicle());
    bean.setUserVehicleNumber(record.getUserVehicleNumber());
    bean.setPredicted(record.isPredicted());
    bean.setVehicleId(AgencyAndIdLibrary.convertToString(record.getVehicleId()));
    bean.setDistanceAlongBlock(record.getDistanceAlongBlock());
    bean.setScheduleDeviation(record.getScheduleDeviation());
    bean.setVehicleLat(record.getVehicleLat());
    bean.setVehicleLon(record.getVehicleLon());
    if (stopId != null) {
        try {
            bean.setStop(_stopBeanService.getStopForId(stopId));
        } catch (NoSuchStopServiceException ex) {
        }
    }
    if (tripId != null) {
        bean.setTrip(_tripBeanService.getTripForId(tripId));
    }
    if (tripId != null && stopId != null) {
        TripEntry trip = _graph.getTripEntryForId(tripId);
        StopEntry stop = _graph.getStopEntryForId(stopId);
        if (trip != null && stop != null) {
            AgencyAndId vehicleId = record.getMatchedVehicleId();
            if (vehicleId == null)
                vehicleId = record.getVehicleId();
            ArrivalAndDepartureQuery query = new ArrivalAndDepartureQuery();
            query.setStop(stop);
            query.setStopSequence(-1);
            query.setTrip(trip);
            query.setServiceDate(record.getServiceDate());
            query.setVehicleId(vehicleId);
            query.setTime(record.getTime());
            ArrivalAndDepartureInstance instance = _arrivalAndDepartureService.getArrivalAndDepartureForStop(query);
            if (instance != null) {
                StopTimeInstance sti = instance.getStopTimeInstance();
                StopTimeInstanceBean stopTimeBean = _stopTimeBeanService.getStopTimeInstanceAsBean(sti);
                bean.setStopTime(stopTimeBean);
            }
        }
    }
    return bean;
}
Also used : StopTimeInstanceBean(org.onebusaway.transit_data.model.StopTimeInstanceBean) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) StopTimeInstance(org.onebusaway.transit_data_federation.model.StopTimeInstance) ArrivalAndDepartureQuery(org.onebusaway.transit_data_federation.services.ArrivalAndDepartureQuery) NoSuchStopServiceException(org.onebusaway.exceptions.NoSuchStopServiceException) TripEntry(org.onebusaway.transit_data_federation.services.transit_graph.TripEntry) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) ArrivalAndDepartureInstance(org.onebusaway.transit_data_federation.services.realtime.ArrivalAndDepartureInstance) TripProblemReportBean(org.onebusaway.transit_data.model.problems.TripProblemReportBean)

Example 5 with NoSuchStopServiceException

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

the class StopBeanServiceImpl method getStopForId.

@Cacheable
public StopBean getStopForId(AgencyAndId id) {
    StopEntry stop = _transitGraphDao.getStopEntryForId(id);
    StopNarrative narrative = _narrativeService.getStopForId(id);
    if (stop == null) {
        // try looking up consolidated id
        AgencyAndId consolidatedId = _consolidatedStopsService.getConsolidatedStopIdForHiddenStopId(id);
        if (consolidatedId != null)
            return getStopForId(consolidatedId);
        throw new NoSuchStopServiceException(AgencyAndIdLibrary.convertToString(id));
    }
    StopBean sb = new StopBean();
    fillStopBean(stop, narrative, sb);
    fillRoutesForStopBean(stop, sb);
    return sb;
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) NoSuchStopServiceException(org.onebusaway.exceptions.NoSuchStopServiceException) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) StopBean(org.onebusaway.transit_data.model.StopBean) StopNarrative(org.onebusaway.transit_data_federation.model.narrative.StopNarrative) Cacheable(org.onebusaway.container.cache.Cacheable)

Aggregations

NoSuchStopServiceException (org.onebusaway.exceptions.NoSuchStopServiceException)5 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)4 StopBean (org.onebusaway.transit_data.model.StopBean)2 StopEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopEntry)2 Date (java.util.Date)1 Actions (org.apache.struts2.convention.annotation.Actions)1 Cacheable (org.onebusaway.container.cache.Cacheable)1 StopCalendarDaysBean (org.onebusaway.transit_data.model.StopCalendarDaysBean)1 StopTimeInstanceBean (org.onebusaway.transit_data.model.StopTimeInstanceBean)1 StopProblemReportBean (org.onebusaway.transit_data.model.problems.StopProblemReportBean)1 TripProblemReportBean (org.onebusaway.transit_data.model.problems.TripProblemReportBean)1 StopTimeInstance (org.onebusaway.transit_data_federation.model.StopTimeInstance)1 StopNarrative (org.onebusaway.transit_data_federation.model.narrative.StopNarrative)1 ArrivalAndDepartureQuery (org.onebusaway.transit_data_federation.services.ArrivalAndDepartureQuery)1 ArrivalAndDepartureInstance (org.onebusaway.transit_data_federation.services.realtime.ArrivalAndDepartureInstance)1 TripEntry (org.onebusaway.transit_data_federation.services.transit_graph.TripEntry)1