Search in sources :

Example 81 with RequestMapping

use of org.springframework.web.bind.annotation.RequestMapping 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 82 with RequestMapping

use of org.springframework.web.bind.annotation.RequestMapping 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 83 with RequestMapping

use of org.springframework.web.bind.annotation.RequestMapping 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 84 with RequestMapping

use of org.springframework.web.bind.annotation.RequestMapping 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)

Example 85 with RequestMapping

use of org.springframework.web.bind.annotation.RequestMapping in project head by mifos.

the class PreviewHolidayController 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") HolidayFormBean formBean, BindingResult result, SessionStatus status) {
    String viewName = REDIRECT_TO_ADMIN_SCREEN;
    ModelAndView modelAndView = new ModelAndView();
    if (StringUtils.isNotBlank(edit)) {
        viewName = "defineNewHoliday";
        modelAndView.setViewName(viewName);
        modelAndView.addObject("formBean", formBean);
    } else if (StringUtils.isNotBlank(cancel)) {
        modelAndView.setViewName("redirect:viewHolidays.ftl");
        status.setComplete();
    } else if (result.hasErrors()) {
        modelAndView.setViewName("previewHoliday");
    } else {
        HolidayDetails holidayDetail = holidayAssembler.translateHolidayFormBeanToDto(formBean);
        List<Short> branchIds = holidayAssembler.convertToIds(formBean.getSelectedOfficeIds());
        this.holidayServiceFacade.createHoliday(holidayDetail, branchIds);
        viewName = REDIRECT_TO_ADMIN_SCREEN;
        modelAndView.setViewName(viewName);
        status.setComplete();
    }
    return modelAndView;
}
Also used : HolidayDetails(org.mifos.dto.domain.HolidayDetails) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1964 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)459 ModelAndView (org.springframework.web.servlet.ModelAndView)413 ApiOperation (io.swagger.annotations.ApiOperation)305 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)234 ArrayList (java.util.ArrayList)197 HashMap (java.util.HashMap)155 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)124 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)124 IOException (java.io.IOException)97 ResponseEntity (org.springframework.http.ResponseEntity)92 Date (java.util.Date)83 Aggregation (org.springframework.data.mongodb.core.aggregation.Aggregation)80 DBObject (com.mongodb.DBObject)71 BasicDBObject (com.mongodb.BasicDBObject)67 InputStream (java.io.InputStream)66 Aggregation.newAggregation (org.springframework.data.mongodb.core.aggregation.Aggregation.newAggregation)64 HttpServletResponse (javax.servlet.http.HttpServletResponse)59 User (org.hisp.dhis.user.User)59 List (java.util.List)53