List of usage examples for org.springframework.web.bind.support SessionStatus setComplete
void setComplete();
From source file:csns.web.controller.DepartmentSectionControllerS.java
@RequestMapping(value = "/department/{dept}/section/import", method = RequestMethod.POST) public String importSection(@ModelAttribute("importer") GradesImporter importer, @PathVariable String dept, @RequestParam("_page") int currentPage, HttpServletRequest request, SessionStatus sessionStatus) { if (request.getParameter("_finish") == null) { int targetPage = WebUtils.getTargetPage(request, "_target", currentPage); if (targetPage == 1 && currentPage < targetPage) { importer.clear();//from w ww .j a v a2 s . c o m Section section = importer.getSection(); List<Section> sections = sectionDao.getSectionsByInstructor(section.getInstructors().get(0), section.getQuarter(), section.getCourse()); for (Section s : sections) importer.getSectionNumbers().add(s.getNumber()); section.setNumber( importer.getSectionNumbers().size() == 0 ? -1 : importer.getSectionNumbers().get(0)); } if (targetPage == 2) { int number = importer.getSection().getNumber(); if (number > 0) { Quarter quarter = importer.getSection().getQuarter(); Course course = importer.getSection().getCourse(); Section section = sectionDao.getSection(quarter, course, number); for (ImportedUser student : importer.getImportedStudents()) { User user = userDao.getUserByCin(student.getCin()); if (user == null) { student.setNewAccount(true); student.setNewEnrollment(true); } else { Enrollment enrollment = section.getEnrollment(user); if (enrollment == null) student.setNewEnrollment(true); else if (enrollment.getGrade() != null) student.setOldGrade(enrollment.getGrade().getSymbol()); } } } } return "department/section/import" + targetPage; } // received _finish, so do the import. Quarter quarter = importer.getSection().getQuarter(); Course course = importer.getSection().getCourse(); int number = importer.getSection().getNumber(); Section section = number > 0 ? sectionDao.getSection(quarter, course, number) : sectionDao.addSection(quarter, course, importer.getSection().getInstructors().get(0)); for (ImportedUser importedStudent : importer.getImportedStudents()) { String cin = importedStudent.getCin(); User student = userDao.getUserByCin(cin); if (student == null) { student = new User(); student.setCin(cin); student.setLastName(importedStudent.getLastName()); student.setFirstName(importedStudent.getFirstName()); student.setMiddleName(importedStudent.getMiddleName()); student.setUsername(cin); String password = passwordEncoder.encodePassword(cin, null); student.setPassword(password); student.setPrimaryEmail(cin + "@localhost"); student.setTemporary(true); student = userDao.saveUser(student); } Enrollment enrollment = section.getEnrollment(student); if (enrollment == null) enrollment = new Enrollment(section, student); if (importedStudent.getGrade() != null && (enrollment.getGrade() == null || !enrollment.getGrade().getSymbol().equalsIgnoreCase(importedStudent.getGrade()))) { enrollment.setGrade(gradeDao.getGrade(importedStudent.getGrade())); enrollmentDao.saveEnrollment(enrollment); } } logger.info( SecurityUtils.getUser().getUsername() + " imported section " + section.getQuarter().getShortString() + " " + section.getCourse().getCode() + "-" + section.getNumber()); sessionStatus.setComplete(); return "redirect:/department/" + dept + "/section?id=" + section.getId(); }
From source file:org.motechproject.server.omod.web.controller.PatientController.java
@RequestMapping(value = "/module/motechmodule/patient", method = RequestMethod.POST) public String submitForm(@ModelAttribute("patient") WebPatient patient, Errors errors, ModelMap model, SessionStatus status) { log.debug("Register Patient"); if (patient.getMotechId() != null) { String motechIdString = patient.getMotechId().toString(); boolean validId = false; MotechIdVerhoeffValidator validator = new MotechIdVerhoeffValidator(); try {// w ww . jav a 2 s. c o m validId = validator.isValid(motechIdString); } catch (Exception e) { } if (!validId) { errors.rejectValue("motechId", "motechmodule.motechId.invalid"); } else if (openmrsBean.getPatientByMotechId(motechIdString) != null) { errors.rejectValue("motechId", "motechmodule.motechId.nonunique"); } } if (patient.getRegistrantType() == RegistrantType.PREGNANT_MOTHER) { if (patient.getDueDate() != null) { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.MONTH, 9); if (patient.getDueDate().after(calendar.getTime())) { errors.rejectValue("dueDate", "motechmodule.dueDate.overninemonths"); } } } else if (patient.getRegistrantType() == RegistrantType.CHILD_UNDER_FIVE) { if (patient.getBirthDate() != null) { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.YEAR, -5); if (patient.getBirthDate().before(calendar.getTime())) { errors.rejectValue("birthDate", "motechmodule.birthDate.notunderfive"); } } } if (patient.getBirthDate() != null) { if (patient.getBirthDate().after(Calendar.getInstance().getTime())) { errors.rejectValue("birthDate", "motechmodule.birthdate.future"); } } Community community = null; if (patient.getCommunityId() != null) { community = registrarBean.getCommunityById(patient.getCommunityId()); if (community == null) { errors.rejectValue("communityId", "motechmodule.communityId.notexist"); } } Facility facility = null; if (patient.getFacility() != null) { facility = registrarBean.getFacilityById(patient.getFacility()); if (facility == null) { errors.rejectValue("facility", "motechmodule.facility.does.not.exist"); } } Patient mother = null; if (patient.getMotherMotechId() != null) { mother = openmrsBean.getPatientByMotechId(patient.getMotherMotechId().toString()); if (mother == null) { errors.rejectValue("motherMotechId", "motechmodule.motechId.notexist"); } } if (patient.getPhoneNumber() != null && !patient.getPhoneNumber().matches(MotechConstants.PHONE_REGEX_PATTERN)) { errors.rejectValue("phoneNumber", "motechmodule.phoneNumber.invalid"); } if (!errors.hasErrors()) { registrarBean.registerPatient(patient.getRegistrationMode(), patient.getMotechId(), patient.getRegistrantType(), patient.getFirstName(), patient.getMiddleName(), patient.getLastName(), patient.getPrefName(), patient.getBirthDate(), patient.getBirthDateEst(), patient.getSex(), patient.getInsured(), patient.getNhis(), patient.getNhisExpDate(), mother, community, facility, patient.getAddress(), patient.getPhoneNumber(), patient.getDueDate(), patient.getDueDateConfirmed(), patient.getEnroll(), patient.getConsent(), patient.getPhoneType(), patient.getMediaType(), patient.getLanguage(), patient.getDayOfWeek(), patient.getTimeOfDay(), patient.getInterestReason(), patient.getHowLearned(), patient.getMessagesStartWeek()); model.addAttribute("successMsg", "motechmodule.Patient.register.success"); status.setComplete(); return "redirect:/module/motechmodule/viewdata.form"; } JSONLocationSerializer.populateJavascriptMaps(model, patient.getPreferredLocation()); return "/module/motechmodule/patient"; }
From source file:egovframework.example.sample.web.EgovSampleController.java
@RequestMapping(value = "/allDeleteKart.do", method = RequestMethod.POST) public String allDeleteKart(SessionStatus status, Model model, HttpServletRequest request) throws Exception { status.setComplete(); HttpSession hs = request.getSession(); Account loginInfo = (Account) hs.getAttribute("userInfo"); KartVO kart = new KartVO(); kart.setK_id(loginInfo.getA_id());//from ww w. j a v a 2 s.c om sampleService.allDeleteKart(kart); status.setComplete(); List<KartVO> kartList = sampleService.kartList(kart); int kc = 0; kc += kartList.size(); model.addAttribute("kartCount", kc); int sum = 0; int cashSum = 0; String deliveryPay = "no"; for (int i = 0; i < kartList.size(); i++) { KartVO kvo = kartList.get(i); // System.out.println(kvo.getK_price()); sum += kvo.getK_price(); cashSum += kvo.getK_cash(); if (kvo.getK_deliveryprice() == 4000) { deliveryPay = "yes"; } } model.addAttribute("sum", sum); model.addAttribute("cashSum", cashSum); model.addAttribute("deliveryPay", deliveryPay); model.addAttribute("resultList", kartList); model.addAttribute("login", "loginOK.jsp"); model.addAttribute("main", "kartPage.jsp"); return "sample/home"; }
From source file:cdr.forms.FormController.java
@RequestMapping(value = "/{formId}.form", method = RequestMethod.POST) public String processForm(Model model, @PathVariable(value = "formId") String formId, @Valid @ModelAttribute("deposit") Deposit deposit, BindingResult errors, Principal user, SessionStatus sessionStatus, @RequestParam(value = "deposit", required = false) String submitDepositAction, HttpServletRequest request, HttpServletResponse response) throws PermissionDeniedException { request.setAttribute("hasSupplementalObjectsStep", formId.equals(SUPPLEMENTAL_OBJECTS_FORM_ID)); // Check that the form submitted by the user matches the one in the session if (!deposit.getFormId().equals(formId)) throw new Error("Form ID in session doesn't match form ID in path"); ///* www. j a va 2 s .com*/ this.getAuthorizationHandler().checkPermission(formId, deposit.getForm(), request); // try { request.setCharacterEncoding("UTF-8"); } catch (UnsupportedEncodingException e) { LOG.error("Failed to set character encoding", e); } // if (user != null) deposit.getForm().setCurrentUser(user.getName()); // Remove entries set to null, append an entry for elements with append set for (DepositElement element : deposit.getElements()) { Iterator<DepositEntry> iterator = element.getEntries().iterator(); while (iterator.hasNext()) { if (iterator.next() == null) iterator.remove(); } if (element.getAppend() != null) { element.appendEntry(); element.setAppend(null); } } // Check the deposit's files for virus signatures IdentityHashMap<DepositFile, String> signatures = new IdentityHashMap<DepositFile, String>(); for (DepositFile depositFile : deposit.getAllFiles()) scanDepositFile(depositFile, signatures); // If the "submit deposit" button was pressed, run the validator. if (submitDepositAction != null) { Validator validator = new DepositValidator(); validator.validate(deposit, errors); } // If the deposit has validation errors and no virus signatures were detected, display errors if (errors.hasErrors() && signatures.size() == 0) { LOG.debug(errors.getErrorCount() + " errors"); return "form"; } // If the "submit deposit" button was not pressed, render the form again if (submitDepositAction == null) { return "form"; } // Otherwise, display one of the result pages: if we detected a virus signature, display // the virus warning; otherwise, try to submit the deposit and display results. In each // case, we want to do the same cleanup. String view; if (signatures.size() > 0) { model.addAttribute("signatures", signatures); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); view = "virus"; } else { // Redirect for supplemental objects special case if (formId.equals(SUPPLEMENTAL_OBJECTS_FORM_ID)) { return "redirect:/supplemental"; } // We're doing a regular deposit, so call the deposit handler DepositResult result = this.getDepositHandler().deposit(deposit); if (result.getStatus() == Status.FAILED) { LOG.error("deposit failed"); if (getNotificationHandler() != null) getNotificationHandler().notifyError(deposit, result); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); view = "failed"; } else { if (getNotificationHandler() != null) getNotificationHandler().notifyDeposit(deposit, result); view = "success"; } } // Clean up deposit.deleteAllFiles(); sessionStatus.setComplete(); request.setAttribute("formId", formId); request.setAttribute("administratorEmail", getAdministratorEmail()); return view; }
From source file:egovframework.example.sample.web.EgovSampleController.java
/** * ? ?.//from w w w.j a va 2 s.com * @param sampleVO - ? VO * @param searchVO - ? VO * @param status * @return "forward:/egovSampleList.do" * @exception Exception */ @RequestMapping(value = "/addSample.do", method = RequestMethod.POST) public String addSample(@ModelAttribute("searchVO") SampleDefaultVO searchVO, SampleVO sampleVO, BindingResult bindingResult, Model model, SessionStatus status) throws Exception { // Server-Side Validation beanValidator.validate(sampleVO, bindingResult); if (bindingResult.hasErrors()) { model.addAttribute("sampleVO", sampleVO); return "sample/boardWrite"; } sampleService.insertSample(sampleVO); status.setComplete(); return "forward:/egovSampleList.do"; }
From source file:egovframework.example.sample.web.EgovSampleController.java
@RequestMapping(value = "/selectedDeleteKart.do", method = RequestMethod.POST) public String selectedDeleteKart(SessionStatus status, Model model, HttpServletRequest request, @RequestParam("chk") int[] chk) throws Exception { KartVO vo = new KartVO(); for (int i = 0; i < chk.length; i++) { int seq = chk[i]; System.out.println("??seq = " + seq); vo.setK_seq(seq);// w w w . j ava 2s.com sampleService.selectedDeleteKart(vo); status.setComplete(); System.out.println(seq + " "); } HttpSession hs = request.getSession(); Account loginInfo = (Account) hs.getAttribute("userInfo"); KartVO kart = new KartVO(); kart.setK_id(loginInfo.getA_id()); List<KartVO> kartList = sampleService.kartList(kart); int kc = 0; kc += kartList.size(); model.addAttribute("kartCount", kc); int sum = 0; int cashSum = 0; String deliveryPay = "no"; for (int i = 0; i < kartList.size(); i++) { KartVO kvo = kartList.get(i); // System.out.println(kvo.getK_price()); sum += kvo.getK_price(); cashSum += kvo.getK_cash(); if (kvo.getK_deliveryprice() == 4000) { deliveryPay = "yes"; } } model.addAttribute("sum", sum); model.addAttribute("cashSum", cashSum); model.addAttribute("deliveryPay", deliveryPay); model.addAttribute("resultList", kartList); model.addAttribute("login", "loginOK.jsp"); model.addAttribute("main", "kartPage.jsp"); return "sample/home"; }
From source file:egovframework.example.sample.web.EgovSampleController.java
/** * ? .//from w ww. j a v a 2s . co m * @param sampleVO - VO * @param searchVO - ? VO * @param status * @return "forward:/egovSampleList.do" * @exception Exception */ @RequestMapping("/updateSample.do") public String updateSample(HttpServletRequest request, @ModelAttribute("searchVO") SampleDefaultVO searchVO, SampleVO sampleVO, BindingResult bindingResult, Model model, SessionStatus status) throws Exception { beanValidator.validate(sampleVO, bindingResult); if (bindingResult.hasErrors()) { model.addAttribute("sampleVO", sampleVO); // return "sample/egovSampleRegister"; loginCheck(request); model.addAttribute("main", "egovSampleRegister.jsp"); return "sample/home"; } sampleService.updateSample(sampleVO); status.setComplete(); loginCheck(request); model.addAttribute("main", "goFreebbs.jsp"); return "forward:/egovSampleList.do"; // return "sample/home"; }
From source file:egovframework.example.sample.web.EgovSampleController.java
@RequestMapping(value = "/doModifyId.do", method = { RequestMethod.GET, RequestMethod.POST }) public String doModifyId(HttpServletRequest request, @RequestParam("j_id") String a_id, @RequestParam("j_pw") String a_pw, @RequestParam("j_name") String a_name, @RequestParam("j_adress") String a_adress, @RequestParam("j_phone") String a_phone, @RequestParam("j_hint") String a_hint, @RequestParam("j_respond") String a_respond, Model model, SessionStatus status ) throws Exception { HttpSession hs = request.getSession(); Account loginInfo = (Account) hs.getAttribute("userInfo"); System.out.println("? "); System.out.println("? " + a_phone); System.out.println("int " + a_phone); Account ac = new Account(a_id, a_pw, a_name, a_adress, a_hint, a_respond, a_phone); ac.setA_cash(loginInfo.getA_cash()); sampleService.modifyId(ac);/*from w ww .j a v a 2 s . c om*/ status.setComplete(); //HttpSession hs = request.getSession(); // hs.invalidate(); hs.setAttribute("userInfo", ac); hs.setMaxInactiveInterval(1 * 60 * 60); model.addAttribute("login", "loginOK.jsp"); // model.addAttribute("main", "defaultMain.jsp"); return "forward:/home.do"; }
From source file:egovframework.example.sample.web.EgovSampleController.java
@RequestMapping(value = "/join.do", method = RequestMethod.POST) public String join(HttpServletRequest request, @RequestParam("j_id") String a_id, @RequestParam("j_pw") String a_pw, @RequestParam("j_name") String a_name, @RequestParam("j_adress") String a_adress, @RequestParam("j_phone") String a_phone, @RequestParam("j_hint") String a_hint, @RequestParam("j_respond") String a_respond, Model model, SessionStatus status ) throws Exception { System.out.println(" ??" + a_id); Account ac = new Account(a_id, a_pw, a_name, a_adress, a_hint, a_respond, a_phone); int IDCheck = sampleService.joinIdCheck(ac); System.out.println("? : " + IDCheck); if (IDCheck > 0) {//? ? System.out.println("? "); model.addAttribute("idCheck", "? ID ."); model.addAttribute("login", "login.jsp"); model.addAttribute("main", "joinPage.jsp"); } else {//? ? System.out.println("."); sampleService.join(ac);//from w ww . java 2 s. co m status.setComplete(); model.addAttribute("welcomeNname", a_name); model.addAttribute("login", "login.jsp"); model.addAttribute("main", "welcome.jsp"); } return "sample/home"; }
From source file:egovframework.example.sample.web.EgovSampleController.java
@RequestMapping(value = "/orderSeetUpdate.do") public void orderSeetUpdate(HttpServletRequest request, HttpServletResponse response, SessionStatus status) throws Exception { PlatformData oData = new PlatformData(); int nErrorCode = 0; String strErrorMsg = "START"; HttpPlatformRequest pReq = new HttpPlatformRequest(request); pReq.receiveData();//???? ?? PlatformData iData = pReq.getData(); VariableList in_vl = iData.getVariableList(); String code = in_vl.getString("sVal1"); // try {//from w ww . ja v a2s.com int del = Integer.parseInt(request.getParameter("del")); //1- 0-\ OrderSeetListVO oslVO = new OrderSeetListVO(); oslVO.setOl_code(code); if (del == 1) { oslVO.setOl_delivery(" "); sampleService.changeDeliv(oslVO); status.setComplete(); System.out.println(" "); } else { oslVO.setOl_delivery(" "); sampleService.changeDeliv(oslVO); status.setComplete(); System.out.println(" "); } strErrorMsg = "SUCC"; } catch (Exception e) { nErrorCode = -1; strErrorMsg = e.getMessage(); e.printStackTrace(); } // VariableList VariableList varList = oData.getVariableList(); // VariableList? ? ? varList.add("ErrorCode", nErrorCode); varList.add("ErrorMsg", strErrorMsg); System.out.println("-------" + nErrorCode + strErrorMsg); // HttpServletResponse ? HttpPlatformResponse ? HttpPlatformResponse pRes = new HttpPlatformResponse(response, PlatformType.CONTENT_TYPE_XML, "UTF-8"); pRes.setData(oData); // ?? pRes.sendData(); }