Package com.liferay.faces.demos.dto

Examples of com.liferay.faces.demos.dto.Airport


  @PostConstruct
  public void postConstruct() {

    long departureAirportId = bookingFlowModelBean.getBookingDepartureId();
    Airport departureAirport = airportService.findById(departureAirportId);
    this.departureAirportName = departureAirport.getName();
    this.departureCity = departureAirport.getCity();

    long arrivalAirportId = bookingFlowModelBean.getBookingArrivalId();
    Airport arrivalAirport = airportService.findById(arrivalAirportId);
    this.setArrivalAirportName(arrivalAirport.getName());
    this.setArrivalCity(arrivalAirport.getCity());

    scopeTrackingBean.setFlightSearchModelBeanInScope(true);
  }
View Full Code Here


          String country = csvParts[3];

          if (UNITED_STATES.equals(country) || CANADA.equals(country)) {

            Airport airport = new Airport();
            long airportId = LongHelper.toLong(csvParts[0]);
            airport.setAirportId(airportId);
            airport.setName(csvParts[1]);
            airport.setCity(csvParts[2]);
            airport.setCountry(country);
            airport.setCode(csvParts[4]);
            airport.setLatitude(Double.parseDouble(csvParts[6]));
            airport.setLongitude(Double.parseDouble(csvParts[7]));
            this.airports.add(airport);
            this.airportMap.put(airportId, airport);
          }
        }
      }
View Full Code Here

  public List<Booking> searchDirect(long departureAirportId, Date departureDate, long arrivalAirportId) {

    DateFormat dateFormat = new SimpleDateFormat();
    List<Booking> searchResults = new ArrayList<Booking>();

    Airport departureAirport = airportService.findById(departureAirportId);
    double departureLatitude = departureAirport.getLatitude();
    double departureLongitude = departureAirport.getLongitude();
    LatLng departureLatLong = new LatLng(departureLatitude, departureLongitude);
    Airport arrivalAirport = airportService.findById(arrivalAirportId);
    double arrivalLatitude = arrivalAirport.getLatitude();
    double arrivalLongitude = arrivalAirport.getLongitude();
    LatLng arrivalLatLong = new LatLng(arrivalLatitude, arrivalLongitude);
    double distanceInKilometers = LatLngTool.distance(departureLatLong, arrivalLatLong, LengthUnit.KILOMETER);
    double durationInHours = distanceInKilometers / AVG_SPEED_KM_PER_HOUR;
    double priceUSD = distanceInKilometers * PRICE_USD_PER_KM;
    Calendar departureCalendar = new GregorianCalendar();
    departureCalendar.setTime(departureDate);
    departureCalendar.set(Calendar.HOUR_OF_DAY, 6);

    Random random = new Random();

    while (departureCalendar.get(Calendar.HOUR_OF_DAY) < 18) {

      Calendar arrivalCalendar = (Calendar) departureCalendar.clone();
      arrivalCalendar.add(Calendar.HOUR_OF_DAY, (int) Math.round(durationInHours));

      Booking flight = new Booking();
      Date flightDepartureDate = departureCalendar.getTime();
      flight.setDepartureDate(flightDepartureDate);
      flight.setArrivalId(arrivalAirportId);

      Date flightArrivalDate = arrivalCalendar.getTime();
      flight.setArrivalDate(flightArrivalDate);
      flight.setDistance(distanceInKilometers);
      flight.setDuration(durationInHours);
      flight.setBookingId(Math.abs(random.nextLong()));

      String flightNumber = Integer.toString(Math.abs(random.nextInt()));
      flight.setLabel(flightNumber);

      StringBuilder description = new StringBuilder();
      description.append("Flight#");
      description.append(flightNumber);
      description.append(StringPool.SPACE);
      description.append("departing from");
      description.append(StringPool.SPACE);
      description.append(departureAirport.getCity());
      description.append(StringPool.SPACE);
      description.append(StringPool.OPEN_PARENTHESIS);
      description.append(departureAirport.getCode());
      description.append(StringPool.CLOSE_PARENTHESIS);
      description.append(StringPool.SPACE);
      description.append("on");
      description.append(StringPool.SPACE);
      description.append(dateFormat.format(flightDepartureDate));
      description.append(StringPool.SPACE);
      description.append("arriving at");
      description.append(StringPool.SPACE);
      description.append(arrivalAirport.getCity());
      description.append(StringPool.OPEN_PARENTHESIS);
      description.append(arrivalAirport.getCode());
      description.append(StringPool.CLOSE_PARENTHESIS);
      description.append(StringPool.SPACE);
      description.append("on");
      description.append(StringPool.SPACE);
      description.append(dateFormat.format(flightArrivalDate));
View Full Code Here

TOP

Related Classes of com.liferay.faces.demos.dto.Airport

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.