Package it.hotel.controller.booking

Source Code of it.hotel.controller.booking.BookingCheckinController

/*
Copyright (C) European Community 2008 - Licensed under the EUPL V.1.0 (http://ec.europa.eu/idabc/en/document/6523)
*/
package it.hotel.controller.booking;

import it.hotel.controller.booking.DTO.BookingDTO;
import it.hotel.controller.hotel.HotelSimpleFormController;
import it.hotel.model.booking.Booking;
import it.hotel.model.booking.manager.IBookingManager;
import it.hotel.model.customer.Customer;
import it.hotel.model.customer.manager.ICustomerManager;
import it.hotel.model.structure.Structure;
import it.hotel.model.structure.manager.IStructureManager;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;

/**
*
*
*/
public class BookingCheckinController  extends HotelSimpleFormController{
 

//  private IHotelManager hotelManager;
  private IStructureManager structureManager;
  private ICustomerManager customerManager;
  private IBookingManager bookingManager;
   
 
  /**
   *
   */
  protected Map referenceData (HttpServletRequest req) throws Exception{
    Map map = new HashMap();
    String id= req.getParameter("idBooking");
    Booking  booking =(Booking)(bookingManager.get(Integer.parseInt(id)));
    BookingDTO bookingDTO = new BookingDTO(booking);
    ArrayList<Structure>  hotels = new  ArrayList<Structure>();
    hotels.add(booking.getStructure());
    map.put("hotels", hotels);
    map.put("booking", bookingDTO);
    map.put("customer", booking.getCustomer());
    return map;
  }
 
  /**
   *
   */
  @Override
  protected Object formBackingObject(HttpServletRequest request)
      throws Exception {
   
   
    return super.formBackingObject(request);
  }
 

  /**
   *
   */
  @Override
  protected ModelAndView onSubmit(HttpServletRequest req,
      HttpServletResponse response, Object command, BindException errors)
  throws Exception {


    String id= req.getParameter("idBooking");
    Customer customer = (Customer) command;
    Booking  booking =(Booking)bookingManager.get(Integer.parseInt(id));

    customer.setStructure(booking.getStructure());
    customer.setHotelId(booking.getStructure().getId());
    booking.setCustomer(customer);
    bookingManager.checkIn(booking);

    return super.onSubmit(req, response, command, errors);
  }
 
  @Resource(name = "customerManager")
  public void setCustomerManager(ICustomerManager customerManager){
    this.customerManager=customerManager;
  }
 
 
  @Resource(name = "bookingManager")
  public void setBookingManager(IBookingManager bookingManager) {
    this.bookingManager = bookingManager;
  }


  @Resource(name = "structureManager")
  public void setStructureManager(IStructureManager structureManager) {
    this.structureManager = structureManager;
  }
 

}
TOP

Related Classes of it.hotel.controller.booking.BookingCheckinController

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.