Package org.onebusaway.transit_data.model

Examples of org.onebusaway.transit_data.model.VehicleStatusBean


    for (VehicleStatus status : statuses) {
      AgencyAndId vid = status.getVehicleId();
      if (!vid.getAgencyId().equals(agencyId))
        continue;

      VehicleStatusBean bean = getStatusAsBean(status, time);
      beans.add(bean);
    }

    return new ListBean<VehicleStatusBean>(beans, false);
  }
View Full Code Here


  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);
      }
    }
View Full Code Here

    RouteBean.Builder routeBuilder = RouteBean.builder();
    routeBuilder.setId("1_r1");
    RouteBean route = routeBuilder.create();

    {
      VehicleStatusBean vehicle = new VehicleStatusBean();
      vehicles.add(vehicle);
      vehicle.setLastUpdateTime(1234 * 1000);
      vehicle.setVehicleId("1_v1");

      TripStatusBean tripStatus = new TripStatusBean();
      vehicle.setTripStatus(tripStatus);

      TripBean trip = new TripBean();
      trip.setId("1_t0");
      trip.setRoute(route);
      tripStatus.setActiveTrip(trip);

      vehicle.setLocation(new CoordinatePoint(47.0, -122.0));
    }
    {
      VehicleStatusBean vehicle = new VehicleStatusBean();
      vehicles.add(vehicle);
      vehicle.setLastUpdateTime(5678 * 1000);
      vehicle.setVehicleId("1_v2");

      TripStatusBean tripStatus = new TripStatusBean();
      vehicle.setTripStatus(tripStatus);

      TripBean trip = new TripBean();
      trip.setId("1_t1");
      trip.setRoute(route);
      tripStatus.setActiveTrip(trip);

      vehicle.setLocation(new CoordinatePoint(47.1, -122.1));
    }

    ListBean<VehicleStatusBean> bean = new ListBean<VehicleStatusBean>();
    bean.setList(vehicles);
    Mockito.when(_service.getAllVehiclesForAgency("1", now)).thenReturn(bean);
View Full Code Here

    RouteBean.Builder routeBuilder = RouteBean.builder();
    routeBuilder.setId("1_r1");
    RouteBean route = routeBuilder.create();

    {
      VehicleStatusBean vehicle = new VehicleStatusBean();
      vehicles.add(vehicle);
      vehicle.setLastUpdateTime(1234 * 1000);
      vehicle.setVehicleId("1_v1");

      TripStatusBean tripStatus = new TripStatusBean();
      vehicle.setTripStatus(tripStatus);

      TripBean trip = new TripBean();
      trip.setId("1_t0");
      trip.setRoute(route);
      tripStatus.setActiveTrip(trip);

      StopBean stop = new StopBean();
      stop.setId("1_s2");
      tripStatus.setNextStop(stop);
      tripStatus.setNextStopTimeOffset(5 * 60);
    }
    {
      VehicleStatusBean vehicle = new VehicleStatusBean();
      vehicles.add(vehicle);
      vehicle.setLastUpdateTime(5678 * 1000);
      vehicle.setVehicleId("1_v2");

      TripStatusBean tripStatus = new TripStatusBean();
      vehicle.setTripStatus(tripStatus);

      TripBean trip = new TripBean();
      trip.setId("1_t1");
      trip.setRoute(route);
      tripStatus.setActiveTrip(trip);
View Full Code Here

      time = _time;

    BeanFactoryV2 factory = getBeanFactoryV2();

    try {
      VehicleStatusBean vehicle = _service.getVehicleForAgency(_id, time);

      if (vehicle == null)
        return setResourceNotFoundResponse();

      return setOkResponse(factory.getVehicleStatusResponse(vehicle));
View Full Code Here

    String vehicleId = _request.getParameter("VehicleRef");

    // single trip, by vehicle
    if (vehicleId != null) {
      String vehicleIdWithAgency = agencyId + "_" + vehicleId;
      VehicleStatusBean vehicle = _transitDataService.getVehicleForAgency(
          vehicleIdWithAgency, _time.getTime());
      ArrayList<VehicleActivity> activities = new ArrayList<VehicleActivity>();
      if (vehicle != null) {
        if (!(vehicle.getPhase().equals("DEADHEAD_AFTER")
            || vehicle.getPhase().equals("DEADHEAD_BEFORE") || vehicle.getPhase().equals(
            "DEADHEAD_DURING"))) {
          activities.add(createActivity(vehicle, onwardCalls));
        }
      }
      _response = generateSiriResponse(_time, activities);
View Full Code Here

TOP

Related Classes of org.onebusaway.transit_data.model.VehicleStatusBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.