protected void processDeleteModel(
     String actionCode, String actionObject, HttpServletRequest request) throws SQLException {
   GosReservationMgr gosReservationMgr = (GosReservationMgr) this.getManagerFromSession(request);
   gosReservationMgr.setFunctionMode(Constant.DELETE);
   //        this.setHttpRequestOrderList(request, gosFrontdeskMgr);
   //
   // gosFrontdeskMgr.getCurrentFrontdesk().getSelectedUnit().getBill().removeOrderChecked();
 }
 protected void processConfirmModel(
     String actionCode, String actionObject, HttpServletRequest request) throws SQLException {
   GosReservationMgr gosReservationMgr = (GosReservationMgr) this.getManagerFromSession(request);
   if (actionObject.equals("reservation")) {
     setHttpRequestReservation(request, gosReservationMgr);
     gosReservationMgr.getCurrentReservation().getSelectedUnit().validate();
   }
 }
 protected void initModel(String page, HttpServletRequest request) throws SQLException {
   GosReservationMgr gosReservationMgr = new GosReservationMgr();
   this.putManagerToSession(request, gosReservationMgr);
   if (page.equals("reservation")) {
     gosReservationMgr.setEntryMode(Constant.RESERVATION);
     //        	gosReservationMgr.getCurrentReservation().refreshUnitList();
     gosReservationMgr.getReservationMeta().refreshReservationList();
     this.setHttpRequestReservation(request, gosReservationMgr);
   } else if (page.equals("reservationList")) {
     gosReservationMgr.setEntryMode(Constant.RESERVATION_LIST);
     //        	gosReservationMgr.getCurrentReservation().refreshUnitList();
     gosReservationMgr.getReservationMeta().refreshReservationList();
     this.setHttpRequestReservation(request, gosReservationMgr);
   }
 }
  protected void processEditModel(
      String actionCode, String actionObject, HttpServletRequest request) throws SQLException {

    GosReservationMgr gosReservationMgr = (GosReservationMgr) this.getManagerFromSession(request);
    gosReservationMgr.setFunctionMode(Constant.EDIT);
    String key;

    if (actionCode.split("-").length > 2) {
      key = actionCode.split("-")[2];
    }

    //        if (actionObject.equals("Order")) {
    //            gosFrontdeskMgr.getItemMeta().refreshItemList();
    //            gosFrontdeskMgr.setNavigationMode(Constant.ORDER);
    //        } else if (actionObject.equals("Bill")) {
    //            gosFrontdeskMgr.getItemMeta().refreshItemList();
    //            gosFrontdeskMgr.setNavigationMode(Constant.BILL);
    //        }

    //		if (actionObject.equals("Open")) {
    //			gosFrontdeskMgr.getCurrentFrontdesk().getSelectedUnit().setOpen(true);
    //		}

    // } else if (actionObject.equals("Subcategory")) {
    // Subcategory subcategory = (Subcategory)
    // Utility.getObject(gosFrontdeskMgr.getSubcategoryMeta().getSubcategoryList(), key);
    // subcategory.setSaved(false);
    // gosFrontdeskMgr.setCurrentSubcategory(subcategory);
    // } else if (actionObject.equals("Department")) {
    // Department department = (Department)
    // Utility.getObject(gosFrontdeskMgr.getDepartmentMeta().getDepartmentList(), key);
    // department.setSaved(false);
    // gosFrontdeskMgr.setCurrentDepartment(department);
    //
    // } else if (actionObject.equals("Area")) {
    // Area area = (Area) Utility.getObject(gosFrontdeskMgr.getAreaMeta().getAreaList(), key);
    // area.setSaved(false);
    // gosFrontdeskMgr.setCurrentArea(area);
    //
    // } else if (actionObject.equals("Unit")) {
    // Unit unit = (Unit) Utility.getObject(gosFrontdeskMgr.getUnitMeta().getUnitList(), key);
    // unit.setSaved(false);
    // gosFrontdeskMgr.setCurrentUnit(unit);
    //
    //
    // }

  }
  protected void forwardView(
      String actionEvent,
      String actionObject,
      HttpServletRequest request,
      HttpServletResponse response)
      throws ServletException, IOException {
    GosReservationMgr gosReservationMgr = (GosReservationMgr) this.getManagerFromSession(request);
    String page = request.getParameter("page");

    if (gosReservationMgr.getEntryMode().equals(Constant.RESERVATION)) {
      getServletContext()
          .getRequestDispatcher("/jsp/gos/reservation/reservation.jsp")
          .forward(request, response);
    } else if (gosReservationMgr.getEntryMode().equals(Constant.RESERVATION_LIST)) {
      getServletContext()
          .getRequestDispatcher("/jsp/gos/reservation/reservationList.jsp")
          .forward(request, response);
    }
  }
  private void setHttpRequestReservation(
      HttpServletRequest request, GosReservationMgr gosReservationMgr) {

    gosReservationMgr
        .getCurrentReservation()
        .setReservationId(request.getParameter("reservationId"));
    gosReservationMgr.getCurrentReservation().setUnitType(request.getParameter("unitType"));
    gosReservationMgr.getCurrentReservation().setUnitName(request.getParameter("unitName"));
    gosReservationMgr.getCurrentReservation().setArea(request.getParameter("area"));
    //    	 gosReservationMgr.getCurrentReservation().setCustomer(request.getParameter("customer"));
    //
    // gosReservationMgr.getCurrentReservation().setNoOfPeople(request.getParameter("noOfPeople"));
    //
    // gosReservationMgr.getCurrentReservation().setReservationDate(request.getParameter("reservationDate"));
    //
    // gosReservationMgr.getCurrentReservation().setTelephone(request.getParameter("telephone"));
    //    	 gosReservationMgr.getCurrentReservation().setEmployee(request.getParameter("employee"));
    //    	 gosReservationMgr.getCurrentReservation().setRemark(request.getParameter("remark"));
  }
  protected void processSelectModel(
      String actionCode, String actionObject, HttpServletRequest request) throws SQLException {

    GosReservationMgr gosReservationMgr = (GosReservationMgr) this.getManagerFromSession(request);
    String key = actionCode.split("-")[2];

    if (actionObject.equals("reservation")) {
      setHttpRequestReservation(request, gosReservationMgr);
      gosReservationMgr.getCurrentReservation().validate();
      System.out.println(
          "gosReservationMgr.getCurrentReservation().isValid() : "
              + gosReservationMgr.getCurrentReservation().isValid());
      if (gosReservationMgr.getCurrentReservation().isValid()) {
        gosReservationMgr.getCurrentReservation().save();
        if (gosReservationMgr.getCurrentReservation().isValid()
            && !gosReservationMgr.getFunctionMode().equals(Constant.EDIT)) {
          ((LinkedList) gosReservationMgr.getReservationMeta().getReservationList())
              .addFirst(gosReservationMgr.getCurrentReservation());
        }
      }
    }
  }