/** Builds URL for the report dump url. */ private String buildReportExportForwardURL( ReportRunnerForm reportRunnerForm, ActionMapping mapping, String documentReportMode) { Map<String, String> parameters = new HashMap<String, String>(); parameters.put( KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, reportRunnerForm.getChartOfAccountsCode()); parameters.put(KFSPropertyConstants.ACCOUNT_NUMBER, reportRunnerForm.getAccountNumber()); parameters.put(KFSPropertyConstants.SUB_ACCOUNT_NUMBER, reportRunnerForm.getSubAccountNumber()); parameters.put(BCConstants.Report.REPORT_MODE, documentReportMode); parameters.put(BCConstants.IS_ORG_REPORT_REQUEST_PARAMETER, "false"); return BudgetUrlUtil.buildBudgetUrl( mapping, reportRunnerForm, BCConstants.REPORT_EXPORT_ACTION, parameters); }
/** * Runs the reports or dump selected by the user using the BudgetConstructionDocumentReportMode to * help determine the various objects needed to actually build the report data and render the * report. * * @param mapping * @param form * @param request * @param response * @return * @throws Exception */ public ActionForward performReportDump( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ReportRunnerForm reportRunnerForm = (ReportRunnerForm) form; String principalName = GlobalVariables.getUserSession().getPerson().getPrincipalId(); int selectIndex = this.getSelectedLine(request); String reportModeName = reportRunnerForm .getBudgetConstructionDocumentReportModes() .get(selectIndex) .getReportModeName(); Collection reportSet = new ArrayList(); String jasperFileName = null; ByteArrayOutputStream baos = new ByteArrayOutputStream(); switch (selectIndex) { case 0: { jasperFileName = "BudgetAccountObjectDetail"; SpringContext.getBean(BudgetConstructionDocumentAccountObjectDetailReportService.class) .updateDocumentAccountObjectDetailReportTable( principalName, reportRunnerForm.getDocumentNumber(), reportRunnerForm.getUniversityFiscalYear(), reportRunnerForm.getChartOfAccountsCode(), reportRunnerForm.getAccountNumber(), reportRunnerForm.getSubAccountNumber()); reportSet = SpringContext.getBean( BudgetConstructionDocumentAccountObjectDetailReportService.class) .buildReports(principalName); break; } case 1: { jasperFileName = "BudgetAccountSalaryDetail"; reportSet = SpringContext.getBean(BudgetConstructionAccountSalaryDetailReportService.class) .buildReports( reportRunnerForm.getUniversityFiscalYear(), reportRunnerForm.getChartOfAccountsCode(), reportRunnerForm.getAccountNumber(), reportRunnerForm.getSubAccountNumber()); break; } case 2: { jasperFileName = "BudgetAccountMonthlyDetail"; reportSet = SpringContext.getBean(BudgetConstructionAccountMonthlyDetailReportService.class) .buildReports( reportRunnerForm.getDocumentNumber(), reportRunnerForm.getUniversityFiscalYear(), reportRunnerForm.getChartOfAccountsCode(), reportRunnerForm.getAccountNumber(), reportRunnerForm.getSubAccountNumber()); break; } case 3: { return new ActionForward( buildReportExportForwardURL( reportRunnerForm, mapping, BudgetConstructionReportMode.ACCOUNT_EXPORT.reportModeName), true); } case 4: { return new ActionForward( buildReportExportForwardURL( reportRunnerForm, mapping, BudgetConstructionReportMode.FUNDING_EXPORT.reportModeName), true); } case 5: { return new ActionForward( buildReportExportForwardURL( reportRunnerForm, mapping, BudgetConstructionReportMode.MONTHLY_EXPORT.reportModeName), true); } } if (reportSet.isEmpty()) { List<String> messageList = new ArrayList<String>(); messageList.add(BCConstants.Report.MSG_REPORT_NO_DATA); SpringContext.getBean(BudgetConstructionReportsServiceHelper.class) .generatePdf(messageList, baos); WebUtils.saveMimeOutputStreamAsFile( response, ReportGeneration.PDF_MIME_TYPE, baos, jasperFileName + ReportGeneration.PDF_FILE_EXTENSION); } else { ResourceBundle resourceBundle = ResourceBundle.getBundle( BCConstants.Report.REPORT_MESSAGES_CLASSPATH, Locale.getDefault()); Map<String, Object> reportData = new HashMap<String, Object>(); reportData.put(JRParameter.REPORT_RESOURCE_BUNDLE, resourceBundle); SpringContext.getBean(ReportGenerationService.class) .generateReportToOutputStream( reportData, reportSet, BCConstants.Report.REPORT_TEMPLATE_CLASSPATH + jasperFileName, baos); WebUtils.saveMimeOutputStreamAsFile( response, ReportGeneration.PDF_MIME_TYPE, baos, jasperFileName + ReportGeneration.PDF_FILE_EXTENSION); } return null; }