The saveBooking method passes the booking data that it receives as parameters to the entity bean QuickBookingBean. The entity bean then writes the record to the database instance of the QCR_RESERVATION table. If an error occurs, the method throws a QuickCarRentalException.
|
You have opened the bean class QuickOrderProcessorBean in the Java Editor. |
1. Add the following code in the saveBooking method:
Date dateFrom=getDate(dateFromString); Date dateTo=getDate(dateToString); QuickBookingLocal booking = null; java.util.Date reservationDate = new java.util.Date();
java.lang.String bookingId = generateId(); try { booking = bookingHome.create( bookingId, vehicleTypeId, reservationDate, dateFrom, dateTo, pickupLocation, dropoffLocation, Constants.STATUS_ACTIVE); } catch (CreateException e) { e.printStackTrace(); throw new QuickCarRentalException(e.getMessage()); }
|
2. Replace the default return value return null; with:
return getBookingModel(booking);
|
3. To add the import statements, choose Source → Organize Imports from the context menu.
4. If necessary, correct the formatting of these lines by choosing Format from the context menu.
5. Save the contents of the editor by choosing the appropriate icon from the toolbar.
You have completely implemented the business method saveBooking.
Implementing the cancelBooking() Method