Example usage for org.springframework.web.bind.support SessionStatus setComplete

List of usage examples for org.springframework.web.bind.support SessionStatus setComplete

Introduction

In this page you can find the example usage for org.springframework.web.bind.support SessionStatus setComplete.

Prototype

void setComplete();

Source Link

Document

Mark the current handler's session processing as complete, allowing for cleanup of session attributes.

Usage

From source file:nl.surfnet.coin.teams.control.AddTeamController.java

@RequestMapping(value = "/doaddteam.shtml", method = RequestMethod.POST)
public String addTeam(ModelMap modelMap, @ModelAttribute("team") Team team, HttpServletRequest request,
        @ModelAttribute(TokenUtil.TOKENCHECK) String sessionToken, @RequestParam() String token,
        SessionStatus status) throws IOException {
    TokenUtil.checkTokens(sessionToken, token, status);
    ViewUtil.addViewToModelMap(request, modelMap);

    Person person = (Person) request.getSession().getAttribute(LoginInterceptor.PERSON_SESSION_KEY);
    String personId = person.getId();

    String admin2 = request.getParameter("admin2");
    modelMap.addAttribute("admin2", admin2);
    String admin2Message = request.getParameter("admin2message");
    modelMap.addAttribute("admin2message", admin2Message);

    // Check if the user has permission
    if (PermissionUtil.isGuest(request)) {
        throw new RuntimeException("User is not allowed to add a team!");
    }/*from ww  w.  j a  v a2 s .  c o  m*/
    // Check if the user is not requesting the wrong stem.
    if (team.getStem() != null && !isPersonUsingAllowedStem(personId, team.getStem().getId())) {
        throw new RuntimeException("User is not allowed to add a team!");
    }
    String stemId = team.getStem() != null ? team.getStem().getId() : environment.getDefaultStemName();
    // (Ab)using a Team bean, do not use for actual storage
    String teamName = team.getName();
    // Form not completely filled in.
    if (!StringUtils.hasText(teamName)) {
        modelMap.addAttribute("nameerror", "empty");
        return "addteam";
    }
    // Colons conflict with the stem name
    teamName = teamName.replace(":", "");

    String teamDescription = team.getDescription();

    // Add the team
    String teamId;
    try {
        teamId = grouperTeamService.addTeam(teamName, teamName, teamDescription, stemId);
        AuditLog.log("User {} added team (name: {}, id: {}) with stem {}", personId, teamName, teamId, stemId);
        final Locale locale = localeResolver.resolveLocale(request);
        inviteAdmin(teamId, person, admin2, teamName, admin2Message, locale);
    } catch (DuplicateTeamException e) {
        modelMap.addAttribute("nameerror", "duplicate");
        return "addteam";
    }

    // Set the visibility of the group
    grouperTeamService.setVisibilityGroup(teamId, team.isViewable());

    // Add the person who has added the team as admin to the team.
    grouperTeamService.addMember(teamId, person);

    // Give him the right permissions, add as the super user
    grouperTeamService.addMemberRole(teamId, personId, Role.Admin, environment.getGrouperPowerUser());

    status.setComplete();
    modelMap.clear();
    if (environment.isGroupzyEnabled()) {
        return String.format("redirect:/teams/%s/service-providers.shtml?view=", teamId,
                ViewUtil.getView(request));
    } else {
        return "redirect:detailteam.shtml?team=" + URLEncoder.encode(teamId, "utf-8") + "&view="
                + ViewUtil.getView(request);

    }

}

From source file:org.openmrs.module.billing.web.controller.main.ServiceManageController.java

