=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java' --- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java 2011-02-23 14:27:49 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java 2011-02-23 19:20:08 +0000 @@ -86,6 +86,8 @@ private static final String MODE_REPORT = "report"; private static final String MODE_REPORT_TABLE = "table"; + private static final String YES = "Yes"; + private static final String NO = "No"; // --------------------------------------------------------------------- // Dependencies @@ -515,7 +517,7 @@ grid.addValue( reportTable.getReportingMonthName() ); grid.addValue( reportTable.getOrganisationUnitName() ); - grid.addValue( isCurrentParent( row ) ? 1 : 0 ); + grid.addValue( isCurrentParent( row ) ? YES : NO ); for ( List column : reportTable.getColumns() ) { === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement/CreateReportTableStatement.java' --- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement/CreateReportTableStatement.java 2011-02-17 16:56:33 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement/CreateReportTableStatement.java 2011-02-23 19:20:08 +0000 @@ -100,7 +100,7 @@ // Organisation unit is parent // --------------------------------------------------------------------- - buffer.append( ReportTable.ORGANISATION_UNIT_IS_PARENT_COLUMN_NAME + SPACE + NUMERIC_COLUMN_TYPE + SEPARATOR ); + buffer.append( ReportTable.ORGANISATION_UNIT_IS_PARENT_COLUMN_NAME + SPACE + SHORT_TEXT_COLUMN_TYPE + SEPARATOR ); // --------------------------------------------------------------------- // Crosstab === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridJasperResult.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridJasperResult.java 2011-01-26 11:28:54 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridJasperResult.java 2011-02-23 19:20:08 +0000 @@ -28,7 +28,6 @@ */ import java.io.StringWriter; -import java.sql.Connection; import javax.servlet.http.HttpServletResponse; @@ -38,7 +37,6 @@ import net.sf.jasperreports.engine.JasperPrint; import net.sf.jasperreports.engine.JasperReport; -import org.amplecode.quick.StatementManager; import org.apache.commons.lang.StringUtils; import org.apache.struts2.ServletActionContext; import org.apache.velocity.VelocityContext; @@ -65,17 +63,6 @@ private static final String DEFAULT_FILENAME = "Grid"; // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private StatementManager statementManager; - - public void setStatementManager( StatementManager statementManager ) - { - this.statementManager = statementManager; - } - - // ------------------------------------------------------------------------- // Input // ------------------------------------------------------------------------- @@ -138,22 +125,8 @@ JasperReport jasperReport = JasperCompileManager.compileReport( StreamUtils.getInputStream( report ) ); - Connection connection = statementManager.getHolder().getConnection(); - - JasperPrint print = null; - - try - { - print = JasperFillManager.fillReport( jasperReport, null, connection ); - } - finally - { - connection.close(); - } - - if ( print != null ) - { - JasperExportManager.exportReportToPdfStream( print, response.getOutputStream() ); - } + JasperPrint print = JasperFillManager.fillReport( jasperReport, null, grid ); + + JasperExportManager.exportReportToPdfStream( print, response.getOutputStream() ); } } === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/grid.vm' --- dhis-2/dhis-web/dhis-web-commons/src/main/resources/grid.vm 2011-01-18 10:28:31 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/grid.vm 2011-02-23 19:23:07 +0000 @@ -1,17 +1,6 @@ #set( $dollar = '$' ) - - - - - #foreach( $header in $grid.getHeaders() ) - - #end - - - - #foreach( $header in $grid.getHeaders() ) #end @@ -56,11 +45,11 @@ - - + + #foreach( $header in $grid.getHeaders() ) - #if ( !$header.meta ) + #if ( !$header.meta ) @@ -71,9 +60,7 @@ - - - + @@ -97,7 +84,7 @@ #set( $x = 10 ) #foreach( $header in $grid.getVisibleHeaders() ) - #if( $header.meta ) #set( $offset = 110 ) #else #set( $offset = 60 ) #end + #if( $header.meta ) #set( $offset = 110 ) #else #set( $offset = 60 ) #end @@ -116,7 +103,7 @@ #set( $x = 10 ) #foreach( $header in $grid.getVisibleHeaders() ) - #if( $header.meta ) #set( $offset = 110 ) #else #set( $offset = 60 ) #end + #if( $header.meta ) #set( $offset = 110 ) #else #set( $offset = 60 ) #end === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/RenderReportAction.java' --- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/RenderReportAction.java 2011-01-26 07:55:56 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/RenderReportAction.java 2011-02-23 19:20:08 +0000 @@ -39,8 +39,12 @@ import net.sf.jasperreports.engine.JasperReport; import org.amplecode.quick.StatementManager; +import org.hisp.dhis.common.Grid; +import org.hisp.dhis.i18n.I18nFormat; import org.hisp.dhis.report.Report; import org.hisp.dhis.report.ReportService; +import org.hisp.dhis.reporttable.ReportTable; +import org.hisp.dhis.reporttable.ReportTableService; import org.hisp.dhis.system.util.StreamUtils; import org.hisp.dhis.util.ContextUtils; import org.hisp.dhis.util.StreamActionSupport; @@ -63,12 +67,26 @@ this.reportService = reportService; } + private ReportTableService reportTableService; + + public void setReportTableService( ReportTableService reportTableService ) + { + this.reportTableService = reportTableService; + } + private StatementManager statementManager; public void setStatementManager( StatementManager statementManager ) { this.statementManager = statementManager; } + + private I18nFormat format; + + public void setFormat( I18nFormat format ) + { + this.format = format; + } // ------------------------------------------------------------------------- // Input @@ -81,6 +99,20 @@ this.id = id; } + private Integer reportingPeriod; + + public void setReportingPeriod( Integer reportingPeriod ) + { + this.reportingPeriod = reportingPeriod; + } + + private Integer organisationUnitId; + + public void setOrganisationUnitId( Integer organisationUnitId ) + { + this.organisationUnitId = organisationUnitId; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -93,24 +125,37 @@ JasperReport jasperReport = JasperCompileManager.compileReport( StreamUtils.getInputStream( report.getDesignContent() ) ); - Connection connection = statementManager.getHolder().getConnection(); - JasperPrint print = null; - - try + + if ( report.hasReportTable() ) // Use JR data source { - print = JasperFillManager.fillReport( jasperReport, null, connection ); + ReportTable reportTable = report.getReportTable(); + + Grid grid = reportTableService.getReportTableGrid( reportTable.getId(), format, reportingPeriod, organisationUnitId ); + + System.out.println( grid ); + + print = JasperFillManager.fillReport( jasperReport, null, grid ); } - finally - { - connection.close(); + else // Assume SQL report and provide JDBC connection + { + Connection connection = statementManager.getHolder().getConnection(); + + try + { + print = JasperFillManager.fillReport( jasperReport, null, connection ); + } + finally + { + connection.close(); + } } if ( print != null ) { JasperExportManager.exportReportToPdfStream( print, out ); } - + return SUCCESS; } === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2011-02-22 23:05:45 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2011-02-23 19:20:08 +0000 @@ -318,6 +318,8 @@ scope="prototype"> + === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties 2011-02-19 00:09:05 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties 2011-02-23 19:20:08 +0000 @@ -118,7 +118,7 @@ generate_workbook= Generate Workbook importing_report_tables= Importing report tables completeness_configuration_explanation= Number of days refers to the maximum number of days after the end of the reporting month before the data must be submitted -omit_report_table_explanation= If selecting no report table, the user is responsible for providing the data source table +omit_report_table_explanation= If selecting no report table, the user is responsible for providing the data source reporting_deadline= Reporting deadline nr_of_days= Number of days select_report_table_none= Select report table / none === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addReportForm.vm' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addReportForm.vm 2011-02-22 23:05:45 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addReportForm.vm 2011-02-23 19:20:08 +0000 @@ -23,13 +23,8 @@ - - - - $i18n.getString( "report_table" ) - - - +