Search in sources :

Example 56 with ModelAndView

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

the class PentahoReportingController method executeReport.

@RequestMapping(value = "/execPentahoReport.ftl", method = RequestMethod.POST)
public ModelAndView executeReport(final HttpServletRequest request, HttpServletResponse response, @RequestParam(value = CANCEL_PARAM, required = false) String cancel, @Valid @ModelAttribute("pentahoReportFormBean") PentahoReportFormBean pentahoReportFormBean, BindingResult bindingResult) throws IOException {
    if (!this.pentahoReportsService.checkAccessToReport(pentahoReportFormBean.getReportId())) {
        throw new AccessDeniedException("Access denied");
    }
    ModelAndView mav = null;
    Integer reportId = pentahoReportFormBean.getReportId();
    if (StringUtils.isNotBlank(cancel)) {
        mav = new ModelAndView("redirect:" + REPORTS_MAIN_URL);
    } else if (bindingResult.hasErrors()) {
        mav = new ModelAndView("viewPentahoReport");
        initFormBean(pentahoReportFormBean, reportId, request);
    } else {
        Integer outputType = Integer.parseInt(pentahoReportFormBean.getOutputType());
        Map<String, AbstractPentahoParameter> reportParams = pentahoReportFormBean.getAllParameteres();
        PentahoReport report = this.pentahoReportsService.getReport(reportId, outputType, reportParams);
        if (report.isInError()) {
            for (PentahoValidationError error : report.getErrors()) {
                addErrorToBindingResult(error, bindingResult);
            }
            mav = new ModelAndView("viewPentahoReport");
            initFormBean(pentahoReportFormBean, reportId, request);
        } else {
            if (report.getContentType().equalsIgnoreCase("text/html")) {
                HashMap<String, String> modelMap = new HashMap<String, String>();
                modelMap.put("reportContent", new String(report.getContent()));
                mav = new ModelAndView("viewHtmlReport", modelMap);
            } else {
                response.setHeader("Content-Disposition", "attachment; filename=\"" + report.getFilename() + "\"");
                response.setContentType(report.getContentType());
                response.setContentLength(report.getContentSize());
                response.getOutputStream().write(report.getContent());
            }
        }
    }
    return mav;
}
Also used : PentahoReport(org.mifos.reports.pentaho.PentahoReport) AccessDeniedException(org.springframework.security.access.AccessDeniedException) HashMap(java.util.HashMap) ModelAndView(org.springframework.web.servlet.ModelAndView) PentahoValidationError(org.mifos.reports.pentaho.PentahoValidationError) HashMap(java.util.HashMap) Map(java.util.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 57 with ModelAndView

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

the class ViewEditLoanProductController method showLoanProductDetails.

@RequestMapping(method = RequestMethod.GET)
public ModelAndView showLoanProductDetails(@RequestParam("productId") Integer productId) {
    LoanProductRequest loanProductDetails = adminServiceFacade.retrieveLoanProductDetails(productId);
    ModelAndView mav = new ModelAndView("viewEditLoanProduct");
    mav.addObject("loanProductDetails", loanProductDetails);
    return mav;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) LoanProductRequest(org.mifos.dto.domain.LoanProductRequest) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 58 with ModelAndView

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

the class ViewEditSavingsProductController method showSavingProductDetails.

@RequestMapping(method = RequestMethod.GET)
public ModelAndView showSavingProductDetails(@RequestParam("productId") Integer productId) {
    ModelAndView modelAndView = new ModelAndView("viewEditSavingsProduct");
    AccountingConfigurationDto configurationDto = this.configurationServiceFacade.getAccountingConfiguration();
    modelAndView.addObject("GLCodeMode", configurationDto.getGlCodeMode());
    modelAndView.addObject("savingsProductDetails", adminServiceFacade.retrieveSavingsProductDetails(productId));
    return modelAndView;
}
Also used : AccountingConfigurationDto(org.mifos.config.servicefacade.dto.AccountingConfigurationDto) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 59 with ModelAndView

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

the class ViewImportedTransactionFileController method viewImportedTransactions.

@RequestMapping("/viewImportedTransactions.ftl")
public ModelAndView viewImportedTransactions(@RequestParam(required = false) String fileName) {
    ModelAndView modelAndView = new ModelAndView();
    modelAndView.setViewName("viewImportedTransactions");
    List<ImportedFileDto> importedFiles = this.importTransactionsServiceFacade.getImportedFiles();
    List<ImportedFileDto> supportedFiles = new ArrayList<ImportedFileDto>();
    for (ImportedFileDto importedFile : importedFiles) {
        if (importedFile.getUndoable()) {
            supportedFiles.add(importedFile);
        }
    }
    modelAndView.addObject("importedFiles", supportedFiles);
    return modelAndView;
}
Also used : ImportedFileDto(org.mifos.dto.screen.ImportedFileDto) ModelAndView(org.springframework.web.servlet.ModelAndView) ArrayList(java.util.ArrayList) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 60 with ModelAndView

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

the class ViewLoanAccountDetailsController method showLoanAccountDetails.

@RequestMapping(value = "/viewLoanAccountDetails", method = RequestMethod.GET)
public ModelAndView showLoanAccountDetails(HttpServletRequest request, HttpServletResponse response) throws ApplicationException {
    ModelAndView modelAndView = new ModelAndView();
    sitePreferenceHelper.resolveSiteType(modelAndView, "viewLoanAccountDetails", request);
    modelAndView.addObject("include_page", new IncludePage(request, response));
    String globalAccountNum = request.getParameter("globalAccountNum");
    LoanInformationDto loanInformationDto = loanAccountServiceFacade.retrieveLoanInformation(globalAccountNum);
    modelAndView.addObject("loanInformationDto", loanInformationDto);
    boolean containsQGForCloseLoan = questionnaireServiceFacade.getQuestionGroupInstances(loanInformationDto.getAccountId(), "Close", "Loan").size() > 0;
    modelAndView.addObject("containsQGForCloseLoan", containsQGForCloseLoan);
    // for mifostabletag
    List<LoanActivityDto> activities = loanInformationDto.getRecentAccountActivity();
    for (LoanActivityDto activity : activities) {
        activity.setUserPrefferedDate(DateFormatUtils.format(activity.getActionDate(), "dd/MM/yyyy", personnelServiceFacade.getUserPreferredLocale()));
    }
    request.getSession().setAttribute("recentAccountActivities", loanInformationDto.getRecentAccountActivity());
    request.getSession().setAttribute("guarantyInformation", loanAccountServiceFacade.handleGuaranties(loanInformationDto));
    //for GLIM
    if (configurationServiceFacade.isGlimEnabled() && loanInformationDto.isGroup()) {
        List<LoanAccountDetailsDto> loanAccountsDetails = loanAccountServiceFacade.retrieveLoanAccountDetails(loanInformationDto);
        addEmptyBuisnessActivities(loanAccountsDetails);
        modelAndView.addObject("loanAccountDetailsView");
        request.setAttribute("loanAccountDetailsView", loanAccountsDetails);
    }
    modelAndView.addObject("backPageUrl", UrlHelper.constructCurrentPageUrl(request));
    request.getSession().setAttribute("backPageUrl", request.getAttribute("currentPageUrl"));
    loanAccountServiceFacade.putLoanBusinessKeyInSession(globalAccountNum, request);
    return modelAndView;
}
Also used : LoanActivityDto(org.mifos.dto.domain.LoanActivityDto) ModelAndView(org.springframework.web.servlet.ModelAndView) IncludePage(freemarker.ext.servlet.IncludePage) LoanInformationDto(org.mifos.dto.screen.LoanInformationDto) LoanAccountDetailsDto(org.mifos.dto.domain.LoanAccountDetailsDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ModelAndView (org.springframework.web.servlet.ModelAndView)1576 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)669 Test (org.junit.jupiter.api.Test)195 Test (org.junit.Test)188 HashMap (java.util.HashMap)166 ArrayList (java.util.ArrayList)140 RedirectView (org.springframework.web.servlet.view.RedirectView)90 Map (java.util.Map)85 List (java.util.List)69 IOException (java.io.IOException)62 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 ExceptionHandler (org.springframework.web.bind.annotation.ExceptionHandler)35