@RequestMapping(method = RequestMethod.POST)
public String submit(@ModelAttribute("command") Object command, BindingResult binding,
        SessionStatus sessionStatus, @RequestParam("cons") Integer[] concepts, HttpServletRequest request,
        Model model) {// w w  w.  jav  a 2 s . c  o  m

    ConceptService cs = Context.getConceptService();
    Integer root = Integer.valueOf(Context.getAdministrationService()
            .getGlobalProperty(BillingConstants.GLOBAL_PROPRETY_SERVICE_CONCEPT));
    validate(concepts, request, binding);
    if (binding.hasErrors()) {
        log.info(binding.getAllErrors());

        Concept concept = cs.getConcept(root);

        BillingService billingService = Context.getService(BillingService.class);

        List<BillableService> services = billingService.getAllServices();

        Map<Integer, BillableService> mapServices = new HashMap<Integer, BillableService>();

        for (BillableService ser : services) {
            if (ser.getPrice() != null)
                mapServices.put(ser.getConceptId(), ser);
        }

        model.addAttribute("errors", binding.getAllErrors());
        model.addAttribute("tree", billingService.traversServices(concept, mapServices));
        return "/module/billing/main/serviceManage";
    }

    BillingService billingService = Context.getService(BillingService.class);
    List<BillableService> services = billingService.getAllServices();

    Map<Integer, BillableService> mapServices = new HashMap<Integer, BillableService>();

    for (BillableService ser : services) {
        mapServices.put(ser.getConceptId(), ser);
    }
    for (int conId : concepts) {

        String name = request.getParameter(conId + "_name");
        String shortName = request.getParameter(conId + "_shortName");
        String price = request.getParameter(conId + "_price");
        String serviceTypeText = request.getParameter(conId + "_type");

        BillableService service = mapServices.get(conId);
        if (service == null) {
            service = new BillableService();
            service.setConceptId(conId);
            service.setName(name);
            service.setShortName(shortName);
            if (StringUtils.isNotBlank(price))
                service.setPrice(NumberUtils.createBigDecimal(price));
            mapServices.put(conId, service);
        } else {
            service.setName(name);
            service.setShortName(shortName);
            if (StringUtils.isNotBlank(price))
                service.setPrice(NumberUtils.createBigDecimal(price));
            mapServices.remove(conId);
            mapServices.put(conId, service);
        }
    }
    billingService.saveServices(mapServices.values());
    sessionStatus.setComplete();
    return "redirect:/module/billing/service.form";
}

From source file:egovframework.oe1.cms.sim.web.EgovOe1ChangeRequestManageController.java

/**
 *  ?/*from  ww  w  . jav  a  2  s.c o  m*/
 * @param multiRequest ? MultipartHttpServletRequest
 * @param     EgovOe1ChangeRequestVO
 * @return "/cms/sim/gnrl/getChangeRequestList.do"
 * @exception Exception
 */
@RequestMapping("/cms/sim/gnrl/changeRequestRegistData.do")
public String insertChangeRequest(final MultipartHttpServletRequest multiRequest,
        @ModelAttribute("changeRequestvo") EgovOe1ChangeRequestVO changeRequestVo, BindingResult bindingResult,
        ModelMap model, SessionStatus status) throws Exception {

    //Spring Security
    Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
    if (!isAuthenticated) {
        return "/cms/com/EgovLoginUsr"; //? ??
    }

    // Server-Side Validation
    //  (:??   )
    beanValidator.validate(changeRequestVo, bindingResult);
    if (bindingResult.hasErrors()) {

        //
        EgovOe1ComDefaultCodeVO vo = new EgovOe1ComDefaultCodeVO();
        vo.setCodeId("OE1020");
        List srTrgetCode_result = egovCmmUseService.selectCmmCodeDetail(vo);
        model.addAttribute("operJobSeCodeList", srTrgetCode_result);
        //
        EgovOe1ComDefaultCodeVO vo1 = new EgovOe1ComDefaultCodeVO();
        vo1.setCodeId("OE1002");
        List srTrgetCode_result1 = egovCmmUseService.selectCmmCodeDetail(vo1);
        model.addAttribute("changeRequstResnCodeList", srTrgetCode_result1);
        //
        EgovOe1ComDefaultCodeVO vo2 = new EgovOe1ComDefaultCodeVO();
        vo2.setCodeId("OE1005");
        List srTrgetCode_result2 = egovCmmUseService.selectCmmCodeDetail(vo2);
        model.addAttribute("emrgncyRequstAtList", srTrgetCode_result2);

        //??  display
        model.addAttribute("changeRequestvo", changeRequestVo);
        model.addAttribute("searchVO", changeRequestVo);
        return "/cms/sim/EgovChangeRequestRegist";

    } else {
        /** ?  */
        List<EgovOe1FileVO> _result = null;
        String _atchFileId = "";
        final Map<String, MultipartFile> files = multiRequest.getFileMap();
        if (!files.isEmpty()) {
            _result = fileUtil.parseFileInf(files, "", 0, "", "");
            _atchFileId = fileMngService.insertFileInfs(_result); //?? ?? ?? ? ID .
        }
        changeRequestVo.setAtchFileId(_atchFileId);

        // set Login User Id to change Operator Id.
        EgovOe1LoginVO user = (EgovOe1LoginVO) EgovUserDetailsHelper.getAuthenticatedUser();
        changeRequestVo.setChangeRqesterId(user.getMberId());
        changeRequestManageService.insertChangeRequest(changeRequestVo);
        status.setComplete();
        return "forward:/cms/sim/gnrl/getChangeRequestList.do";
    }
}

