Skip to content

Commit

Permalink
SEAMREPORTS-3: Added getDelegate() to interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed May 26, 2011
1 parent b693f16 commit 5860a92
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 7 deletions.
12 changes: 12 additions & 0 deletions api/src/main/java/org/jboss/seam/reports/Report.java
Expand Up @@ -23,5 +23,17 @@
*
*/
public interface Report {
/**
* Return the definition (if available) that this report was based
*
* @return the {@link ReportDefinition} used to create this {@link Report}
*/
public ReportDefinition<? extends ReportDataSource, ? extends Report> getReportDefinition();

/**
* Return the underlying provider object for the {@link Report}, if available
*
* @return The result of this method is implementation specific
*/
public Object getDelegate();
}
Expand Up @@ -24,4 +24,10 @@
*/
public interface ReportDataSource {

/**
* The result of this method is implementation specific
*
* @return
*/
public Object getDelegate();
}
Expand Up @@ -23,12 +23,24 @@
public class JasperSeamReport implements Report {

private JasperPrint jasperPrint;

private JasperSeamReportDefinition reportDefinition;

public JasperSeamReport(JasperPrint jasperPrint) {
this.jasperPrint = jasperPrint;
}

public JasperPrint getJasperPrint() {
public JasperSeamReport(JasperPrint jasperPrint, JasperSeamReportDefinition reportDefinition) {
this.jasperPrint = jasperPrint;
this.reportDefinition = reportDefinition;
}

@Override
public JasperSeamReportDefinition getReportDefinition() {
return reportDefinition;
}

@Override
public JasperPrint getDelegate() {
return jasperPrint;
}
}
Expand Up @@ -28,7 +28,7 @@ public JasperSeamReportDataSource(JRDataSource dataSource) {
this.dataSource = dataSource;
}

public JRDataSource getDataSource() {
public JRDataSource getDelegate() {
return dataSource;
}
}
Expand Up @@ -44,7 +44,7 @@ public JasperReport getCompiledReport() {
public JasperSeamReport fill(JasperSeamReportDataSource dataSource, Map<String, Object> parameters)
throws ReportException {
try {
JRDataSource ds = dataSource.getDataSource();
JRDataSource ds = dataSource.getDelegate();
JasperPrint filledReport = JasperFillManager.fillReport(getCompiledReport(), parameters,ds);
return new JasperSeamReport(filledReport);
} catch (JRException e) {
Expand Down
Expand Up @@ -31,7 +31,7 @@ public abstract class AbstractJasperReportRenderer implements ReportRenderer<Jas
@Override
public void render(JasperSeamReport reportInstance, OutputStream output) throws ReportException {
JRExporter exporter = getExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, reportInstance.getJasperPrint());
exporter.setParameter(JRExporterParameter.JASPER_PRINT, reportInstance.getDelegate());
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, output);
try {
exporter.exportReport();
Expand Down
Expand Up @@ -24,9 +24,9 @@

import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.seam.reports.ReportDefinition;
import org.jboss.seam.reports.ReportDataSource;
import org.jboss.seam.reports.Report;
import org.jboss.seam.reports.ReportDataSource;
import org.jboss.seam.reports.ReportDefinition;
import org.jboss.seam.reports.ReportRenderer;
import org.jboss.seam.reports.jasperreports.JasperReports;
import org.jboss.seam.reports.jasperreports.JasperSeamReportLoader;
Expand Down

0 comments on commit 5860a92

Please sign in to comment.