/** * the action method for inserting new hotel contract to db * * @param mapping * @param form * @param request * @param response * @return * @throws Exception */ public ActionForward insert( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { Hotel hotel = this.getHotelFromRequest(request); this.checkHotel(hotel, request); BeanForm hotelContractForm = (BeanForm) form; HotelContract hotelContract = new HotelContract(); hotelContractForm.populate(hotelContract, BeanForm.TO_BEAN); hotelContract.setHotel(hotel); FormFile file = (FormFile) hotelContractForm.get("fileContent"); hotelContract.setFileName(file.getFileName()); HotelContractManager hotelContractManager = ServiceLocator.getHotelContractManager(request); HotelContract newHc = null; if (file.getFileSize() > 0) { hotelContract.setFileSize(file.getFileSize()); newHc = hotelContractManager.insertHotelContract(hotelContract, file.getInputStream()); } else { throw new ActionException("hotelContract.error.fileSize.zero"); } request.setAttribute("X_OBJECT", newHc); request.setAttribute("X_ROWPAGE", "hotelContract/row.jsp"); return mapping.findForward("success"); }
/** * action method for inserting PurchaseOrderItemReceipt * * @param mapping * @param form * @param request * @param response * @return * @throws Exception */ public ActionForward insert( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { PurchaseOrderItem poi = this.getPurchaseOrderItemFromRequest(request); this.checkEditPower(poi, request); BeanForm purchaseOrderItemReceiptForm = (BeanForm) form; PurchaseOrderItemReceipt poir = new PurchaseOrderItemReceipt(); purchaseOrderItemReceiptForm.populate(poir, BeanForm.TO_BEAN); poir.setPurchaseOrderItem(poi); PurchaseOrderItemReceiptManager pm = ServiceLocator.getPurchaseOrderItemReceiptManager(request); if (!pm.checkQty(poir)) throw new BackToInputActionException("purchaseOrderItemReceipt.qtyExceeds"); poir = pm.insertPurchaseOrderItemReceipt(poir, this.getCurrentUser(request)); request.setAttribute("X_OBJECT", poir); request.setAttribute("X_ROWPAGE", "purchaseOrderItemReceipt/row.jsp"); EmailManager em = ServiceLocator.getEmailManager(request); Map context = new HashMap(); User emailToUser = null; if (this.getCurrentUser(request).equals(poir.getReceiver1())) { emailToUser = poir.getReceiver2(); context.put("x_receiveQty", poir.getReceiveQty1()); context.put("x_receiveDate", poir.getReceiveDate1()); } else { emailToUser = poir.getReceiver1(); context.put("x_receiveQty", poir.getReceiveQty2()); context.put("x_receiveDate", poir.getReceiveDate2()); } context.put("x_emailToUser", emailToUser); context.put("x_receiver", this.getCurrentUser(request)); context.put("x_poir", poir); context.put("role", EmailManager.EMAIL_ROLE_RECEIVER); em.insertEmail(poir.getLogSite(), emailToUser.getEmail(), "POItemReceive.vm", context); return mapping.findForward("success"); }
/** * the action method for creating hotel contract * * @param mapping * @param form * @param request * @param response * @return * @throws Exception */ public ActionForward newObject( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { Hotel hotel = this.getHotelFromRequest(request); this.checkHotel(hotel, request); if (!isBack(request)) { HotelContract hotelContract = new HotelContract(); hotelContract.setHotel(hotel); BeanForm hotelContractForm = (BeanForm) getForm("/insertHotelContract", request); hotelContractForm.populate(hotelContract, BeanForm.TO_FORM); } putEnumListToRequest(request); return mapping.findForward("page"); }
/** * the action method for updating hotel contract * * @param mapping * @param form * @param request * @param response * @return * @throws Exception */ public ActionForward update( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { Hotel hotel = this.getHotelFromRequest(request); this.checkHotel(hotel, request); BeanForm hotelContractForm = (BeanForm) form; HotelContract hotelContract = new HotelContract(); hotelContractForm.populate(hotelContract, BeanForm.TO_BEAN); HotelContractManager hotelContractManager = ServiceLocator.getHotelContractManager(request); request.setAttribute("X_OBJECT", hotelContractManager.updateHotelContract(hotelContract)); request.setAttribute("X_ROWPAGE", "hotelContract/row.jsp"); return mapping.findForward("success"); }
/** * the action method for editing hotel contract * * @param mapping * @param form * @param request * @param response * @return * @throws Exception */ public ActionForward edit( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { HotelContract hotelContract = getHotelContractFromRequest(request); Hotel hotel = hotelContract.getHotel(); this.checkHotel(hotel, request); request.setAttribute("x_hotelContract", hotelContract); if (!isBack(request)) { BeanForm hotelContractForm = (BeanForm) getForm("/updateHotelContract", request); hotelContractForm.populate(hotelContract, BeanForm.TO_FORM); } putEnumListToRequest(request); return mapping.findForward("page"); }