From source file:egovframework.oe1.cms.cmm.web.EgovOe1FrmwrkInfoManageController.java

/**
 * ? //from   w  w  w  .  j  av a  2s .co  m
 * @param EgovOe1FrmwrkInfoManageVO 
 * @return "/cms/cmm/frmwrkInfoList.do"
 * @exception Exception
 */
@RequestMapping("/cms/cmm/frmwrkInfoUpdate.do")
public String updateFrmwrkInfoManage(@ModelAttribute("frmwrkInfoVO") EgovOe1FrmwrkInfoManageVO frmwrkInfoVo,
        BindingResult bindingResult, ModelMap model, SessionStatus status) throws Exception {

    //Spring Security
    Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
    if (!isAuthenticated) {
        return "/cms/com/EgovLoginUsr"; //? ??
    }

    // Server-Side Validation
    //  (:??  )
    beanValidator.validate(frmwrkInfoVo, bindingResult);
    if (bindingResult.hasErrors()) {

        EgovOe1ComDefaultCodeVO vo = new EgovOe1ComDefaultCodeVO();

        // Presentation Layer
        vo.setCodeId("OE1041");
        List presnatnlyr_result = egovCmmUseService.selectCmmCodeDetail(vo);
        model.addAttribute("presnatnlyr_result", presnatnlyr_result);

        // Persistence Layer
        vo.setCodeId("OE1042");
        List persstnlyr_result = egovCmmUseService.selectCmmCodeDetail(vo);
        model.addAttribute("persstnlyr_result", persstnlyr_result);

        // DBMS 
        vo.setCodeId("OE1043");
        List dbmsKindCode_result = egovCmmUseService.selectCmmCodeDetail(vo);
        model.addAttribute("dbmsKindCode_result", dbmsKindCode_result);

        // WEB 
        vo.setCodeId("OE1044");
        List websKindCode_result = egovCmmUseService.selectCmmCodeDetail(vo);
        model.addAttribute("websKindCode_result", websKindCode_result);

        // WAS 
        vo.setCodeId("OE1045");
        List wasKindCode_result = egovCmmUseService.selectCmmCodeDetail(vo);
        model.addAttribute("wasKindCode_result", wasKindCode_result);

        // OS 
        vo.setCodeId("OE1046");
        List osKindCode_result = egovCmmUseService.selectCmmCodeDetail(vo);
        model.addAttribute("osKindCode_result", osKindCode_result);

        // JDK  
        vo.setCodeId("OE1047");
        List jdkVerCode_result = egovCmmUseService.selectCmmCodeDetail(vo);
        model.addAttribute("jdkVerCode_result", jdkVerCode_result);

        model.addAttribute("frmwrkInfoVO", frmwrkInfoVo);
        model.addAttribute("searchVO", frmwrkInfoVo);
        return "cms/cmm/EgovFrmwrkInfoManageUpdt";
    }

    // set Login User Id to change Operator Id
    EgovOe1LoginVO user = (EgovOe1LoginVO) EgovUserDetailsHelper.getAuthenticatedUser();
    frmwrkInfoVo.setLastUpdusrId(user.getMberId());
    egovOe1FrmwrkInfoManageService.updateFrmwrkInfoManage(frmwrkInfoVo);
    status.setComplete();
    return "forward:/cms/cmm/frmwrkInfoList.do"; //?

}

From source file:csns.web.controller.DepartmentUserControllerS.java

