java.lang.Object
is.codion.plugin.jasperreports.JasperReports
Factory for
Report based on JasperReports.-
Method Summary
Modifier and TypeMethodDescriptionstatic JRReport<net.sf.jasperreports.engine.JasperPrint> classPathReport(Class<?> resourceClass, String reportPath) Instantiates a JRReport for a classpath based report.static <R> JRReport<R> Returns a report producing the result of the given export when filled, instead of aJasperPrint.static <R> RExports the given filled report, for aJasperPrintalready at hand, such as one returned byfillReport(JRReport, JRDataSource).static JRReport<net.sf.jasperreports.engine.JasperPrint> fileReport(String reportPath) Instantiates a JRReport for a file based report, either loaded from a URL or from the filesystem.static JRReport<net.sf.jasperreports.engine.JasperPrint> fileReport(String reportPath, boolean cacheReport) Instantiates a JRReport for a file based report, either loaded from a URL or from the filesystem.static net.sf.jasperreports.engine.JasperPrintfillReport(JRReport<net.sf.jasperreports.engine.JasperPrint> report, net.sf.jasperreports.engine.JRDataSource dataSource) Fills the report using the data source wrapped by the given data wrapperstatic net.sf.jasperreports.engine.JasperPrintfillReport(JRReport<net.sf.jasperreports.engine.JasperPrint> report, net.sf.jasperreports.engine.JRDataSource dataSource, Map<String, Object> reportParameters) Fills the report using the given data.static net.sf.jasperreports.engine.JasperPrintloadPrint(byte[] bytes) Reconstructs aJasperPrintfrom the bytesJRExport.SERIALIZEDproduced, for a client receiving them from a report exported to it, letting a client with the reporting engine keep aJasperPrintreport over a connection which can not transfer one, such as a JSON one.
-
Method Details
-
classPathReport
public static JRReport<net.sf.jasperreports.engine.JasperPrint> classPathReport(Class<?> resourceClass, String reportPath) Instantiates a JRReport for a classpath based report. Note that classpath reports are always cached.- Parameters:
resourceClass- the class owning the report resourcereportPath- the report path, relative to the resource class- Returns:
- a report wrapper
-
fileReport
Instantiates a JRReport for a file based report, either loaded from a URL or from the filesystem.- Parameters:
reportPath- the report path, relative to the central report pathReport.REPORT_PATH- Returns:
- a report wrapper
-
fileReport
public static JRReport<net.sf.jasperreports.engine.JasperPrint> fileReport(String reportPath, boolean cacheReport) Instantiates a JRReport for a file based report, either loaded from a URL or from the filesystem.- Parameters:
reportPath- the report path, relative to the central report pathReport.REPORT_PATHcacheReport- if true the report is only loaded once and cached- Returns:
- a report wrapper
-
export
public static <R> JRReport<R> export(JRReport<net.sf.jasperreports.engine.JasperPrint> report, JRExport<R> export) Returns a report producing the result of the given export when filled, instead of aJasperPrint.The export runs wherever the report is filled, on the server in case of a remote connection, so a report exported to
JRExport.PDFreaches the client as bytes, requiring no reporting engine there.ReportType<Map<String, Object>, byte[]> REPORT = reportType("customer_report"); add(REPORT, export(classPathReport(Store.class, "customer_report.jasper"), PDF));The loaded report and its cache are shared with the given report, so exporting the same report to more than one format loads and caches it once.
- Type Parameters:
R- the export result type- Parameters:
report- the report to exportexport- the export to apply to the filled report- Returns:
- a report producing the result of the given export
- See Also:
-
export
Exports the given filled report, for aJasperPrintalready at hand, such as one returned byfillReport(JRReport, JRDataSource).- Type Parameters:
R- the export result type- Parameters:
print- the filled report to exportexport- the export to apply- Returns:
- the exported report
- Throws:
ReportException- in case of an exception- See Also:
-
loadPrint
public static net.sf.jasperreports.engine.JasperPrint loadPrint(byte[] bytes) Reconstructs aJasperPrintfrom the bytesJRExport.SERIALIZEDproduced, for a client receiving them from a report exported to it, letting a client with the reporting engine keep aJasperPrintreport over a connection which can not transfer one, such as a JSON one.JasperPrint print = loadPrint(connection.report(REPORT, parameters));- Parameters:
bytes- the bytesJRExport.SERIALIZEDproduced- Returns:
- the reconstructed report
- Throws:
ReportException- in case of an exception- See Also:
-
fillReport
public static net.sf.jasperreports.engine.JasperPrint fillReport(JRReport<net.sf.jasperreports.engine.JasperPrint> report, net.sf.jasperreports.engine.JRDataSource dataSource) Fills the report using the data source wrapped by the given data wrapper- Parameters:
report- the report to filldataSource- the data provider to use for the report generation- Returns:
- a filled report ready for display
- Throws:
ReportException- in case of an exception
-
fillReport
public static net.sf.jasperreports.engine.JasperPrint fillReport(JRReport<net.sf.jasperreports.engine.JasperPrint> report, net.sf.jasperreports.engine.JRDataSource dataSource, Map<String, Object> reportParameters) Fills the report using the given data.- Parameters:
report- the report to filldataSource- the data provider to use for the report generationreportParameters- the report parameters, must be modifiable- Returns:
- a filled report ready for display
- Throws:
ReportException- in case of an exception
-