=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/JDBCReportTableManager.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/JDBCReportTableManager.java 2011-01-14 16:14:22 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/JDBCReportTableManager.java 2011-01-14 18:10:02 +0000
@@ -210,7 +210,7 @@
{
ResultSet resultSet = holder.getStatement().executeQuery( "SELECT * FROM " + reportTable.getExistingTableName() );
- Grid grid = new ListGrid().setTitle( reportTable.getName() );
+ Grid grid = new ListGrid().setTitle( reportTable.getName() ).setTable( reportTable.getExistingTableName() );
// -----------------------------------------------------------------
// Columns
=== added 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 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridJrxmlResult.java 2011-01-14 18:10:02 +0000
@@ -0,0 +1,113 @@
+package org.hisp.dhis.result;
+
+import java.io.Writer;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.struts2.ServletActionContext;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.Velocity;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
+import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.system.util.CodecUtils;
+import org.hisp.dhis.util.ContextUtils;
+
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.Result;
+
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Lars Helge Overland
+ */
+public class GridJrxmlResult
+ implements Result
+{
+ private static final String KEY_GRID = "grid";
+ private static final String TEMPLATE = "grid.vm";
+ private static final String RESOURCE_LOADER_NAME = "class";
+ private static final String DEFAULT_FILENAME = "Grid";
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private Grid grid;
+
+ public void setGrid( Grid grid )
+ {
+ this.grid = grid;
+ }
+
+ // -------------------------------------------------------------------------
+ // Result implementation
+ // -------------------------------------------------------------------------
+
+ @Override
+ public void execute( ActionInvocation invocation )
+ throws Exception
+ {
+ // ---------------------------------------------------------------------
+ // Get grid
+ // ---------------------------------------------------------------------
+
+ Grid _grid = (Grid) invocation.getStack().findValue( "grid" );
+
+ grid = _grid != null ? _grid : grid;
+
+ // ---------------------------------------------------------------------
+ // Configure response
+ // ---------------------------------------------------------------------
+
+ HttpServletResponse response = ServletActionContext.getResponse();
+
+ Writer writer = response.getWriter();
+
+ String filename = CodecUtils.filenameEncode( StringUtils.defaultIfEmpty( grid.getTitle(), DEFAULT_FILENAME ) ) + ".jrxml";
+
+ ContextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_XML, true, filename, false );
+
+ // ---------------------------------------------------------------------
+ // Write jrxml based on Velocity template
+ // ---------------------------------------------------------------------
+
+ VelocityEngine velocity = new VelocityEngine();
+
+ velocity.setProperty( Velocity.RESOURCE_LOADER, RESOURCE_LOADER_NAME );
+ velocity.setProperty( RESOURCE_LOADER_NAME + ".resource.loader.class", ClasspathResourceLoader.class.getName() );
+ velocity.init();
+
+ VelocityContext context = new VelocityContext();
+
+ context.put( KEY_GRID, grid );
+
+ velocity.getTemplate( TEMPLATE ).merge( context, writer );
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridPdfResult.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridPdfResult.java 2011-01-14 16:14:22 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridPdfResult.java 2011-01-14 18:10:02 +0000
@@ -52,7 +52,7 @@
public class GridPdfResult
implements Result
{
- private static final String DEFAULT_FILENAME = "Grid.pdf";
+ private static final String DEFAULT_FILENAME = "Grid";
// -------------------------------------------------------------------------
// Input
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2011-01-14 17:42:33 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2011-01-14 18:10:02 +0000
@@ -39,6 +39,8 @@
class="org.hisp.dhis.result.GridPdfResult" />
+
=== added 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 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/grid.vm 2011-01-14 18:10:02 +0000
@@ -0,0 +1,190 @@
+#set( $dollar = '$' )
+
+
+
+
+
+
+ #foreach( $header in $grid.getHeaders() )
+
+ #end
+
+
+
+
+ #foreach( $header in $grid.getHeaders() )
+
+ #end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
=== 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-01-13 15:44:09 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties 2011-01-14 18:10:02 +0000
@@ -306,4 +306,6 @@
get_report_as_xls = Download as Excel
get_report_as_csv = Download as CSV
get_report_as_pdf = Download as PDF
+get_report_as_jasper = Download as Jasper
+get_report_as_jrxml = Download as JRXML
user_organisation_unit = Include current user organisation unit
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml 2011-01-06 22:22:18 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml 2011-01-14 18:10:02 +0000
@@ -251,6 +251,8 @@
+
+
/main.vm
/dhis-web-reporting/reportTableGrid.vm
/dhis-web-reporting/menu.vm
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/reportTableGrid.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/reportTableGrid.vm 2011-01-06 12:40:57 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/reportTableGrid.vm 2011-01-14 18:10:02 +0000
@@ -3,6 +3,8 @@
+
+