@RequestMapping(value = "/department/{dept}/user/import", method = RequestMethod.POST)
public String importStudents(@ModelAttribute("importer") StudentsImporter importer, @PathVariable String dept,
        @RequestParam("_page") int currentPage, HttpServletRequest request, SessionStatus sessionStatus,
        ModelMap models) {/*from  w  w w . j av a 2  s. c  o  m*/
    if (request.getParameter("_finish") == null) {
        int targetPage = WebUtils.getTargetPage(request, "_target", currentPage);
        if (targetPage == 1 && currentPage < targetPage) {
            for (ImportedUser importedStudent : importer.getImportedStudents()) {
                User user = userDao.getUserByCin(importedStudent.getCin());
                if (user == null)
                    importedStudent.setNewAccount(true);
            }
        }
        return "department/user/import" + targetPage;
    }

    // received _finish, so do the import.

    // need to get a managed instance of department, otherwise
    // user.getCurrentStanding(department) won't work correctly.
    Department department = departmentDao.getDepartment(importer.getDepartment().getId());
    Standing standing = importer.getStanding();
    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.setUsername(cin);
            String password = passwordEncoder.encodePassword(cin, null);
            student.setPassword(password);
            student.setPrimaryEmail(cin + "@localhost");
            student.setTemporary(true);
            student = userDao.saveUser(student);
            logger.info("New account created for student " + student.getName());
        }

        AcademicStanding academicStanding = academicStandingDao.getAcademicStanding(student, department,
                standing);

        if (academicStanding == null) {
            logger.debug("New standing " + standing.getSymbol() + " for student " + student.getName());
            academicStanding = new AcademicStanding(student, department, standing,
                    importedStudent.getQuarter());
        } else {
            logger.debug("Standing updated for student " + student.getName() + ": "
                    + academicStanding.getStanding().getSymbol() + " "
                    + academicStanding.getQuarter().getShortString() + " -> "
                    + importedStudent.getQuarter().getShortString());
            academicStanding.setQuarter(importedStudent.getQuarter());
        }
        academicStanding = academicStandingDao.saveAcademicStanding(academicStanding);

        AcademicStanding currentStanding = student.getCurrentStanding(department);
        if (currentStanding == null || currentStanding.compareTo(academicStanding) < 0) {
            if (currentStanding != null)
                logger.debug("Current standing updated for student " + student.getName() + ": "
                        + currentStanding.getStanding().getSymbol() + " -> "
                        + academicStanding.getStanding().getSymbol());

            student.getCurrentStandings().put(department, academicStanding);
            userDao.saveUser(student);
        }
    }

    sessionStatus.setComplete();

    models.put("backUrl", "/department/" + dept + "/people");
    return "status";
}

From source file:com.sf.springsecurityregistration1.web.controllers.AnnouncementDetailsController.java

/**
 * Method used to verify and persist the new announcement.
 *
 * @param status used to remove announcement from the session
 * @param announcement edited/*  ww w  .ja v  a2  s  . co m*/
 * @param result used to search for errors in form
 * @param request for future code
 * @param errors for future code
 * @return model of next view (search for success, edit for errors)
 */
