Search in sources :

Example 16 with TripDetailsBean

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

the class VehicleStatusBeanServiceImpl method getStatusAsBean.

/**
 **
 *
 ***
 */
private VehicleStatusBean getStatusAsBean(VehicleStatus status, long time) {
    VehicleLocationRecord record = status.getRecord();
    VehicleStatusBean bean = new VehicleStatusBean();
    bean.setLastUpdateTime(record.getTimeOfRecord());
    bean.setLastLocationUpdateTime(record.getTimeOfLocationUpdate());
    EVehiclePhase phase = record.getPhase();
    if (phase != null)
        bean.setPhase(phase.toLabel());
    bean.setStatus(record.getStatus());
    if (record.isCurrentLocationSet())
        bean.setLocation(new CoordinatePoint(record.getCurrentLocationLat(), record.getCurrentLocationLon()));
    bean.setVehicleId(AgencyAndIdLibrary.convertToString(record.getVehicleId()));
    TripDetailsBean details = _tripDetailsBeanService.getTripForVehicle(record.getVehicleId(), time, new TripDetailsInclusionBean(true, false, true));
    if (details != null && details.getStatus() != null) {
        bean.setTrip(details.getTrip());
        bean.setTripStatus(details.getStatus());
    }
    List<VehicleLocationRecord> allRecords = status.getAllRecords();
    if (!CollectionsLibrary.isEmpty(allRecords)) {
        List<VehicleLocationRecordBean> allRecordBeans = new ArrayList<VehicleLocationRecordBean>();
        bean.setAllRecords(allRecordBeans);
        for (VehicleLocationRecord r : allRecords) {
            VehicleLocationRecordBean rBean = getVehicleLocationRecordAsBean(r);
            allRecordBeans.add(rBean);
        }
    }
    return bean;
}
Also used : CoordinatePoint(org.onebusaway.geospatial.model.CoordinatePoint) EVehiclePhase(org.onebusaway.realtime.api.EVehiclePhase) ArrayList(java.util.ArrayList) VehicleLocationRecord(org.onebusaway.realtime.api.VehicleLocationRecord) TripDetailsInclusionBean(org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean) VehicleLocationRecordBean(org.onebusaway.transit_data.model.realtime.VehicleLocationRecordBean) TripDetailsBean(org.onebusaway.transit_data.model.trips.TripDetailsBean) VehicleStatusBean(org.onebusaway.transit_data.model.VehicleStatusBean)

Aggregations

TripDetailsBean (org.onebusaway.transit_data.model.trips.TripDetailsBean)16 TripDetailsInclusionBean (org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean)10 ArrayList (java.util.ArrayList)6 BeanFactoryV2 (org.onebusaway.api.model.transit.BeanFactoryV2)5 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)4 TimepointPredictionRecord (org.onebusaway.realtime.api.TimepointPredictionRecord)4 Date (java.util.Date)3 OutOfServiceAreaServiceException (org.onebusaway.exceptions.OutOfServiceAreaServiceException)3 TripForVehicleQueryBean (org.onebusaway.transit_data.model.trips.TripForVehicleQueryBean)3 TripDetailsV2Bean (org.onebusaway.api.model.transit.TripDetailsV2Bean)2 CoordinateBounds (org.onebusaway.geospatial.model.CoordinateBounds)2 ListBean (org.onebusaway.transit_data.model.ListBean)2 TripDetailsQueryBean (org.onebusaway.transit_data.model.trips.TripDetailsQueryBean)2 TripStatusBean (org.onebusaway.transit_data.model.trips.TripStatusBean)2 TripsForBoundsQueryBean (org.onebusaway.transit_data.model.trips.TripsForBoundsQueryBean)2 BlockLocation (org.onebusaway.transit_data_federation.services.realtime.BlockLocation)2 BlockTripEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry)2 TripEntry (org.onebusaway.transit_data_federation.services.transit_graph.TripEntry)2 SiriExtensionWrapper (org.onebusaway.transit_data_federation.siri.SiriExtensionWrapper)2 VehicleActivityStructure (uk.org.siri.siri.VehicleActivityStructure)2