Examples of Trip


Examples of it.cdq.model.db.Trip

  @Transactional
  public void takeTripDuplicateTest() {
    List<Trip> list = new ArrayList<Trip>();

    for (int i = 0; i < ITERATION; i++) {
      Trip trip = new Trip();
      trip.setArrival(mockFight("a", "b", 1));
      trip.setDeparture(mockFight("a", "b", 1));
      trip.setCreationTripDate(new Date());
      list.add(trip);
    }

    for (Trip trip : list)
      tripRepository.takeTrip(trip);
View Full Code Here

Examples of it.cdq.model.db.Trip

  @Transactional
  public void discardSimilarTripTest() {
    List<Trip> list = new ArrayList<Trip>();

    for (int i = 0; i < 14; i++) {
      Trip trip = new Trip();
      trip.setArrival(mockFight("a", "b", 0));
      trip.setDeparture(mockFight("b", "a", 0));
      Calendar c = Calendar.getInstance();
      c.add(Calendar.DAY_OF_YEAR, i);
      trip.getArrival().setDate(c.getTime());
      trip.getDeparture().setDate(c.getTime());
      trip.setCreationTripDate(new Date());
      list.add(tripRepository.takeTrip(trip));
    }
    Assert.assertTrue(tripRepository.list().size() == list.size());

    for (Trip trip : list) {
View Full Code Here

Examples of it.cdq.model.db.Trip

      if (t.getArrival().getOperator().equals(operator)) {
        filtered.add(t);
      }
    }
    while (true) {
      Trip trip = codoquService.getNextElement(operator);
      if (trip == null)
        break;
    }

    Assert
View Full Code Here

Examples of it.cdq.model.db.Trip

    super(Trip.class);
  }

  public Trip takeTrip(Trip sample) {

    Trip result = searchTrip(sample);
    if (result != null) {
      logger.info("Trip [" + counter.get() + "] alredy present : " + sample);
      return result;
    }
View Full Code Here

Examples of it.cdq.model.db.Trip

    for (Option option : options) {
      if (option.isCandidate()) {
        i++;
        for (Trip tripDate : tripDates) {

          Trip clone = tripDate.clone();

          Airport a = new Airport();
          a.setAirportname(option.getOriginLabel());
          a.setIataCode(option.getOrigin());

          Airport b = new Airport();
          b.setAirportname(option.getDestinationLabel());
          b.setIataCode(option.getDestination());

          Flight arrival = clone.getArrival();
          arrival.setOrigin(a);
          arrival.setDestination(b);
          arrival.setCandidate(true);
          arrival.setModificationDate(new Date());
          arrival.setOperator(option.getOperator());

          Flight departure = clone.getDeparture();
          departure.setOrigin(b);
          departure.setDestination(a);
          departure.setCandidate(true);
          departure.setModificationDate(new Date());
          departure.setOperator(option.getOperator());
View Full Code Here

Examples of it.cdq.model.db.Trip

    arrival.setDate(arrivalDate);

    Flight departure = new Flight();
    departure.setDate(departureDate);

    Trip trip = new Trip();
    trip.setArrival(arrival);
    trip.setDeparture(departure);
    list.add(trip);

  }
View Full Code Here

Examples of it.cdq.model.db.Trip

    List<Trip> list = tripRepository.list(query, 1);
    if (CollectionUtils.isEmpty(list))
      return null;

    Trip trip = list.get(0);
    trip.setStarProcessingDate(new Date());
    tripRepository.update(trip);

    return trip;
  }
View Full Code Here

Examples of models.transit.Trip

    public static void getTrip(Long id, Long patternId, Long calendarId, Long agencyId) {
        try {
            if(id != null)
            {
                Trip trip = Trip.findById(id);
                if(trip != null)
                    renderJSON(Api.toJson(trip, false));
                else
                    notFound();
            }
View Full Code Here

Examples of models.transit.Trip

        }
    }
   
    public static void createTrip() {
        TripWithStopTimes tripWithStopTimes = null;
        Trip trip = null;

        try {
            try {
                tripWithStopTimes = mapper.readValue(params.get("body"), TripWithStopTimes.class);
            } catch (Exception e) {
                trip = mapper.readValue(params.get("body"), Trip.class);
            }

            if (tripWithStopTimes != null) {
                trip = tripWithStopTimes.toTrip();
            }
           
            if(Route.findById(trip.pattern.route.id) == null)
                badRequest();

            // if endtime is before start time add a day (e.g 07:00-00:30 becomes 07:00-24:30)
            if(trip != null && trip.useFrequency != null && trip.endTime != null &&  trip.useFrequency  && trip.startTime != null && trip.endTime < trip.startTime) {
              trip.endTime += (24 * 60 * 60 );
            }
           
            trip.save();

            // check if gtfsRouteId is specified, if not create from DB id
            if(trip.gtfsTripId == null) {
                trip.gtfsTripId = "TRIP_" + trip.id.toString();
                trip.save();
            }
           
            if (tripWithStopTimes != null && tripWithStopTimes.stopTimes != null) {
                for (StopTimeWithDeletion stopTime: tripWithStopTimes.stopTimes) {
                    stopTime.trip = trip;
View Full Code Here

Examples of models.transit.Trip

            // check if gtfsRouteId is specified, if not create from DB id
             if(trip.gtfsTripId == null) {
                trip.gtfsTripId = "TRIP_" + trip.id.toString();
            }

             Trip updatedTrip = Trip.em().merge(trip.toTrip());
            
            // update the stop times
            // TODO: how to detect deleted StopTimes (i.e. route no longer stops here)?
            for (StopTimeWithDeletion stopTime : trip.stopTimes) {
                if (Boolean.TRUE.equals(stopTime.deleted)) {
                    StopTime.delete("id = ? AND trip = ?", stopTime.id, updatedTrip);
                }
                else {
                    StopTime updatedStopTime = StopTime.em().merge(stopTime.toStopTime());
                    // this was getting lost somehow
                    updatedStopTime.trip = updatedTrip;
                    updatedStopTime.save();
                }
            }
           
            updatedTrip.save();

            renderJSON(Api.toJson(updatedTrip, false));
        } catch (Exception e) {
            e.printStackTrace();
            badRequest();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.