@RequestMapping(value = "/customer/announcement/create", method = { RequestMethod.POST })
public ModelAndView create(SessionStatus status, @Valid @ModelAttribute Announcements announcement,
        BindingResult result, WebRequest request, Errors errors) {
    String title = changeEncoding(announcement.getTitle(), pageEncoding, dbEncoding);
    announcement.setTitle(title);
    System.out.println("create " + title); // ISO-8859-1
    String header = changeEncoding(announcement.getHeader(), pageEncoding, dbEncoding);
    announcement.setHeader(header);
    String content = changeEncoding(announcement.getContent(), pageEncoding, dbEncoding);
    announcement.setContent(content);
    Announcements registered = null;
    if (!result.hasErrors() && !announcement.getHeader().equals("new")) {
        System.out.println("!result.hasErrors() ");
        registered = createAnnouncement(announcement, result);
    }
    if (registered == null) {
        System.out.println("registered == null");
        //            result.rejectValue("title", "message.title.error");

    }
    if (result.hasErrors()) {
        String titleErrorMessage = result.hasFieldErrors("title")
                ? result.getFieldError("title").getDefaultMessage()
                : "";
        System.out.println("result.hasErrors() " + titleErrorMessage);
        if (!titleErrorMessage.isEmpty()) {
            result.rejectValue("title", "message.title.error",
                    result.getFieldError("title").getDefaultMessage());
        }
        String contentErrorMessage = result.hasFieldErrors("content")
                ? result.getFieldError("content").getDefaultMessage()
                : "";
        if (!contentErrorMessage.isEmpty()) {
            result.rejectValue("content", "message.content.error",
                    result.getFieldError("content").getDefaultMessage());
        }
        ModelAndView model = new ModelAndView("/customer/announcement/create");
        model.addObject("announcements", announcement);
        return model;
        //            return "redirect:/customer/announcement/create";
    } else {
        if (announcement.getHeader().equals("new")) {
            int size = announcement.getNewHeader().length();
            if (size > 25 || 0 == size) {
                result.rejectValue("newHeader", "message.header.error");
                ModelAndView model = new ModelAndView("/customer/announcement/create");
                model.addObject("announcements", announcement);
                return model;
            }
            announcement.setHeader(changeEncoding(announcement.getNewHeader(), pageEncoding, dbEncoding));
            createAnnouncement(announcement, result);
        }
        ModelAndView model = new ModelAndView("/customer/announcement/search");
        //            model.addObject("announcements", announcement);
        model.addObject("announcementSearchCriteria", new AnnouncementSearchCriteria());
        model.addObject("categories", this.announcementService.findAllCategories());
        model.addObject("authors", this.announcementService.findAllAuthors());
        model.addObject("announcementsList",
                this.announcementService.findAnnouncements(new AnnouncementSearchCriteria()));
        status.setComplete();
        return model;
        //            return "redirect:/customer/announcement/search";
    }
}

From source file:cdr.forms.FormController.java

@RequestMapping(value = "/supplemental", method = { RequestMethod.POST, RequestMethod.GET })
public String collectSupplementalObjects(@Valid @ModelAttribute("deposit") Deposit deposit,
        BindingResult errors, SessionStatus sessionStatus,
        @RequestParam(value = "added", required = false) DepositFile[] addedDepositFiles,
        @RequestParam(value = "deposit", required = false) String submitDepositAction,
        HttpServletRequest request, HttpServletResponse response) {

    request.setAttribute("formattedMaxUploadSize", (getMaxUploadSize() / 1000000) + "MB");
    request.setAttribute("maxUploadSize", getMaxUploadSize());

    // Validate request and ensure character encoding is set

    this.getAuthorizationHandler().checkPermission(deposit.getFormId(), deposit.getForm(), request);

    try {//from  ww w  . j ava 2s.co m
        request.setCharacterEncoding("UTF-8");
    } catch (UnsupportedEncodingException e) {
        LOG.error("Failed to set character encoding", e);
    }

    // Update supplemental objects

    Iterator<SupplementalObject> iterator = deposit.getSupplementalObjects().iterator();

    while (iterator.hasNext()) {
        SupplementalObject file = iterator.next();
        if (file == null)
            iterator.remove();
    }

    if (addedDepositFiles != null) {
        for (DepositFile depositFile : addedDepositFiles) {
            if (depositFile != null) {

                depositFile.setExternal(true);

                SupplementalObject object = new SupplementalObject();
                object.setDepositFile(depositFile);

                deposit.getSupplementalObjects().add(object);

            }
        }
    }

    Collections.sort(deposit.getSupplementalObjects(), new Comparator<SupplementalObject>() {
        public int compare(SupplementalObject sf1, SupplementalObject sf2) {
            return sf1.getDepositFile().getFilename().compareTo(sf2.getDepositFile().getFilename());
        }
    });

    // Check the deposit's files for virus signatures

    IdentityHashMap<DepositFile, String> signatures = new IdentityHashMap<DepositFile, String>();

    for (DepositFile depositFile : deposit.getAllFiles())
        scanDepositFile(depositFile, signatures);

    // Validate supplemental objects

    if (submitDepositAction != null) {

        Validator validator = new SupplementalObjectValidator();

        int i = 0;

        for (SupplementalObject object : deposit.getSupplementalObjects()) {
            errors.pushNestedPath("supplementalObjects[" + i + "]");
            validator.validate(object, errors);
            errors.popNestedPath();

            i++;
        }

    }

    // Handle viruses, validation errors, and the deposit not having been finally submitted

    request.setAttribute("formId", deposit.getFormId());
    request.setAttribute("administratorEmail", getAdministratorEmail());

    if (signatures.size() > 0) {
        request.setAttribute("signatures", signatures);
        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);

        deposit.deleteAllFiles(true);
        sessionStatus.setComplete();

        return "virus";
    }

    if (errors.hasErrors()) {
        return "supplemental";
    }

    if (submitDepositAction == null) {
        return "supplemental";
    }

    // Try to deposit

    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);

        deposit.deleteAllFiles(true);
        sessionStatus.setComplete();

        return "failed";

    } else {

        if (getNotificationHandler() != null) {
            getNotificationHandler().notifyDeposit(deposit, result);
        }

        deposit.deleteAllFiles(false);
        sessionStatus.setComplete();

        return "success";

    }

}

