Example #1
0
  public TripV2Bean getTrip(TripBean trip) {

    TripV2Bean bean = new TripV2Bean();

    bean.setId(trip.getId());

    bean.setRouteId(trip.getRoute().getId());
    addToReferences(trip.getRoute());

    bean.setRouteShortName(trip.getRouteShortName());
    bean.setTripHeadsign(trip.getTripHeadsign());
    bean.setTripShortName(trip.getTripShortName());

    bean.setDirectionId(trip.getDirectionId());
    bean.setServiceId(trip.getServiceId());
    bean.setShapeId(trip.getShapeId());
    bean.setBlockId(trip.getBlockId());

    return bean;
  }
Example #2
0
  public ArrivalAndDepartureV2Bean getArrivalAndDeparture(ArrivalAndDepartureBean ad) {

    TripBean trip = ad.getTrip();
    RouteBean route = trip.getRoute();
    StopBean stop = ad.getStop();

    ArrivalAndDepartureV2Bean bean = new ArrivalAndDepartureV2Bean();

    bean.setTripId(trip.getId());
    addToReferences(trip);

    bean.setServiceDate(ad.getServiceDate());
    bean.setVehicleId(ad.getVehicleId());
    bean.setStopId(stop.getId());
    addToReferences(stop);
    bean.setStopSequence(ad.getStopSequence());
    bean.setBlockTripSequence(ad.getBlockTripSequence());

    bean.setRouteId(route.getId());
    addToReferences(route);

    String routeShortName = ad.getRouteShortName();
    if (routeShortName == null || routeShortName.isEmpty())
      routeShortName = trip.getRouteShortName();
    if (routeShortName == null || routeShortName.isEmpty()) routeShortName = route.getShortName();
    bean.setRouteShortName(routeShortName);

    bean.setRouteLongName(route.getLongName());

    String tripHeadsign = ad.getTripHeadsign();
    if (tripHeadsign == null || tripHeadsign.isEmpty()) tripHeadsign = trip.getTripHeadsign();
    bean.setTripHeadsign(tripHeadsign);

    bean.setArrivalEnabled(ad.isArrivalEnabled());
    bean.setDepartureEnabled(ad.isDepartureEnabled());

    bean.setScheduledArrivalTime(ad.getScheduledArrivalTime());
    bean.setScheduledDepartureTime(ad.getScheduledDepartureTime());

    bean.setScheduledArrivalInterval(getTimeInterval(ad.getScheduledArrivalInterval()));
    bean.setScheduledDepartureInterval(getTimeInterval(ad.getScheduledDepartureInterval()));

    if (ad.getFrequency() != null) bean.setFrequency(getFrequency(ad.getFrequency()));

    bean.setStatus(ad.getStatus());

    if (ad.isDistanceFromStopSet()) bean.setDistanceFromStop(ad.getDistanceFromStop());

    bean.setNumberOfStopsAway(ad.getNumberOfStopsAway());

    bean.setPredicted(ad.isPredicted());
    bean.setLastUpdateTime(ad.getLastUpdateTime());

    List<ServiceAlertBean> situations = ad.getSituations();
    if (situations != null && !situations.isEmpty()) {
      List<String> situationIds = new ArrayList<String>();
      for (ServiceAlertBean situation : situations) {
        situationIds.add(situation.getId());
        addToReferences(situation);
      }
      bean.setSituationIds(situationIds);
    }

    return bean;
  }