110 likes | 228 Views
EQE Reporting. Your guide to the awesome world of business report creation!. Workspace Configuration. The ‘eqeweb’ project has a folder off of the root for holding the report templates that iReports generates.
E N D
EQE Reporting Your guide to the awesome world of business report creation!
Workspace Configuration • The ‘eqeweb’ project has a folder off of the root for holding the report templates that iReports generates. • These templates have a .jrxml extension and should be saved in SVN but not deployed.
Workspace Configuration (cont.) • ‘eqeweb’ has a folder under /WebContent/WEB-INF/reports for storing the compiled reports. • Compiled reports are generated by iReport and have a .jasper extension. • These should be deployed with the application, which is why they are stored under /WebContent
iReports Setup • Create a new report. • File -> New… Blank A4. • Choose to work with the template or use the report wizard. • When prompted enter the directory to save the template to. • [WORKSPACE]\eqeweb\reportTemplates
iReport Configuration (cont.) • Configure the compiler output directory. • Tools -> options • Click the Compilation and Execution Tab • Uncheck ‘use report directory’ and enter [WORKSPACE]\eqeweb\WebContent\WEB-INF\reports
iReports Configuration (cont.) • While in the options menu click on the classpath tab and add an entry for [WORKSPACE]\eqeweb\build\classes and check ‘reloadable’ • To add a class that will be used for reporting, click the database button above the report designer. Click the javabean datasource tab. Put in the name of the class that should be used. For example, com.cigna.eqe.pbo.report.MetricResultsreportDisplay. Click ‘Read Attributes’. Select the attributes that should be used on the report and click ‘Add Selected Fields’. Click ‘Ok’. • These fields can now be dragged out onto the report designer. • Everything should now be configured properly so you can work on the report. • Use the hammer button above the report designer to compile a report.
Eclipse • After compiling a report, refresh the project in Eclipse. The report template should show up under the reportTemplates folder and the compiled report should show up under /WebContent/WEB-INF/reports. • The next step is to write code to render the report to the browser.
Overview of Coding Steps • Create a jsp page with search criteria in a form with a button for submitting the criteria. • Add a method to the ReportController class in the com.cigna.eqe.web package that the form will submit to. • Get the collection that you will pass to the report using, for example, a service method. • Add the collection to the Model object of Spring Web MVC.
ReportController Sample Code • @RequestMapping(value = "reports/metricResultsReportSearch.html", method = RequestMethod.POST) • public String searchMetricResultsReport(@ModelAttribute("dashboardSearch") DashboardSearch dashboardSearch, Model model) • { • List<FileIntake> fileIntakes = eqeService.doFileIntakeSearch(dashboardSearch); • List<FileProcess> fileProcesses = eqeStageService.findFileProcessByFileIntakesFileStatus(fileIntakes, dashboardSearch.getFileStatusType().getFileStatusTypeId()); • List<BusinessFileIntake> businessFileIntakes = eqeService.getBusinessFileIntakes(fileProcesses, fileIntakes); • List<MetricResultsReportDisplay> metricResultsReportDisplays = new ArrayList<MetricResultsReportDisplay>(); • List<MetricResultsDisplay> metricResultsDisplays = new ArrayList<MetricResultsDisplay>(); • List<MetricResultsDisplay> metricResultsDisplaysFile = new ArrayList<MetricResultsDisplay>(); • for(BusinessFileIntake businessFileIntake : businessFileIntakes) • { • Integer fid = businessFileIntake.getFileIntakeId(); • List<MetricResults> metricResults = eqeService.getMetricResultsByFid(fid); • MetricResultsDisplayMapper.mapMetricResultToMetricResultsDisplay(metricResults, metricResultsDisplaysFile, metricResultsDisplays); • for(MetricResultsDisplay metricResultsDisplay : metricResultsDisplays) • { • MetricResultsReportDisplay metricResultsReportDisplay = new MetricResultsReportDisplay(); • metricResultsReportDisplay.setFid(fid); • metricResultsReportDisplay.setFieldName(metricResultsDisplay.getFieldName()); • metricResultsReportDisplay.setLowerValue(metricResultsDisplay.getLowerThreshold()); • metricResultsReportDisplay.setResult(metricResultsDisplay.getResult()); • metricResultsReportDisplay.setUpperValue(metricResultsDisplay.getUpperThreshold()); • metricResultsReportDisplay.setValue(metricResultsDisplay.getValue()); • metricResultsReportDisplays.add(metricResultsReportDisplay); • } • metricResultsDisplays.clear(); • metricResultsDisplaysFile.clear(); • } • model.addAttribute("metricResultsReportDisplays", metricResultsReportDisplays); • return "metricResultsReport"; • }
Resource Bundle Configuration • The last step is to add an entry to the report views resource bundle for the new report. • The resource bundle is located in /resource/reportViews.properties. • There is also a folder /resource/reportImages that contains any reporting images. ** These have to be on the classpath to be added to the report. They cannot be added from a web folder.
Sample Resource Bundle Entries • metricResultsReport.class=org.springframework.web.servlet.view.jasperreports.JasperReportsPdfView • metricResultsReport.url=/WEB-INF/reports/MetricResults.jasper • The first entry lets the view resolver know that the view will be a JasperReportsPdfView. This should remain the same for all reports, but it doesn’t have to. • The second entry tells spring where to find the compiled report. • When returning from a controller back to the view just specify the part of the property before the dot. For the metric results report, the controller would return “metricResultsReport”, as seen in the previous slide.