From source file:egovframework.oe1.cms.sim.web.EgovOe1ChangeRequestManageController.java

/**
 *  //from ww  w .j av a2s.com
 * @param multiRequest ? MultipartHttpServletRequest
 * @param    EgovOe1ChangeRequestVO
 * @return "/cms/sim/gnrl/getChangeRequestList.do"
 * @exception Exception
 */
@RequestMapping("/cms/sim/gnrl/changeRequestUpdate.do")
public String updateChangeRequest(final MultipartHttpServletRequest multiRequest,
        @ModelAttribute("changeRequestvo") EgovOe1ChangeRequestVO changeRequestVo, BindingResult bindingResult,
        ModelMap model, SessionStatus status) throws Exception {

    //Spring Security
    Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
    if (!isAuthenticated) {
        return "/cms/com/EgovLoginUsr"; //? ??
    }

    // Server-Side Validation
    //  (:??   )
    beanValidator.validate(changeRequestVo, bindingResult);

    if (bindingResult.hasErrors()) {
        //
        EgovOe1ComDefaultCodeVO vo = new EgovOe1ComDefaultCodeVO();
        vo.setCodeId("OE1020");
        List srTrgetCode_result = egovCmmUseService.selectCmmCodeDetail(vo);
        model.addAttribute("operJobSeCodeList", srTrgetCode_result);
        //
        EgovOe1ComDefaultCodeVO vo1 = new EgovOe1ComDefaultCodeVO();
        vo1.setCodeId("OE1002");
        List srTrgetCode_result1 = egovCmmUseService.selectCmmCodeDetail(vo1);
        model.addAttribute("changeRequstResnCodeList", srTrgetCode_result1);
        //
        EgovOe1ComDefaultCodeVO vo2 = new EgovOe1ComDefaultCodeVO();
        vo2.setCodeId("OE1005");
        List srTrgetCode_result2 = egovCmmUseService.selectCmmCodeDetail(vo2);
        model.addAttribute("emrgncyRequstAtList", srTrgetCode_result2);

        //?  display
        model.addAttribute("changeRequestvo", changeRequestVo);
        model.addAttribute("searchVO", changeRequestVo);
        return "/cms/sim/EgovChangeRequestUpdt";

    } else {
        String _atchFileId = changeRequestVo.getAtchFileId();//  ? ? ? ? ? ID .
        final Map<String, MultipartFile> files = multiRequest.getFileMap();
        if (!files.isEmpty()) {
            if ("".equals(_atchFileId) || _atchFileId == null) {
                List<EgovOe1FileVO> _result = fileUtil.parseFileInf(files, "", 0, _atchFileId, "");
                _atchFileId = fileMngService.insertFileInfs(_result); // ? ? ID .
                changeRequestVo.setAtchFileId(_atchFileId); //   ? ? ?? ? ID  .
            } else {
                EgovOe1FileVO fvo = new EgovOe1FileVO();
                fvo.setAtchFileId(_atchFileId); //  ? ? ??  VO?  ? ID .
                int _cnt = fileMngService.getMaxFileSN(fvo); //  ? ID? ?  ? ? ??.
                List<EgovOe1FileVO> _result = fileUtil.parseFileInf(files, "", _cnt, _atchFileId, "");
                fileMngService.updateFileInfs(_result);
            }
        }

        // set Login User Id to change Operator Id.
        EgovOe1LoginVO user = (EgovOe1LoginVO) EgovUserDetailsHelper.getAuthenticatedUser();
        changeRequestVo.setLastUpdusrId(user.getMberId());
        changeRequestManageService.updateChangeRequest(changeRequestVo);
        status.setComplete();
        return "forward:/cms/sim/gnrl/getChangeRequestList.do";
    }
}

