use of com.liferay.faces.demos.dto.Booking in project liferay-faces-bridge-impl by liferay.
the class BookingServiceMockImpl method postConstruct.
@PostConstruct
public void postConstruct() {
allBookings = new ArrayList<Booking>();
// Bookings for Brian Green
long customerId = CustomerServiceMockImpl.ID_BRIAN_GREEN;
allBookings.add(new Booking(BookingTypeServiceMockImpl.TYPE_ID_RENTAL_CAR, customerId));
allBookings.add(new Booking(BookingTypeServiceMockImpl.TYPE_ID_HOTEL, customerId));
allBookings.add(new Booking(BookingTypeServiceMockImpl.TYPE_ID_AIRFARE, customerId));
allBookings.add(new Booking(BookingTypeServiceMockImpl.TYPE_ID_THEME_PARK, customerId));
allBookings.add(new Booking(BookingTypeServiceMockImpl.TYPE_ID_PLAY, customerId));
// Bookings for Elizabeth Kessler
customerId = CustomerServiceMockImpl.ID_LIZ_KESSLER;
allBookings.add(new Booking(BookingTypeServiceMockImpl.TYPE_ID_HOTEL, customerId));
allBookings.add(new Booking(BookingTypeServiceMockImpl.TYPE_ID_AIRFARE, customerId));
allBookings.add(new Booking(BookingTypeServiceMockImpl.TYPE_ID_THEME_PARK, customerId));
// Bookings for Rich Shearer
customerId = CustomerServiceMockImpl.ID_RICH_SHEARER;
allBookings.add(new Booking(BookingTypeServiceMockImpl.TYPE_ID_AIRFARE, customerId));
allBookings.add(new Booking(BookingTypeServiceMockImpl.TYPE_ID_RENTAL_CAR, customerId));
allBookings.add(new Booking(BookingTypeServiceMockImpl.TYPE_ID_PLAY, customerId));
allBookings.add(new Booking(BookingTypeServiceMockImpl.TYPE_ID_HOTEL, customerId));
allBookings = Collections.unmodifiableList(allBookings);
}
use of com.liferay.faces.demos.dto.Booking in project liferay-faces-bridge-impl by liferay.
the class BookingsModelBean method postConstruct.
@PostConstruct
public void postConstruct() {
logger.trace("@PostConstruct annotation worked");
customer = new Customer();
customer.setBookings(new ArrayList<Booking>(5));
}
use of com.liferay.faces.demos.dto.Booking in project liferay-faces-bridge-impl by liferay.
the class FlightServiceMockImpl method searchDirect.
@Override
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(" departing from ");
description.append(departureAirport.getCity());
description.append(" (");
description.append(departureAirport.getCode());
description.append(") on ");
description.append(dateFormat.format(flightDepartureDate));
description.append(" arriving at ");
description.append(arrivalAirport.getCity());
description.append("(");
description.append(arrivalAirport.getCode());
description.append(") on ");
description.append(dateFormat.format(flightArrivalDate));
flight.setDescription(description.toString());
BigDecimal price = new BigDecimal(priceUSD);
price.setScale(2, BigDecimal.ROUND_HALF_UP);
flight.setPrice(price);
departureCalendar.add(Calendar.MINUTE, 90);
searchResults.add(flight);
}
return searchResults;
}
use of com.liferay.faces.demos.dto.Booking in project liferay-faces-bridge-impl by liferay.
the class BookingFlowBackingBean method removeBooking.
public void removeBooking(long bookingId) {
List<Booking> cartBookings = bookingFlowModelBean.getCartBookings();
Booking bookingToRemove = null;
for (Booking cartBooking : cartBookings) {
if (cartBooking.getBookingId() == bookingId) {
bookingToRemove = cartBooking;
break;
}
}
if (bookingToRemove != null) {
cartBookings.remove(bookingToRemove);
}
}
use of com.liferay.faces.demos.dto.Booking in project liferay-faces-bridge-impl by liferay.
the class CartModelBean method getTotalPrice.
public BigDecimal getTotalPrice() {
if (totalPrice == null) {
totalPrice = new BigDecimal(0L);
totalPrice.setScale(2, BigDecimal.ROUND_HALF_UP);
List<Booking> cartBookings = bookingFlowModelBean.getCartBookings();
for (Booking booking : cartBookings) {
totalPrice = totalPrice.add(booking.getPrice());
}
}
return totalPrice;
}
Aggregations