/** * 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"); }
/** * 保存修改的PurchaseOrderItem * * @param mapping * @param form * @param request * @param response * @return ActionForward * @throws Exception */ public ActionForward update( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { BeanForm itemForm = (BeanForm) form; itemForm.setBeanLoader(ServiceLocator.getBeanLoader(request)); PurchaseOrderItem poi = this.getPurchaseOrderItemFromSession(request); if (itemForm.getString("isRecharge").equals(YesNo.YES.getEnumCode().toString())) itemForm.populateToBean(poi, request, new String[] {"buyForDepartment.id", "buyForUser.id"}); else itemForm.populateToBean(poi, request); poi.setRecharges(this.getRechargeInfoFromRequest(poi, request)); poi.setAttachments(this.getPurchaseOrderItemAttachmentListFromRequest(request)); request.setAttribute("X_OBJECT", poi); request.setAttribute("X_ROWPAGE", "purchaseOrder/itemRow.jsp"); // make itemRow.jsp edit version this.setEditing(true, request); return mapping.findForward("success"); }
/** * the action method for downloading hotel contract * * @param mapping * @param form * @param request * @param response * @return * @throws Exception */ public ActionForward download( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { HotelContract hotelContract = this.getHotelContractFromRequest(request); Hotel hotel = hotelContract.getHotel(); this.checkHotel(hotel, request); InputStream in = ServiceLocator.getHotelContractManager(request) .getHotelContractContent(hotelContract.getId()); if (in != null) { try { if (hotelContract.getFileSize() == 0) { throw new ActionException("hotelContract.error.fileSize.zero"); } else { DownloadUploadHelper.download( in, hotelContract.getFileName(), DownloadUploadHelper.getMime(hotelContract.getFileName()), hotelContract.getFileSize(), request, response, true); } } finally { in.close(); } } return null; }
private Hotel getHotelFromRequest(HttpServletRequest request) throws Exception { Integer id = ActionUtils.parseInt(request.getParameter("hotel_id")); HotelManager hotelManager = ServiceLocator.getHotelManager(request); Hotel hotel = hotelManager.getHotel(id); if (hotel == null) throw new ActionException("hotel.notFound", id); return hotel; }
private HotelContract getHotelContractFromRequest(HttpServletRequest request) throws Exception { Integer id = ActionUtils.parseInt(request.getParameter("id")); HotelContractManager hotelContractManager = ServiceLocator.getHotelContractManager(request); HotelContract hotelContract = hotelContractManager.getHotelContract(id); if (hotelContract == null) throw new ActionException("hotelContract.notFound", id); return hotelContract; }
/** * 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"); }
/** * action method for deleting PurchaseOrderItemReceipt * * @param mapping * @param form * @param request * @param response * @return * @throws Exception */ public ActionForward delete( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { PurchaseOrderItemReceipt poir = getPurchaseOrderItemReceiptFromRequest(request); this.checkDeletePower(poir, request); PurchaseOrderItemReceiptManager pm = ServiceLocator.getPurchaseOrderItemReceiptManager(request); pm.deletePurchaseOrderItemReceipt(poir, this.getCurrentUser(request)); return mapping.findForward("success"); }
public ActionForward listReceipt( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { PurchaseOrderManager fm = ServiceLocator.getPurchaseOrderManager(request); PurchaseOrderItemQueryForm queryForm = (PurchaseOrderItemQueryForm) form; if (StringUtils.isEmpty(queryForm.getOrder())) { // init queryForm queryForm.setOrder(PurchaseOrderItemQueryOrder.ITEMSPEC.getName()); queryForm.setDescend(false); } else if (PurchaseOrderItemQueryOrder.getEnum(queryForm.getOrder()) == null) throw new RuntimeException("order not found!"); Map conditions = constructQueryMap(queryForm); if (queryForm.isIncludeReceivedItem()) { conditions.put( PurchaseOrderItemQueryCondition.PO_STATUS_IN2, new Object[] { PurchaseOrderStatus.CONFIRMED.getEnumCode(), PurchaseOrderStatus.RECEIVED.getEnumCode() }); } else { conditions.put( PurchaseOrderItemQueryCondition.PO_STATUS_EQ, PurchaseOrderStatus.CONFIRMED.getEnumCode()); } Integer userId = this.getCurrentUser(request).getId(); conditions.put( PurchaseOrderItemQueryCondition.PR_REQUESTOR_OR_PO_INSPECTOR_EQ, new Object[] {userId, userId}); if (queryForm.isFirstInit()) { queryForm.init(fm.getPurchaseOrderItemListCount(conditions)); } else { queryForm.init(); } List result = fm.getPurchaseOrderItemList( conditions, queryForm.getPageNoAsInt(), queryForm.getPageSizeAsInt(), PurchaseOrderItemQueryOrder.getEnum(queryForm.getOrder()), queryForm.isDescend()); request.setAttribute("X_RESULTLIST", result); return mapping.findForward("page"); }
/** * the action method for searching hotel contract * * @param mapping * @param form * @param request * @param response * @return * @throws Exception */ public ActionForward list( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { HotelContractQueryForm queryForm = (HotelContractQueryForm) form; getHotelFromRequest(request); Map conditions = constructQueryMap(queryForm); HotelContractManager fm = ServiceLocator.getHotelContractManager(request); List result = fm.getHotelContractList(conditions, 0, -1, HotelContractQueryOrder.ID, false); request.setAttribute("X_RESULTLIST", result); return mapping.findForward("page"); }
private void putMaxQtyToRequest( PurchaseOrderItem poi, PurchaseOrderItemReceipt poir, HttpServletRequest request) throws Exception { PurchaseOrderItemReceiptManager pm = ServiceLocator.getPurchaseOrderItemReceiptManager(request); int receiveQty = pm.getRecevieSum(poi, this.getCurrentUser(request)); int maxQty = poi.getQuantity() - receiveQty; if (poir != null) { User currentUser = this.getCurrentUser(request); if (poir.getReceiver1().equals(currentUser) && poir.getReceiveQty1() != null) { maxQty += poir.getReceiveQty1().intValue(); } else if (poir.getReceiver2().equals(currentUser) && poir.getReceiveQty2() != null) { maxQty += poir.getReceiveQty2().intValue(); } } if (maxQty <= 0) throw new ActionException("purchaseOrderItemReceipt.edit.purchaseOrderItem.alreadyReceived"); request.setAttribute("x_maxQty", new Integer(maxQty)); }
/** * action method for listing PurchaseOrderItemReceipt * * @param mapping * @param form * @param request * @param response * @return * @throws Exception */ public ActionForward list( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { PurchaseOrderItem poi = this.getPurchaseOrderItemFromRequest(request); this.checkViewPower(poi, request); request.setAttribute("x_poi", poi); PurchaseOrderItemReceiptManager fm = ServiceLocator.getPurchaseOrderItemReceiptManager(request); Map conditions = new HashMap(); conditions.put(PurchaseOrderItemReceiptQueryCondition.PURCHASEORDERITEM_ID_EQ, poi.getId()); List result = fm.getPurchaseOrderItemReceiptList( conditions, 0, -1, PurchaseOrderItemReceiptQueryOrder.RECEIVEDATE1, true); request.setAttribute("X_RESULTLIST", result); 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"); }
/** * 修改PurchaseOrderItem * * @param mapping * @param form * @param request * @param response * @return ActionForward * @throws Exception */ public ActionForward edit( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { PurchaseOrderItem poi = this.getPurchaseOrderItemFromSession(request); // this.checkPurchaseOrderEditPower(poi.getPurchaseOrder(),request); PurchaseRequest pr = poi.getPurchaseRequestItem().getPurchaseRequest(); request.setAttribute("x_poi", poi); BeanForm itemForm = (BeanForm) this.getForm("/updatePurchaseOrderItem", request); if (!this.isBack(request)) { itemForm.populateToForm(poi); } // recharge this.setRechargeInfoToRequest( poi, poi.getRecharges(), pr.getDepartment().getSite(), itemForm, request); request.setAttribute("X_FORMNAME", "purchaseOrderItemForm"); // combo list SupplierManager sm = ServiceLocator.getSupplierManager(request); request.setAttribute( "x_supplierItemList", sm.getSuitableSupplierItemListForPurchase( poi.getSupplier(), poi.getPurchaseOrder().getSubCategory(), poi.getExchangeRate().getCurrency())); this.putPurchaseTypeListToRequest(pr.getDepartment().getSite(), request); this.putProjectCodeToRequest(pr.getDepartment().getSite(), request); // make itemAttacmentRow.jsp edit version this.setEditing(true, request); return mapping.findForward("page"); }
/** * action method for updating PurchaseOrderItemReceipt * * @param mapping * @param form * @param request * @param response * @return * @throws Exception */ public ActionForward update( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { PurchaseOrderItemReceipt poir = this.getPurchaseOrderItemReceiptFromRequest(request); this.checkEditPower(poir, request); BeanForm purchaseOrderItemReceiptForm = (BeanForm) form; purchaseOrderItemReceiptForm.populateToBean(poir, request); PurchaseOrderItemReceiptManager pm = ServiceLocator.getPurchaseOrderItemReceiptManager(request); if (!pm.checkQty(poir)) throw new BackToInputActionException("purchaseOrderItemReceipt.qtyExceeds"); PurchaseOrderItemReceipt oldPoir = this.getPurchaseOrderItemReceiptFromRequest(request); request.setAttribute( "X_OBJECT", pm.updatePurchaseOrderItemReceipt(oldPoir, poir, this.getCurrentUser(request))); request.setAttribute("X_ROWPAGE", "purchaseOrderItemReceipt/row.jsp"); return mapping.findForward("success"); }
private void putPurchaseTypeListToRequest(Site site, HttpServletRequest request) { PurchaseTypeManager pm = ServiceLocator.getPurchaseTypeManager(request); request.setAttribute("x_purchaseTypeList", pm.getEnabledPurchaseTypeList(site)); }