Search in sources :

Example 1 with TripProblemReportBean

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

Aggregations

NoSuchStopServiceException (org.onebusaway.exceptions.NoSuchStopServiceException)1 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)1 StopTimeInstanceBean (org.onebusaway.transit_data.model.StopTimeInstanceBean)1 TripProblemReportBean (org.onebusaway.transit_data.model.problems.TripProblemReportBean)1 StopTimeInstance (org.onebusaway.transit_data_federation.model.StopTimeInstance)1 ArrivalAndDepartureQuery (org.onebusaway.transit_data_federation.services.ArrivalAndDepartureQuery)1 ArrivalAndDepartureInstance (org.onebusaway.transit_data_federation.services.realtime.ArrivalAndDepartureInstance)1 StopEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopEntry)1 TripEntry (org.onebusaway.transit_data_federation.services.transit_graph.TripEntry)1