Search in sources :

Example 11 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project head by mifos.

the class NewFundPreviewController method processFormSubmit.

@RequestMapping(method = RequestMethod.POST)
public ModelAndView processFormSubmit(@RequestParam(value = EDIT_PARAM, required = false) String edit, @RequestParam(value = CANCEL_PARAM, required = false) String cancel, @ModelAttribute("formBean") FundFormBean formBean, BindingResult result, SessionStatus status) {
    ModelAndView mav = new ModelAndView(REDIRECT_TO_ADMIN_SCREEN);
    if (StringUtils.isNotBlank(edit)) {
        mav = new ModelAndView("editFunds");
        mav.addObject("formBean", formBean);
        mav.addObject("previewView", "newFundPreview");
    } else if (StringUtils.isNotBlank(cancel)) {
        mav = new ModelAndView(REDIRECT_TO_VIEW_FUNDS);
        status.setComplete();
    } else if (result.hasErrors()) {
        mav = new ModelAndView("newFundPreview");
    } else {
        FundCodeDto codeDto = new FundCodeDto();
        codeDto.setId(formBean.getCodeId());
        codeDto.setValue(formBean.getCodeValue());
        FundDto fundDto = new FundDto();
        fundDto.setCode(codeDto);
        fundDto.setId(formBean.getId());
        fundDto.setName(formBean.getName());
        try {
            this.fundServiceFacade.createFund(fundDto);
            status.setComplete();
        } catch (BusinessRuleException e) {
            ObjectError error = new ObjectError("formBean", new String[] { e.getMessageKey() }, new Object[] {}, "default: ");
            result.addError(error);
            mav.setViewName("newFundPreview");
            mav.addObject("formBean", formBean);
        }
    }
    return mav;
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) ObjectError(org.springframework.validation.ObjectError) ModelAndView(org.springframework.web.servlet.ModelAndView) FundDto(org.mifos.accounts.fund.servicefacade.FundDto) FundCodeDto(org.mifos.accounts.fund.servicefacade.FundCodeDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project head by mifos.

the class NewOfficePreviewController method processSubmit.

@RequestMapping(method = RequestMethod.POST)
public ModelAndView processSubmit(@RequestParam(value = CANCEL_PARAM, required = false) String cancel, @RequestParam(value = EDIT_PARAM, required = false) String edit, @ModelAttribute("officeFormBean") OfficeFormBean formBean, BindingResult result, SessionStatus status) {
    ModelAndView modelAndView = new ModelAndView(REDIRECT_TO_ADMIN_SCREEN);
    if (StringUtils.isNotBlank(cancel)) {
        status.setComplete();
    } else if (result.hasErrors()) {
        modelAndView = new ModelAndView("previewOfficeDetails");
        modelAndView.addObject("officeFormBean", formBean);
        modelAndView.addObject("showError", "true");
    } else if (StringUtils.isNotBlank(edit)) {
        EditOfficeInformationController editOfficeInformationController = new EditOfficeInformationController(officeServiceFacade);
        modelAndView = new ModelAndView("defineNewOffice");
        modelAndView.addObject("showError", "false");
        if (!formBean.getLevelId().equals("1")) {
            modelAndView.addObject("parentOffices", editOfficeInformationController.getParentDetails(formBean.getLevelId()));
        }
        modelAndView.addObject("officeTypes", editOfficeInformationController.getOfficeTypes(formBean.getLevelId()));
        modelAndView.addObject("officeFormBean", formBean);
        modelAndView.addObject("view", "enable");
    }
    /*Code for update office in else -vishnu*/
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 13 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project head by mifos.

the class NewPenaltyPreviewController method processFormSubmit.

@RequestMapping(method = RequestMethod.POST)
public ModelAndView processFormSubmit(@RequestParam(value = EDIT_PARAM, required = false) String edit, @RequestParam(value = CANCEL_PARAM, required = false) String cancel, @ModelAttribute("formBean") PenaltyFormBean formBean, BindingResult result, SessionStatus status) {
    ModelAndView modelAndView = new ModelAndView(REDIRECT_TO_ADMIN_SCREEN);
    AccountingConfigurationDto configurationDto = this.configurationServiceFacade.getAccountingConfiguration();
    modelAndView.addObject("GLCodeMode", configurationDto.getGlCodeMode());
    if (StringUtils.isNotBlank(edit)) {
        modelAndView.setViewName("defineNewPenalty");
        modelAndView.addObject("formBean", formBean);
        modelAndView.addObject("param", this.penaltyServiceFacade.getPenaltyParameters());
    } else if (StringUtils.isNotBlank(cancel)) {
        modelAndView.setViewName(REDIRECT_TO_VIEW_PENALTIES);
        status.setComplete();
    } else if (result.hasErrors()) {
        modelAndView.setViewName("newPenaltyPreview");
    } else {
        boolean ratePenalty = StringUtils.isBlank(formBean.getAmount());
        Short currencyId = null;
        Double rate = null;
        Short penaltyFormula = null;
        Short periodId = 3;
        Integer duration = null;
        if (ratePenalty) {
            rate = Double.valueOf(formBean.getRate());
            penaltyFormula = Short.valueOf(formBean.getFormulaId());
        }
        if (StringUtils.isNotBlank(formBean.getDuration())) {
            duration = Integer.valueOf(formBean.getDuration());
        }
        if (StringUtils.isNotBlank(formBean.getCurrencyId())) {
            currencyId = Short.valueOf(formBean.getCurrencyId());
        }
        if (StringUtils.isNotBlank(formBean.getPeriodTypeId())) {
            periodId = Short.valueOf(formBean.getPeriodTypeId());
        }
        PenaltyFormDto dto = new PenaltyFormDto();
        dto.setCategoryType(Short.valueOf(formBean.getCategoryTypeId()));
        dto.setPenaltyPeriod(periodId);
        dto.setPenaltyFrequency(Short.valueOf(formBean.getFrequencyId()));
        dto.setGlCode(Short.valueOf(formBean.getGlCodeId()));
        dto.setPenaltyFormula(penaltyFormula);
        dto.setPenaltyName(formBean.getName());
        dto.setRatePenalty(ratePenalty);
        dto.setCurrencyId(currencyId);
        dto.setRate(rate);
        dto.setAmount(formBean.getAmount());
        dto.setDuration(duration);
        dto.setMin(Double.valueOf(formBean.getMin()));
        dto.setMax(Double.valueOf(formBean.getMax()));
        this.penaltyServiceFacade.createPenalty(dto);
        status.setComplete();
    }
    return modelAndView;
}
Also used : PenaltyFormDto(org.mifos.dto.domain.PenaltyFormDto) AccountingConfigurationDto(org.mifos.config.servicefacade.dto.AccountingConfigurationDto) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 14 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project head by mifos.

the class PenaltyController method showAllPenalties.

@RequestMapping(method = RequestMethod.GET)
public ModelAndView showAllPenalties() {
    ModelAndView modelAndView = new ModelAndView("viewPenalties");
    modelAndView.addObject("savingPenalties", penaltyServiceFacade.getSavingPenalties());
    modelAndView.addObject("loanPenalties", penaltyServiceFacade.getLoanPenalties());
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 15 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project head by mifos.

the class PreviewCoaController method processFormSubmit.

@RequestMapping(method = RequestMethod.POST)
public ModelAndView processFormSubmit(@RequestParam(value = EDIT_PARAM, required = false) String edit, @RequestParam(value = CANCEL_PARAM, required = false) String cancel, @ModelAttribute("formBean") CoaFormBean formBean, BindingResult result, SessionStatus status) {
    String viewName = REDIRECT_TO_COA_ADMIN_SCREEN;
    ModelAndView modelAndView = new ModelAndView();
    if (StringUtils.isNotBlank(edit)) {
        viewName = DEFINE_NEW_COA;
        modelAndView.setViewName(viewName);
        modelAndView.addObject("formBean", formBean);
    } else if (StringUtils.isNotBlank(cancel)) {
        modelAndView.setViewName(REDIRECT_TO_COA_ADMIN_SCREEN);
        status.setComplete();
    } else if (result.hasErrors()) {
        modelAndView.setViewName(PREVIEW_COA);
    } else {
        try {
            CoaDto coaDto = new CoaDto();
            coaDto.setAccountName(formBean.getCoaName());
            coaDto.setGlCodeString(formBean.getGlCode());
            coaDto.setParentId(formBean.getParentId());
            coaServiceFacade.create(coaDto);
            viewName = REDIRECT_TO_COA_ADMIN_SCREEN;
            modelAndView.setViewName(viewName);
            status.setComplete();
        } catch (BusinessRuleException e) {
            ObjectError error = new ObjectError("formBean", new String[] { e.getMessageKey() }, new Object[] {}, "default: ");
            result.addError(error);
            modelAndView.setViewName(PREVIEW_COA);
            modelAndView.addObject("formBean", formBean);
        }
    }
    return modelAndView;
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) ObjectError(org.springframework.validation.ObjectError) CoaDto(org.mifos.application.admin.servicefacade.CoaDto) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ModelAndView (org.springframework.web.servlet.ModelAndView)1573 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)668 Test (org.junit.jupiter.api.Test)195 Test (org.junit.Test)188 HashMap (java.util.HashMap)165 ArrayList (java.util.ArrayList)139 RedirectView (org.springframework.web.servlet.view.RedirectView)90 Map (java.util.Map)84 List (java.util.List)69 IOException (java.io.IOException)60 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)60 Date (java.util.Date)57 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)50 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)49 MockHttpServletResponse (org.springframework.web.testfixture.servlet.MockHttpServletResponse)49 MockHttpServletRequest (org.springframework.web.testfixture.servlet.MockHttpServletRequest)47 GetMapping (org.springframework.web.bind.annotation.GetMapping)45 HandlerMethod (org.springframework.web.method.HandlerMethod)45 IPerson (org.apereo.portal.security.IPerson)43 JSONView (com.intel.mountwilson.util.JSONView)34