=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/constant/ConstantService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/constant/ConstantService.java 2011-06-29 15:25:19 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/constant/ConstantService.java 2011-07-12 12:15:23 +0000 @@ -56,6 +56,8 @@ Map getConstantMap(); + Map getConstantParameterMap(); + // ------------------------------------------------------------------------- // Constant expanding // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/constant/DefaultConstantService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/constant/DefaultConstantService.java 2011-06-29 15:25:19 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/constant/DefaultConstantService.java 2011-07-12 12:15:23 +0000 @@ -97,6 +97,18 @@ return map; } + + public Map getConstantParameterMap() + { + Map map = new HashMap(); + + for ( Constant constant : getAllConstants() ) + { + map.put( constant.getName(), constant.getValue() ); + } + + return map; + } // ------------------------------------------------------------------------- // Constant expanding === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/GridUtils.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/GridUtils.java 2011-06-26 10:15:36 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/GridUtils.java 2011-07-12 12:15:23 +0000 @@ -45,6 +45,7 @@ import java.io.Writer; import java.util.Iterator; import java.util.List; +import java.util.Map; import jxl.Workbook; import jxl.write.Label; @@ -96,6 +97,7 @@ private static final String KEY_GRID = "grid"; private static final String KEY_ENCODER = "encoder"; + private static final String KEY_PARAMS = "params"; private static final String TEMPLATE = "grid.vm"; private static final String RESOURCE_LOADER_NAME = "class"; @@ -281,18 +283,18 @@ /** * Writes a Jasper Reports representation of the given Grid to the given OutputStream. */ - public static void toJasperReport( Grid grid, OutputStream out ) + public static void toJasperReport( Grid grid, Map params, OutputStream out ) throws Exception { final StringWriter writer = new StringWriter(); - render( grid, writer ); + render( grid, params, writer ); String report = writer.toString(); JasperReport jasperReport = JasperCompileManager.compileReport( StreamUtils.getInputStream( report ) ); - JasperPrint print = JasperFillManager.fillReport( jasperReport, null, grid ); + JasperPrint print = JasperFillManager.fillReport( jasperReport, params, grid ); JasperExportManager.exportReportToPdfStream( print, out ); } @@ -300,16 +302,20 @@ /** * Writes a JRXML (Jasper Reports XML) representation of the given Grid to the given Writer. */ - public static void toJrxml( Grid grid, Writer writer ) + public static void toJrxml( Grid grid, Map params, Writer writer ) throws Exception { - render( grid, writer ); + render( grid, params, writer ); } - + + // ------------------------------------------------------------------------- + // Supportive methods + // ------------------------------------------------------------------------- + /** * Render using Velocity. */ - private static void render( Grid grid, Writer writer ) + private static void render( Grid grid, Map params, Writer writer ) throws Exception { final VelocityEngine velocity = new VelocityEngine(); @@ -322,6 +328,7 @@ context.put( KEY_GRID, grid ); context.put( KEY_ENCODER, ENCODER ); + context.put( KEY_PARAMS, params ); velocity.getTemplate( TEMPLATE ).merge( context, writer ); } === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/resources/grid.vm' --- dhis-2/dhis-support/dhis-support-system/src/main/resources/grid.vm 2011-06-26 10:15:36 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/resources/grid.vm 2011-07-12 12:15:23 +0000 @@ -1,6 +1,9 @@ #set( $dollar = '$' ) + #foreach ( $key in $params.keySet() ) + + #end #foreach( $header in $grid.getHeaders() ) #end === 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-05-05 21:15:45 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridJasperResult.java 2011-07-12 12:15:23 +0000 @@ -27,6 +27,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import java.util.Map; + import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.StringUtils; @@ -62,6 +64,13 @@ { this.grid = grid; } + + private Map params; + + public void setParams( Map params ) + { + this.params = params; + } // ------------------------------------------------------------------------- // Result implementation @@ -77,8 +86,12 @@ Grid _grid = (Grid) invocation.getStack().findValue( "grid" ); - grid = _grid != null ? _grid : grid; + grid = _grid != null ? _grid : grid; + + Map _params = (Map) invocation.getStack().findValue( "params" ); + params = _params != null ? _params : params; + // --------------------------------------------------------------------- // Configure response // --------------------------------------------------------------------- @@ -93,6 +106,6 @@ // Write jrxml based on Velocity template // --------------------------------------------------------------------- - GridUtils.toJasperReport( grid, response.getOutputStream() ); + GridUtils.toJasperReport( grid, params, response.getOutputStream() ); } } === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridJrxmlResult.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridJrxmlResult.java 2011-05-05 21:15:45 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridJrxmlResult.java 2011-07-12 12:15:23 +0000 @@ -1,6 +1,7 @@ package org.hisp.dhis.result; import java.io.Writer; +import java.util.Map; import javax.servlet.http.HttpServletResponse; @@ -65,6 +66,13 @@ this.grid = grid; } + private Map params; + + public void setParams( Map params ) + { + this.params = params; + } + // ------------------------------------------------------------------------- // Result implementation // ------------------------------------------------------------------------- @@ -80,6 +88,10 @@ Grid _grid = (Grid) invocation.getStack().findValue( "grid" ); grid = _grid != null ? _grid : grid; + + Map _params = (Map) invocation.getStack().findValue( "params" ); + + params = _params != null ? _params : params; // --------------------------------------------------------------------- // Configure response @@ -97,6 +109,6 @@ // Write jrxml based on Velocity template // --------------------------------------------------------------------- - GridUtils.toJrxml( grid, writer ); + GridUtils.toJrxml( grid, params, writer ); } } === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/JRExportUtils.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/JRExportUtils.java 2011-05-05 21:15:45 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/JRExportUtils.java 2011-07-12 12:15:23 +0000 @@ -49,11 +49,7 @@ public static final String TYPE_XLS = "xls"; public static final String TYPE_PDF = "pdf"; - private static final Map exporters = new HashMap() { - /** - * Determines if a de-serialized file is compatible with this class. - */ - private static final long serialVersionUID = 6662444011214507874L; + private static final Map exporters = new HashMap() { { put( TYPE_XLS, new JRXlsExportProvider() ); put( TYPE_PDF, new JRPdfExportProvider() ); === 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-03-08 01:55:01 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/RenderReportAction.java 2011-07-12 12:15:23 +0000 @@ -31,6 +31,7 @@ import java.io.OutputStream; import java.sql.Connection; +import java.util.Map; import javax.servlet.http.HttpServletResponse; @@ -41,6 +42,7 @@ import org.amplecode.quick.StatementManager; import org.hisp.dhis.common.Grid; +import org.hisp.dhis.constant.ConstantService; import org.hisp.dhis.i18n.I18nFormat; import org.hisp.dhis.report.Report; import org.hisp.dhis.report.ReportService; @@ -79,6 +81,13 @@ this.reportTableService = reportTableService; } + private ConstantService constantService; + + public void setConstantService( ConstantService constantService ) + { + this.constantService = constantService; + } + private StatementManager statementManager; public void setStatementManager( StatementManager statementManager ) @@ -137,6 +146,8 @@ Report report = reportService.getReport( id ); + Map constantMap = constantService.getConstantParameterMap(); + JasperReport jasperReport = JasperCompileManager.compileReport( StreamUtils.getInputStream( report.getDesignContent() ) ); JasperPrint print = null; @@ -147,7 +158,7 @@ Grid grid = reportTableService.getReportTableGrid( reportTable.getId(), format, reportingPeriod, organisationUnitId ); - print = JasperFillManager.fillReport( jasperReport, null, grid ); + print = JasperFillManager.fillReport( jasperReport, constantMap, grid ); } else // Assume SQL report and provide JDBC connection { @@ -155,7 +166,7 @@ try { - print = JasperFillManager.fillReport( jasperReport, null, connection ); + print = JasperFillManager.fillReport( jasperReport, constantMap, connection ); } finally { === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/ExportTableAction.java' --- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/ExportTableAction.java 2011-01-17 16:17:06 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/ExportTableAction.java 2011-07-12 12:15:23 +0000 @@ -27,7 +27,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import java.util.Map; + import org.hisp.dhis.common.Grid; +import org.hisp.dhis.constant.ConstantService; import org.hisp.dhis.i18n.I18nFormat; import org.hisp.dhis.reporttable.ReportTableService; import org.hisp.dhis.util.SessionUtils; @@ -53,6 +56,13 @@ this.reportTableService = reportTableService; } + private ConstantService constantService; + + public void setConstantService( ConstantService constantService ) + { + this.constantService = constantService; + } + private I18nFormat format; public void setFormat( I18nFormat format ) @@ -110,6 +120,13 @@ return grid; } + private Map params; + + public Map getParams() + { + return params; + } + // ------------------------------------------------------------------------- // Result implementation // ------------------------------------------------------------------------- @@ -126,6 +143,8 @@ { grid = reportTableService.getReportTableGrid( id, format, reportingPeriod, organisationUnitId ); } + + params = constantService.getConstantParameterMap(); SessionUtils.setSessionVar( SessionUtils.KEY_REPORT_TABLE_GRID, grid ); === 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-06-07 16:12:23 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2011-07-12 12:15:23 +0000 @@ -165,6 +165,7 @@ + +