From source file:egovframework.oe1.cms.mrm.web.EgovOe1ResveMtgController.java

/**
* ? ./*from  ww  w. j  a  v  a2  s . c om*/
* @param egovOe1ResveMtgVO    -    VO
* @param status
* @return "forward:/cms/mrm/selectResveMtgList.do"
* @exception Exception
*/
@RequestMapping("/cms/mrm/updateResveMtgOK.do")
public String updateResveMtgOK(final MultipartHttpServletRequest multiRequest,
        @RequestParam("selectedId") String selectedId,
        @ModelAttribute("egovOe1ResveMtgVO") EgovOe1ResveMtgVO egovOe1ResveMtgVO, BindingResult bindingResult,
        Model model, SessionStatus status) throws Exception {

    log.debug(this.getClass().getName() + " ==> ?  ");

    Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
    if (!isAuthenticated) {
        return "/cms/com/EgovLoginUsr"; //? ??
    }

    //?   ?   ??.
    model.addAttribute("searchMode", egovOe1ResveMtgVO);

    beanValidator.validate(egovOe1ResveMtgVO, bindingResult);
    if (bindingResult.hasErrors()) {
        model.addAttribute("egovOe1ResveMtgVO", egovOe1ResveMtgVO);
        return "/cms/mrm/EgovResveMtgUpdt";
    }

    //
    EgovOe1LoginVO user = (EgovOe1LoginVO) EgovUserDetailsHelper.getAuthenticatedUser();

    String atchFileId = egovOe1ResveMtgVO.getAtchFileId();

    egovOe1ResveMtgVO.setMtgRoomResId(selectedId);

    final Map<String, MultipartFile> files = multiRequest.getFileMap();
    if (!files.isEmpty()) {
        if ("".equals(atchFileId)) {
            List<EgovOe1FileVO> result = fileUtil.parseFileInf(files, "MTR_", 0, atchFileId, "");
            atchFileId = fileMngService.insertFileInfs(result);
            egovOe1ResveMtgVO.setAtchFileId(atchFileId);
        } else {
            EgovOe1FileVO fvo = new EgovOe1FileVO();
            fvo.setAtchFileId(atchFileId);
            int cnt = fileMngService.getMaxFileSN(fvo);
            List<EgovOe1FileVO> _result = fileUtil.parseFileInf(files, "MTR_", cnt, atchFileId, "");
            fileMngService.updateFileInfs(_result);
        }
    }
    egovOe1ResveMtgVO.setAtchFileId(atchFileId); //? ?? ID  VO? .
    egovOe1ResveMtgVO.setRegisterId(user.getMberId()); //??? ID VO? .

    String shh = egovOe1ResveMtgVO.getStartHh();
    String smm = egovOe1ResveMtgVO.getStartMm();
    String fhh = egovOe1ResveMtgVO.getFinishHh();
    String fmm = egovOe1ResveMtgVO.getFinishMm();

    egovOe1ResveMtgVO.setMtgStartDate(egovOe1ResveMtgVO.getInsRepeatDate()); //??? 
    egovOe1ResveMtgVO.setMtgEndDate(egovOe1ResveMtgVO.getInsRepeatDate()); //???               
    egovOe1ResveMtgVO.setMtgBeginTime(shh + smm); //?
    egovOe1ResveMtgVO.setMtgEndTime(fhh + fmm); //?
    egovOe1ResveMtgService.updateResveMtg(egovOe1ResveMtgVO); //??? .

    egovOe1ResveMtgService.deleteMtGattenInfo(egovOe1ResveMtgVO); //???  . 

    StringTokenizer st = new StringTokenizer(egovOe1ResveMtgVO.getAttendantId(), "|"); //????
    int n = st.countTokens();
    for (int j = 0; j < n; j++) {
        String token = st.nextToken();
        egovOe1ResveMtgVO.setMtgAttenId(token);
        egovOe1ResveMtgService.insertMtGattenInfo(egovOe1ResveMtgVO);
    }

    status.setComplete();

    if (status.isComplete()) {
        model.addAttribute("resultMsg", "?  ");
    } else {
        model.addAttribute("resultMsg", "?  ");
    }

    return "forward:/cms/mrm/selectResveMtgList.do";
}

