예제 #1
0
  @RequestMapping(value = "/api/cacheFlightSearch", method = RequestMethod.GET)
  public String cacheFlightSearch(
      @RequestParam("departureDate") String departureDate,
      @RequestParam("departureAirport") String departureAirport) {

    DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ISO_DATE;

    LocalDate depDate = LocalDate.parse(departureDate, DATE_FORMAT);
    LocalDate returnDate = depDate.plusDays(7);

    String retDate = returnDate.format(DATE_FORMAT);

    List<Destination> destinations = new Destinations().getDestinations();

    for (Destination destination : destinations) {

      String arrivalAirportCode = destination.getAirportCodes().get(0);

      System.out.println(
          "Getting best flight price for destination: "
              + arrivalAirportCode
              + ","
              + destination.getCity());

      flightSearchService.getFlights(departureDate, departureAirport, arrivalAirportCode, retDate);

      System.out.println(
          "Finished processing best flight price for destination: "
              + arrivalAirportCode
              + ","
              + destination.getCity());
    }

    return "success";
  }
예제 #2
0
  @RequestMapping(value = "/api/flightSearch", method = RequestMethod.GET)
  public Flights getFlights(
      @RequestParam("departureDate") String departureDate,
      @RequestParam("departureAirport") String departureAirport,
      @RequestParam("arrivalAirport") String arrivalAirport,
      @RequestParam("returnDate") String returnDate) {

    return flightSearchService.getFlights(
        departureDate, departureAirport, arrivalAirport, returnDate);
  }
예제 #3
0
  @RequestMapping(value = "/api/suggestion", method = RequestMethod.GET)
  public Map<String, FlightSuggestion> getFlight(
      @RequestParam("user") String userID,
      @RequestParam("departureAirportCode") String departureAirportCode,
      @RequestParam("departureAirportCity") String departureAirportCity,
      @RequestParam("departureDate") String date) {

    // The imageService and cruiseSuggestionService calls should happen from withing the
    // flightSuggestionService, but for now are here
    LocalDate departureDate = LocalDate.parse(date, DATE_FORMAT);
    LocalDate returnDate = departureDate.plusDays(7);

    String[] strArray = {"suggested", "followingIfLiked", "followingIfDisliked"};

    Map<String, FlightSuggestion> flightSuggestions = new LinkedHashMap<>();

    String depDate = departureDate.format(DATE_FORMAT);
    String retDate = returnDate.format(DATE_FORMAT);
    String displayDepDate = departureDate.format(DISPLAY_DATE_FORMAT);
    String displayRetDate = returnDate.format(DISPLAY_DATE_FORMAT);

    Map<String, Suggestion> suggestions =
        destinationSuggestionService.getNextDestination(userID, departureAirportCity);

    for (String key : suggestions.keySet()) {
      Suggestion suggestion = suggestions.get(key);

      Flights flights =
          flightSearchService.getFlights(
              depDate, departureAirportCode, suggestion.getAirportCodes().get(0), retDate);

      DestinationDetails destinationDetails = new DestinationDetails();
      //
      // destinationDetails.setDestinationImages(imageService.getCityImages(suggestionCurrent.getCityName(), suggestionCurrent.getLabels(), 3));

      CruiseSuggestion cruiseSuggestion =
          cruiseSuggestionService.getCruiseSuggestion(
              suggestion.getAirportCodes().get(0), departureDate, returnDate);

      FlightSuggestion flightSuggestion =
          new FlightSuggestion(
              flights.getPrice(),
              flights.getDepartureDate(),
              flights.getReturnDate(),
              new Airport(departureAirportCode, departureAirportCity),
              new Airport(suggestion.getAirportCodes().get(0), suggestion.getCityName()),
              destinationDetails,
              cruiseSuggestion,
              displayDepDate,
              displayRetDate);
      flightSuggestions.put(key, flightSuggestion);
    }

    return flightSuggestions;
  }