From source file:org.motechproject.server.omod.web.controller.PregnancyController.java

@RequestMapping(method = RequestMethod.POST)
public String submitForm(@ModelAttribute("pregnancy") WebPatient pregnancy, Errors errors, ModelMap model,
        SessionStatus status) {

    log.debug("Register New Pregnancy on Existing Patient");

    Patient patient = null;// ww  w.  j a v a2 s  .  c  o  m
    if (pregnancy.getId() != null) {
        patient = registrarBean.getPatientById(pregnancy.getId());
        if (patient == null) {
            errors.reject("motechmodule.id.notexist");
        }
    } else {
        errors.reject("motechmodule.id.required");
    }

    if (!Gender.FEMALE.equals(pregnancy.getSex())) {
        errors.reject("motechmodule.sex.female.required");
    }
    if (registrarBean.getActivePregnancy(pregnancy.getId()) != null) {
        errors.reject("motechmodule.Pregnancy.active");
    }

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "dueDate", "motechmodule.dueDate.required");
    if (pregnancy.getDueDate() != null) {
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.MONTH, 9);
        if (pregnancy.getDueDate().after(calendar.getTime())) {
            errors.rejectValue("dueDate", "motechmodule.dueDate.overninemonths");
        }
    }
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "dueDateConfirmed",
            "motechmodule.dueDateConfirmed.required");

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "enroll", "motechmodule.enroll.required");

    if (Boolean.TRUE.equals(pregnancy.getEnroll())) {
        if (!Boolean.TRUE.equals(pregnancy.getConsent())) {
            errors.rejectValue("consent", "motechmodule.consent.required");
        }
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "phoneType", "motechmodule.phoneType.required");
        if (pregnancy.getPhoneType() == ContactNumberType.PERSONAL
                || pregnancy.getPhoneType() == ContactNumberType.HOUSEHOLD) {
            ValidationUtils.rejectIfEmptyOrWhitespace(errors, "phoneNumber",
                    "motechmodule.phoneNumber.required");
        }
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "mediaType", "motechmodule.mediaType.required");
        if (pregnancy.getPhoneType() == ContactNumberType.PUBLIC && pregnancy.getMediaType() != null
                && pregnancy.getMediaType() != MediaType.VOICE) {
            errors.rejectValue("mediaType", "motechmodule.mediaType.voice");
        }
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "language", "motechmodule.language.required");
        if (pregnancy.getMediaType() == MediaType.TEXT && pregnancy.getLanguage() != null
                && !pregnancy.getLanguage().equals("en")) {
            errors.rejectValue("language", "motechmodule.language.english");
        }
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "interestReason",
                "motechmodule.interestReason.required");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "howLearned", "motechmodule.howLearned.required");
    }
    if (pregnancy.getPhoneNumber() != null
            && !pregnancy.getPhoneNumber().matches(MotechConstants.PHONE_REGEX_PATTERN)) {
        errors.rejectValue("phoneNumber", "motechmodule.phoneNumber.invalid");
    }

    validateTextLength(errors, "phoneNumber", pregnancy.getPhoneNumber(),
            MotechConstants.MAX_STRING_LENGTH_OPENMRS);

    if (!errors.hasErrors()) {
        registrarBean.registerPregnancy(patient, pregnancy.getDueDate(), pregnancy.getDueDateConfirmed(),
                pregnancy.getEnroll(), pregnancy.getConsent(), pregnancy.getPhoneNumber(),
                pregnancy.getPhoneType(), pregnancy.getMediaType(), pregnancy.getLanguage(),
                pregnancy.getDayOfWeek(), pregnancy.getTimeOfDay(), pregnancy.getInterestReason(),
                pregnancy.getHowLearned());
        model.addAttribute("successMsg", "motechmodule.Pregnancy.register.success");

        status.setComplete();

        return "redirect:/module/motechmodule/viewdata.form";
    }

    return "/module/motechmodule/pregnancy";
}