← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2425: - Implemented generic Struts results for the multipurpose Grid object for XLS and CSV formats. Ap...

 

------------------------------------------------------------
revno: 2425
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2010-12-26 16:38:45 +0100
message:
  - Implemented generic Struts results for the multipurpose Grid object for XLS and CSV formats. Applied these results for report table data output, all report table data output is now produces by the exportTable action and its representation is defined with the type request parameter. This is cleaner and separates better between the model and its representation than the current myriad of services and actions handling export to the various formats. Removed lots of classes which now are redundant, more to come.  - Removed the display column functionality for report table, which was far too error prone as it failed if the the user first created a report table, then added display columns, then changed the report table. Implemented an automatic function which removes the identifier columns and gives the rest of the columns pretty names before the table is rendered, which is what one mostly did with the display columns anyway.
removed:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableColumn.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/csv/
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/csv/converter/
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/csv/converter/ReportTableDataConverter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/csv/exporter/
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/csv/exporter/CSVExportPipeThread.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/csv/exporter/DefaultCSVExportService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement/DisplayReportTableStatement.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTableColumn.hbm.xml
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GenerateTableDataWorkbookAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetDisplayTableOptionsAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetTableDataAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetTableDataExportAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveDisplayTableAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/displayTableForm.vm
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/style/
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/style/dhis-web-reporting.css
added:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/htmlGrid.vm
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridCsvResult.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridXlsResult.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/ExportTableAction.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/Grid.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml
  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/jdbc/JDBCReportTableManager.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/ReportTableManager.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/WorkbookService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/impl/JExcelWorkbookService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml
  dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableTest.java
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/ListGrid.java
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/CodecUtils.java
  dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/grid/GridTest.java
  dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/CodecUtilsTest.java
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/help/action/GetHelpContentAction.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/help/action/GetHelpItemsAction.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/ContextUtils.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/StreamActionSupport.java
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/GetDataElementCategoryListAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/categorycombo/GetDataElementCategoryComboListAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/concept/GetConceptListAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/EditSectionAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/AddUserGroupAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/AddUserGroupFormAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/UpdateUserGroupAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/ValidateUserAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/ValidateUserGroupAction.java
  dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/ExportExcelAction.java
  dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/ExportImageAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportDesignAction.java
  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/resources/META-INF/dhis/beans.xml
  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/struts.xml
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.js
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewTableForm.vm


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/Grid.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/Grid.java	2010-12-22 09:29:03 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/Grid.java	2010-12-26 15:38:45 +0000
@@ -27,6 +27,8 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.sql.ResultSet;
+import java.sql.SQLException;
 import java.util.List;
 
 /**
@@ -42,7 +44,17 @@
     /**
      * Sets the grid title.
      */
-    void setTitle( String title );
+    Grid setTitle( String title );
+    
+    /**
+     * Returns the grid subtitle.
+     */
+    String getSubtitle();
+    
+    /**
+     * Sets the grid subtitle.
+     */
+    Grid setSubtitle( String subtitle );
     
     /**
      * Returns all header values.
@@ -52,7 +64,13 @@
     /**
      * Adds a header value.
      */
-    void addHeader( String value );
+    Grid addHeader( String value );
+    
+    /**
+     * Replaces the header String given in the first argument with the header
+     * String given in the second argument if the former exists.
+     */
+    Grid replaceHeader( String currentHeader, String newHeader );
     
     /**
      * Returns the current height / number of rows in the grid.
@@ -67,14 +85,14 @@
     /**
      * Adds a new row the the grid and moves the cursor accordingly.
      */
-    void nextRow();
+    Grid nextRow();
 
     /**
      * Adds the value to the end of the current row.
      * 
      * @param value the value to add.
      */
-    void addValue( String value );
+    Grid addValue( String value );
 
     /**
      * Returns the row with the given index.
@@ -112,12 +130,31 @@
      * @throws IllegalStateException if the columnValues has different length
      *         than the rows in grid, or if the grid rows are not of the same length.
      */
-    void addColumn( List<String> columnValues );
-
-    /**
-     * Column must hold numeric data.
+    Grid addColumn( List<String> columnValues );
+    
+    /**
+     * Removes the header and column at the given index.
+     */
+    Grid removeColumn( int columnIndex );
+    
+    /**
+     * Removes the header and the column at the index of the given header if it
+     * exists.
+     */
+    Grid removeColumn( String header );
+    
+    /**
+     * Adds a regression column to the grid. Column must hold numeric data.
      * 
      * @param columnIndex the index of the base column.
      */
-    void addRegressionColumn( int columnIndex );
+    Grid addRegressionColumn( int columnIndex );
+    
+    /**
+     * Instantiates and populates a Grid based on the given result set. The
+     * column names are used as headers and result rows are represented as grid
+     * rows.
+     */
+    Grid fromResultSet( ResultSet resultSet )
+        throws SQLException;
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java	2010-12-10 19:33:05 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java	2010-12-26 15:38:45 +0000
@@ -28,6 +28,7 @@
  */
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -88,6 +89,18 @@
     public static final String TOTAL_COLUMN_PRETTY_PREFIX = "Total ";
     
     public static final String REGRESSION_COLUMN_PREFIX = "regression_";
+
+    public static final List<String> DB_COLUMNS = Arrays.asList( DATAELEMENT_ID, CATEGORYCOMBO_ID, 
+        INDICATOR_ID, DATASET_ID, PERIOD_ID, ORGANISATIONUNIT_ID, REPORTING_MONTH_COLUMN_NAME, PARAM_ORGANISATIONUNIT_COLUMN_NAME );
+    
+    public static final Map<String, String> PRETTY_COLUMNS = new HashMap<String, String>() { {
+        put( DATAELEMENT_NAME, "Data element" );
+        put( CATEGORYCOMBO_NAME, "Category combination" );
+        put( INDICATOR_NAME, "Indicator" );
+        put( DATASET_NAME, "Data set" );
+        put( PERIOD_NAME, "Period" );
+        put( ORGANISATIONUNIT_NAME, "Organisation unit" );
+    } };
     
     private static final String EMPTY_REPLACEMENT = "_";
     private static final String EMPTY = "";    
@@ -183,11 +196,6 @@
      */
     private ReportParams reportParams;
 
-    /**
-     * The list of ReportTableColumns for the ReportTable.
-     */
-    private List<ReportTableColumn> displayColumns = new ArrayList<ReportTableColumn>();
-    
     // -------------------------------------------------------------------------
     // Transient properties
     // -------------------------------------------------------------------------
@@ -650,38 +658,6 @@
     }
     
     /**
-     * Returns a list of ReportTableColumns for this ReportTable. Searches for
-     * persisted display columns for each column. If none is found, a
-     * ReportTableColumn is generated based on the pretty-print column name and
-     * inserted in the list.
-     */
-    public List<ReportTableColumn> getFilledDisplayColumns()
-    {
-        List<String> columns = getAllColumns();
-        
-        List<ReportTableColumn> displayColumns = new ArrayList<ReportTableColumn>( getDisplayColumns() );
-        
-        for ( String column : columns )
-        {
-            if ( !hasDisplayColumn( column ) )
-            {
-                String prettyColumn = prettyCrossTabColumns.get( column ) != null ? 
-                    prettyCrossTabColumns.get( column ) : prettyPrintColumn( column );
-                    
-                ReportTableColumn displayColumn = new ReportTableColumn();
-                
-                displayColumn.setName( column );
-                displayColumn.setHeader( prettyColumn );
-                displayColumn.setHidden( false );
-                
-                displayColumns.add( displayColumn );
-            }
-        }
-        
-        return displayColumns;
-    }
-    
-    /**
      * Returns a list of names of all columns for this ReportTable.
      */
     public List<String> getAllColumns()
@@ -691,6 +667,7 @@
         columns.addAll( getIndexColumns() );
         columns.addAll( getIndexNameColumns() );
         columns.add( ReportTable.REPORTING_MONTH_COLUMN_NAME );
+        columns.add( ReportTable.PARAM_ORGANISATIONUNIT_COLUMN_NAME );
         columns.addAll( getCrossTabColumns() );
         columns.addAll( getDimensionOptionColumns() );
         
@@ -711,22 +688,6 @@
     }
     
     /**
-     * Tests whether the column with the argument name has a corresponding ReportTableColumn.
-     */
-    public boolean hasDisplayColumn( String name )
-    {
-        for ( ReportTableColumn column : displayColumns )
-        {
-            if ( column.getName().equals( name ) && column.getHeader() != null && column.getHeader().trim().length() > 0 )
-            {
-                return true;
-            }
-        }
-        
-        return false;
-    }
-    
-    /**
      * Generates a pretty-print name of the argument column name.
      */
     public String prettyPrintColumn( String column )
@@ -1267,17 +1228,7 @@
     {
         this.reportParams = reportParams;
     }
-
-    public List<ReportTableColumn> getDisplayColumns()
-    {
-        return displayColumns;
-    }
-
-    public void setDisplayColumns( List<ReportTableColumn> displayColumns )
-    {
-        this.displayColumns = displayColumns;
-    }
-
+    
     // -------------------------------------------------------------------------
     // Get- and set-methods for transient properties
     // -------------------------------------------------------------------------

=== removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableColumn.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableColumn.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableColumn.java	1970-01-01 00:00:00 +0000
@@ -1,116 +0,0 @@
-package org.hisp.dhis.reporttable;
-
-/*
- * 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.
- */
-
-/**
- * The ReportTableColumn objec represents a customziable column header for a
- * ReportTable, including a more meaningful name and the ability to hide it in a
- * view.
- * 
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class ReportTableColumn
-{
-    private int id;
-    
-    private String name;
-    
-    private String header;
-    
-    private boolean hidden;
-
-    // -------------------------------------------------------------------------
-    // Constructor
-    // -------------------------------------------------------------------------
-
-    public ReportTableColumn()
-    {   
-    }
-    
-    public ReportTableColumn( String name, String header, boolean hidden )
-    {
-        this.name = name;
-        this.header = header;
-        this.hidden = hidden;
-    }
-
-    // -------------------------------------------------------------------------
-    // equals
-    // -------------------------------------------------------------------------
-
-    @Override
-    public String toString()
-    {
-        return "[" + name + ", " + header + "]";
-    }
-    
-    // -------------------------------------------------------------------------
-    // Getters and setters
-    // -------------------------------------------------------------------------
-
-    public int getId()
-    {
-        return id;
-    }
-
-    public void setId( int id )
-    {
-        this.id = id;
-    }
-
-    public String getName()
-    {
-        return name;
-    }
-
-    public void setName( String name )
-    {
-        this.name = name;
-    }
-
-    public String getHeader()
-    {
-        return header;
-    }
-
-    public void setHeader( String header )
-    {
-        this.header = header;
-    }
-
-    public boolean isHidden()
-    {
-        return hidden;
-    }
-
-    public void setHidden( boolean hidden )
-    {
-        this.hidden = hidden;
-    }
-}

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java	2010-12-14 11:36:39 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java	2010-12-26 15:38:45 +0000
@@ -29,6 +29,7 @@
 
 import java.util.Collection;
 
+import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.i18n.I18nFormat;
 
 /**
@@ -124,17 +125,17 @@
      * @return the ReportTable.
      */
     ReportTable getReportTableByName( String name );
-    
+
     /**
-     * Retrieves a ReportTableData object for the ReportTable with the given
-     * identifier.
+     * Instantiates and populates a Grid populated with data from the ReportTable 
+     * with the given identifier.
      * 
-     * @param id the identifier of the ReportTable which the ReportTableData is
-     *        based on.
-     * @return a ReportTableData object.
+     * @param id the ReportTable identifier.
+     * @param format the I18nFormat.
+     * @return a Grid.
      */
-    ReportTableData getReportTableData( int id, I18nFormat format );
-
+    Grid getPrettyReportTableGrid( int id, I18nFormat format );
+    
     /**
      * Tests whether the report table has been generated in the database.
      * 

=== removed directory 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/csv'
=== removed directory 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/csv/converter'
=== removed file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/csv/converter/ReportTableDataConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/csv/converter/ReportTableDataConverter.java	2010-12-25 13:24:54 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/csv/converter/ReportTableDataConverter.java	1970-01-01 00:00:00 +0000
@@ -1,127 +0,0 @@
-package org.hisp.dhis.importexport.csv.converter;
-
-/*
- * 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.
- */
-
-import static org.hisp.dhis.system.util.CsvUtils.CSV_EXTENSION;
-import static org.hisp.dhis.system.util.CsvUtils.NEWLINE;
-import static org.hisp.dhis.system.util.CsvUtils.SEPARATOR_B;
-import static org.hisp.dhis.system.util.CsvUtils.csvEncode;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.SortedMap;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
-import org.hisp.dhis.importexport.CSVConverter;
-import org.hisp.dhis.importexport.ExportParams;
-import org.hisp.dhis.importexport.ImportParams;
-import org.hisp.dhis.reporttable.ReportTableData;
-import org.hisp.dhis.reporttable.ReportTableService;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class ReportTableDataConverter
-    implements CSVConverter
-{
-    private ReportTableService reportTableService;
-
-    // -------------------------------------------------------------------------
-    // Constructor
-    // -------------------------------------------------------------------------
-
-    /**
-     * Constructor for write operations.
-     * 
-     * @param reportTableService the reportTableService to use.
-     */
-    public ReportTableDataConverter( ReportTableService reportTableService )
-    {
-        this.reportTableService = reportTableService;
-    }
-
-    // -------------------------------------------------------------------------
-    // CSVConverter implementation
-    // -------------------------------------------------------------------------
-
-    public void write( ZipOutputStream out, ExportParams params )
-    {
-        try
-        {
-            for ( Integer id : params.getReportTables() )
-            {
-                out.putNextEntry( new ZipEntry( "ReportTable" + id + CSV_EXTENSION ) );
-                
-                ReportTableData data = reportTableService.getReportTableData( id, params.getFormat() );
-                
-                Iterator<String> columns = data.getPrettyPrintColumns().iterator();
-                
-                while ( columns.hasNext() )
-                {
-                    out.write( csvEncode( columns.next() ).getBytes() );
-                    
-                    if ( columns.hasNext() )
-                    {
-                        out.write( SEPARATOR_B );
-                    }
-                }
-                
-                out.write( NEWLINE );
-                
-                for ( SortedMap<Integer, String> row : data.getRows() )
-                {
-                    final Iterator<String> values = row.values().iterator();
-                    
-                    while ( values.hasNext() )
-                    {
-                        out.write( csvEncode( values.next() ).getBytes() );
-                        
-                        if ( values.hasNext() )
-                        {
-                            out.write( SEPARATOR_B );
-                        }
-                    }
-                    
-                    out.write( NEWLINE );
-                }
-            }
-        }
-        catch ( IOException ex )
-        {
-            throw new RuntimeException( "Failed to write ReportTableData CSV", ex );
-        }
-    }
-    
-    public void read( BufferedReader reader, ImportParams params )
-    {
-        // Not implemented
-    }
-}

=== removed directory 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/csv/exporter'
=== removed file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/csv/exporter/CSVExportPipeThread.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/csv/exporter/CSVExportPipeThread.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/csv/exporter/CSVExportPipeThread.java	1970-01-01 00:00:00 +0000
@@ -1,107 +0,0 @@
-package org.hisp.dhis.importexport.csv.exporter;
-
-/*
- * 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.
- */
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.zip.ZipOutputStream;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.SessionFactory;
-import org.hisp.dhis.importexport.CSVConverter;
-import org.hisp.dhis.importexport.ExportParams;
-import org.hisp.dhis.system.process.OpenSessionThread;
-import org.hisp.dhis.system.util.StreamUtils;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class CSVExportPipeThread
-    extends OpenSessionThread
-{
-    private static final Log log = LogFactory.getLog( CSVExportPipeThread.class );
-
-    private ExportParams params;
-
-    public void setParams( ExportParams params )
-    {
-        this.params = params;
-    }
-    
-    private ZipOutputStream outputStream;
-    
-    public void setOutputStream( ZipOutputStream outputStream )
-    {
-        this.outputStream = outputStream;
-    }
-
-    private List<CSVConverter> converters = new ArrayList<CSVConverter>();
-        
-    public void registerCSVConverter( CSVConverter converter )
-    {
-        this.converters.add( converter );
-    }
-
-    // -------------------------------------------------------------------------
-    // Constructor
-    // -------------------------------------------------------------------------
-    
-    public CSVExportPipeThread( SessionFactory sessionFactory )
-    {   
-        super( sessionFactory );
-    }
-    
-    // -------------------------------------------------------------------------
-    // Thread implementation
-    // -------------------------------------------------------------------------
-    
-    public void doRun()
-    {
-        try
-        {
-            log.info( "Export started" );
-            
-            for ( CSVConverter converter : converters )
-            {
-                converter.write( outputStream, params );
-            }
-            
-            log.info( "Export finished" );
-        }
-        catch ( Exception ex )
-        {
-            throw new RuntimeException( ex );
-        }
-        finally
-        {
-            StreamUtils.closeOutputStream( outputStream );
-        }
-    }
-}

=== removed file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/csv/exporter/DefaultCSVExportService.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/csv/exporter/DefaultCSVExportService.java	2010-12-25 13:58:45 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/csv/exporter/DefaultCSVExportService.java	1970-01-01 00:00:00 +0000
@@ -1,114 +0,0 @@
-package org.hisp.dhis.importexport.csv.exporter;
-
-/*
- * 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.
- */
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PipedInputStream;
-import java.io.PipedOutputStream;
-import java.util.zip.ZipOutputStream;
-
-import org.hibernate.SessionFactory;
-import org.hisp.dhis.importexport.ExportParams;
-import org.hisp.dhis.importexport.ExportService;
-import org.hisp.dhis.importexport.csv.converter.ReportTableDataConverter;
-import org.hisp.dhis.reporttable.ReportTableService;
-
-/**
- * @author Lars Helge Overland
- * @version $Id: DefaultDXFExportService.java 5960 2008-10-17 14:07:50Z larshelg $
- */
-public class DefaultCSVExportService
-    implements ExportService
-{    
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private SessionFactory sessionFactory;
-    
-    public void setSessionFactory( SessionFactory sessionFactory )
-    {
-        this.sessionFactory = sessionFactory;
-    }
-
-    private ReportTableService reportTableService;
-
-    public void setReportTableService( ReportTableService reportTableService )
-    {
-        this.reportTableService = reportTableService;
-    }
-
-    // -------------------------------------------------------------------------
-    // ExportService implementation
-    // -------------------------------------------------------------------------
-
-    public InputStream exportData( ExportParams params )
-    {
-        try
-        {
-            // -----------------------------------------------------------------
-            // Pipes are input/output pairs. Data written on the output stream 
-            // shows up on the input stream at the other end of the pipe. 
-            // -----------------------------------------------------------------
-            
-            PipedOutputStream out = new PipedOutputStream();
-            
-            PipedInputStream in = new PipedInputStream( out );
-            
-            ZipOutputStream zipOut = new ZipOutputStream( new BufferedOutputStream( out ) );
-            
-            // -----------------------------------------------------------------
-            // Writes to one end of the pipe 
-            // -----------------------------------------------------------------
-
-            CSVExportPipeThread thread = new CSVExportPipeThread( sessionFactory );
-
-            thread.setParams( params );
-            thread.setOutputStream( zipOut );
-            
-            thread.registerCSVConverter( new ReportTableDataConverter( reportTableService ) );
-            
-            thread.start();
-            
-            // -----------------------------------------------------------------
-            // Reads at the other end of the pipe 
-            // -----------------------------------------------------------------
-            
-            InputStream bis = new BufferedInputStream( in );
-            
-            return bis;
-        }
-        catch ( IOException ex )
-        {
-            throw new RuntimeException( "Error occured during export to stream", ex );
-        }
-    }
-}

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml	2010-12-23 11:56:44 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml	2010-12-26 15:38:45 +0000
@@ -31,12 +31,6 @@
 				</entry>
 				<entry>
 					<key>
-						<value>CSV</value>
-					</key>
-					<ref bean="org.hisp.dhis.importexport.CSVExportService" />
-				</entry>
-				<entry>
-					<key>
 						<value>XLS</value>
 					</key>
 					<ref bean="org.hisp.dhis.importexport.XLSExportService" />
@@ -364,16 +358,6 @@
 	</bean>
 
 	<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
-	<!-- CSV Export                                           -->
-	<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
-
-	<bean id="org.hisp.dhis.importexport.CSVExportService"
-		class="org.hisp.dhis.importexport.csv.exporter.DefaultCSVExportService">
-		<property name="sessionFactory" ref="sessionFactory"/>
-		<property name="reportTableService" ref="org.hisp.dhis.reporttable.ReportTableService" />
-	</bean>
-
-	<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
 	<!-- XLS Export                                                    -->
 	<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
 

=== 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	2010-12-13 16:32:50 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java	2010-12-26 15:38:45 +0000
@@ -40,6 +40,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.aggregation.AggregatedDataValueService;
 import org.hisp.dhis.common.GenericIdentifiableObjectStore;
+import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.completeness.DataSetCompletenessService;
 import org.hisp.dhis.dataelement.DataElement;
@@ -57,10 +58,8 @@
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.report.ReportService;
 import org.hisp.dhis.reporttable.ReportTable;
-import org.hisp.dhis.reporttable.ReportTableData;
 import org.hisp.dhis.reporttable.ReportTableService;
 import org.hisp.dhis.reporttable.jdbc.ReportTableManager;
-import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.system.grid.ListGrid;
 import org.hisp.dhis.system.util.Filter;
 import org.hisp.dhis.system.util.FilterUtils;
@@ -78,7 +77,7 @@
     private static final String NULL_REPLACEMENT = "0.0";
     private static final String MODE_REPORT = "report";
     private static final String MODE_REPORT_TABLE = "table";
-
+    
     // ---------------------------------------------------------------------
     // Dependencies
     // ---------------------------------------------------------------------
@@ -365,14 +364,33 @@
     }
 
     @Transactional
-    public ReportTableData getReportTableData( int id, I18nFormat format )
+    public Grid getPrettyReportTableGrid( int id, I18nFormat format )
     {
         ReportTable reportTable = getReportTable( id );
         
         reportTable.setI18nFormat( format );
         reportTable.init();
         
-        return reportTableManager.getDisplayReportTableData( reportTable );
+        Grid grid = reportTableManager.getReportTableGrid( reportTable );
+        
+        grid.setTitle( reportTable.getName() );        
+                
+        for ( String col : ReportTable.DB_COLUMNS )
+        {
+            grid.removeColumn( col );
+        }
+        
+        for ( String col : ReportTable.PRETTY_COLUMNS.keySet() )
+        {
+            grid.replaceHeader( col, ReportTable.PRETTY_COLUMNS.get( col ) );
+        }
+        
+        for ( String col : reportTable.getPrettyCrossTabColumns().keySet() )
+        {
+            grid.replaceHeader( col, reportTable.getPrettyCrossTabColumns().get( col ) );
+        }
+        
+        return grid;
     }
     
     public boolean reportTableIsGenerated( int id )

=== 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	2010-10-29 14:37:54 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/JDBCReportTableManager.java	2010-12-26 15:38:45 +0000
@@ -32,26 +32,23 @@
 import java.sql.ResultSet;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.SortedMap;
-import java.util.TreeMap;
 
 import org.amplecode.quick.StatementHolder;
 import org.amplecode.quick.StatementManager;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.jdbc.StatementBuilder;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.reporttable.ReportTable;
-import org.hisp.dhis.reporttable.ReportTableColumn;
-import org.hisp.dhis.reporttable.ReportTableData;
 import org.hisp.dhis.reporttable.statement.CreateReportTableStatement;
-import org.hisp.dhis.reporttable.statement.DisplayReportTableStatement;
 import org.hisp.dhis.reporttable.statement.GetReportTableDataStatement;
 import org.hisp.dhis.reporttable.statement.RemoveReportTableStatement;
 import org.hisp.dhis.reporttable.statement.ReportTableStatement;
+import org.hisp.dhis.system.grid.ListGrid;
 
 /**
  * @author Lars Helge Overland
@@ -204,74 +201,23 @@
         }
     }
     
-    public ReportTableData getDisplayReportTableData( ReportTable reportTable )
+    public Grid getReportTableGrid( ReportTable reportTable )
     {
-        ReportTableData data = new ReportTableData();
-        
-        // ---------------------------------------------------------------------
-        // Set name
-        // ---------------------------------------------------------------------
-
-        data.setName( reportTable.getName() );
-
-        ReportTableStatement statement = new DisplayReportTableStatement( reportTable );
-        
         StatementHolder holder = statementManager.getHolder();
-
+        
         try
         {
-            log.debug( "Get display report table data statement: " + statement.getStatement() );
-            
-            ResultSet resultSet = holder.getStatement().executeQuery( statement.getStatement() );
-            
-            // -----------------------------------------------------------------
-            // Set columns
-            // -----------------------------------------------------------------
-
-            int index = 1;
-            
-            for ( ReportTableColumn column : reportTable.getFilledDisplayColumns() )
-            {
-                if ( !column.isHidden() )
-                {
-                    data.getColumns().put( index++, column.getName() );
-                
-                    data.getPrettyPrintColumns().add( column.getHeader() );
-                }
-            }
-
-            // -----------------------------------------------------------------
-            // Set data
-            // -----------------------------------------------------------------
-
-            while ( resultSet.next() )
-            {
-                SortedMap<Integer, String> row = new TreeMap<Integer, String>();
-                
-                index = 1;
-                
-                for ( ReportTableColumn column : reportTable.getFilledDisplayColumns() )
-                {
-                    if ( !column.isHidden() )
-                    {
-                        row.put( index++, String.valueOf( resultSet.getObject( column.getName() ) ) );
-                    }
-                }
-                
-                data.getRows().add( row );
-            }
-            
-            log.debug( "Number of rows: " + data.getRows().size() );
+            ResultSet resultSet = holder.getStatement().executeQuery( "SELECT * FROM " + reportTable.getExistingTableName() );
+            
+            return new ListGrid().fromResultSet( resultSet );
         }
         catch ( Exception ex )
         {
-            throw new RuntimeException( "Failed to get display report table data", ex );
+            throw new RuntimeException( "Failed to get report table data grid", ex );
         }
         finally
         {
             holder.close();
         }
-        
-        return data;
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/ReportTableManager.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/ReportTableManager.java	2010-10-29 14:37:54 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/ReportTableManager.java	2010-12-26 15:38:45 +0000
@@ -29,12 +29,12 @@
 
 import java.util.Map;
 
+import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.reporttable.ReportTable;
-import org.hisp.dhis.reporttable.ReportTableData;
 
 /**
  * @author Lars Helge Overland
@@ -80,11 +80,11 @@
         DataElementCategoryOptionCombo categoryOptionCombo, Period period, OrganisationUnit unit );
     
     /**
-     * Returns a ReportTableData object based on the registered ReportTableColumns
-     * for the given ReportTable.
-     *  
+     * Instantiates and populates a Grid populated with data from the given 
+     * ReportTable.
+     * 
      * @param reportTable the ReportTable.
-     * @return a ReportTableData object.
+     * @return a Grid.
      */
-    ReportTableData getDisplayReportTableData( ReportTable reportTable );
+    Grid getReportTableGrid( ReportTable reportTable );    
 }

=== removed file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement/DisplayReportTableStatement.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement/DisplayReportTableStatement.java	2010-10-29 14:37:54 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement/DisplayReportTableStatement.java	1970-01-01 00:00:00 +0000
@@ -1,73 +0,0 @@
-package org.hisp.dhis.reporttable.statement;
-
-/*
- * 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.
- */
-
-import java.util.Iterator;
-
-import org.hisp.dhis.reporttable.ReportTable;
-import org.hisp.dhis.reporttable.ReportTableColumn;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class DisplayReportTableStatement
-    extends ReportTableStatement
-{
-    // -------------------------------------------------------------------------
-    // Constructor
-    // -------------------------------------------------------------------------
-
-    public DisplayReportTableStatement( ReportTable reportTable )
-    {
-        super( reportTable );
-    }
-
-    // -------------------------------------------------------------------------
-    // ReportTableStatement implementation
-    // -------------------------------------------------------------------------
-
-    @Override
-    protected void init( ReportTable reportTable )
-    {
-        StringBuffer buffer = new StringBuffer( "SELECT " );
-        
-        Iterator<ReportTableColumn> columns = reportTable.getFilledDisplayColumns().iterator();
-        
-        while ( columns.hasNext() )
-        {
-            ReportTableColumn column = columns.next();
-            
-            buffer.append( column.getName() + ( columns.hasNext() ? SEPARATOR : SPACE ) );
-        }
-        
-        buffer.append( "FROM " + reportTable.getExistingTableName() );
-        
-        statement = buffer.toString();
-    }
-}

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/WorkbookService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/WorkbookService.java	2010-12-25 16:43:02 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/WorkbookService.java	2010-12-26 15:38:45 +0000
@@ -46,8 +46,6 @@
 {
     String ID = WorkbookService.class.getName();
     
-    String writeReportTableData( OutputStream outputStream, int id, I18nFormat format );
-    
     void writeDataSetCompletenessResult( Collection<DataSetCompletenessResult> results, OutputStream out, I18n i18n, OrganisationUnit unit, DataSet dataSet );
     
     void writeValidationResult( List<ValidationResult> results, OutputStream out, I18n i18n, I18nFormat format );

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/impl/JExcelWorkbookService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/impl/JExcelWorkbookService.java	2010-12-25 16:43:02 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/impl/JExcelWorkbookService.java	2010-12-26 15:38:45 +0000
@@ -27,13 +27,10 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.system.util.MathUtils.isNumeric;
-
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.Collection;
 import java.util.List;
-import java.util.SortedMap;
 
 import jxl.Workbook;
 import jxl.write.Label;
@@ -51,8 +48,6 @@
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.period.Period;
-import org.hisp.dhis.reporttable.ReportTableData;
-import org.hisp.dhis.reporttable.ReportTableService;
 import org.hisp.dhis.system.util.DateUtils;
 import org.hisp.dhis.validation.ValidationResult;
 import org.hisp.dhis.workbook.WorkbookService;
@@ -67,89 +62,9 @@
     implements WorkbookService
 {
     // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private ReportTableService reportTableService;
-
-    public void setReportTableService( ReportTableService reportTableService )
-    {
-        this.reportTableService = reportTableService;
-    }
-
-    // -------------------------------------------------------------------------
-    // Properties
-    // -------------------------------------------------------------------------
-
-    private static final WritableCellFormat FORMAT_TTTLE = new WritableCellFormat( new WritableFont(
-        WritableFont.TAHOMA, 13, WritableFont.NO_BOLD, false ) );
-
-    private static final WritableCellFormat FORMAT_LABEL = new WritableCellFormat( new WritableFont(
-        WritableFont.ARIAL, 11, WritableFont.NO_BOLD, true ) );
-
-    private static final WritableCellFormat FORMAT_TEXT = new WritableCellFormat( new WritableFont( WritableFont.ARIAL,
-        11, WritableFont.NO_BOLD, false ) );
-
-    // -------------------------------------------------------------------------
     // WorkbookService implementation
     // -------------------------------------------------------------------------
 
-    public String writeReportTableData( OutputStream outputStream, int id, I18nFormat format )
-    {
-        ReportTableData data = reportTableService.getReportTableData( id, format );
-
-        try
-        {
-            WritableWorkbook workbook = Workbook.createWorkbook( outputStream );
-
-            WritableSheet sheet = workbook.createSheet( "Report table data", 0 );
-
-            int rowNumber = 1;
-
-            int columnIndex = 0;
-
-            sheet.addCell( new Label( 0, rowNumber++, data.getName(), FORMAT_TTTLE ) );
-
-            rowNumber++;
-
-            for ( String column : data.getPrettyPrintColumns() )
-            {
-                sheet.addCell( new Label( columnIndex++, rowNumber, column, FORMAT_LABEL ) );
-            }
-
-            rowNumber++;
-
-            for ( SortedMap<Integer, String> row : data.getRows() )
-            {
-                columnIndex = 0;
-
-                for ( String value : row.values() )
-                {
-                    if ( isNumeric( value ) )
-                    {
-                        sheet.addCell( new Number( columnIndex++, rowNumber, Double.valueOf( value ), FORMAT_TEXT ) );
-                    }
-                    else
-                    {
-                        sheet.addCell( new Label( columnIndex++, rowNumber, value, FORMAT_TEXT ) );
-                    }
-                }
-
-                rowNumber++;
-            }
-
-            workbook.write();
-
-            workbook.close();
-        }
-        catch ( Exception ex )
-        {
-            throw new RuntimeException( "Failed to generate workbook for data elements", ex );
-        }
-
-        return data.getName();
-    }
-
     public void writeDataSetCompletenessResult( Collection<DataSetCompletenessResult> results, OutputStream out,
         I18n i18n, OrganisationUnit unit, DataSet dataSet )
     {

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml	2010-12-25 16:43:02 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml	2010-12-26 15:38:45 +0000
@@ -205,10 +205,7 @@
   <!-- Workbook -->
   
   <bean id="org.hisp.dhis.workbook.WorkbookService"
-    class="org.hisp.dhis.workbook.impl.JExcelWorkbookService">   
-    <property name="reportTableService"
-      ref="org.hisp.dhis.reporttable.ReportTableService"/>
-  </bean>
+    class="org.hisp.dhis.workbook.impl.JExcelWorkbookService"/>
   
   <!-- PivotTable -->
   

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml	2010-06-23 17:50:25 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml	2010-12-26 15:38:45 +0000
@@ -97,12 +97,5 @@
       <property name="paramOrganisationUnit"/>
     </component>
     
-    <list name="displayColumns" table="reporttable_displaycolumns" cascade="all-delete-orphan">
-      <key column="reporttableid"/>
-      <list-index column="sort_order" base="0"/>
-      <many-to-many column="reporttablecolumnid"
-        class="org.hisp.dhis.reporttable.ReportTableColumn"/>
-    </list>
-    
   </class>
 </hibernate-mapping>

=== removed file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTableColumn.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTableColumn.hbm.xml	2009-05-18 20:04:49 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTableColumn.hbm.xml	1970-01-01 00:00:00 +0000
@@ -1,18 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
-  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd";>
-
-<hibernate-mapping>
-  <class name="org.hisp.dhis.reporttable.ReportTableColumn" table="reporttablecolumn">
-  
-    <id name="id" column="reporttablecolumnid">
-      <generator class="native"/>
-    </id>
-    
-    <property name="name"/>
-    <property name="header"/>
-    <property name="hidden"/>
-    
-  </class>
-</hibernate-mapping>

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableTest.java	2010-06-21 14:17:13 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableTest.java	2010-12-26 15:38:45 +0000
@@ -260,11 +260,6 @@
         
         assertNotNull( prettyCrossTabColumns );
         assertEquals( 8, prettyCrossTabColumns.size() );
-        
-        List<ReportTableColumn> filledDisplayColumns = reportTable.getFilledDisplayColumns();
-        
-        assertNotNull( filledDisplayColumns );
-        assertEquals( reportTable.getAllColumns().size(), filledDisplayColumns.size() );
     }
 
     @Test
@@ -319,11 +314,6 @@
         
         assertNotNull( prettyCrossTabColumns );
         assertEquals( 2, prettyCrossTabColumns.size() );
-        
-        List<ReportTableColumn> filledDisplayColumns = reportTable.getFilledDisplayColumns();
-        
-        assertNotNull( filledDisplayColumns );
-        assertEquals( reportTable.getAllColumns().size(), filledDisplayColumns.size() );
     }
 
     @Test
@@ -382,11 +372,6 @@
         
         assertNotNull( prettyCrossTabColumns );
         assertEquals( 4, prettyCrossTabColumns.size() );
-        
-        List<ReportTableColumn> filledDisplayColumns = reportTable.getFilledDisplayColumns();
-        
-        assertNotNull( filledDisplayColumns );
-        assertEquals( reportTable.getAllColumns().size(), filledDisplayColumns.size() );
     }
 
     @Test
@@ -449,11 +434,6 @@
         
         assertNotNull( prettyCrossTabColumns );
         assertEquals( 8, prettyCrossTabColumns.size() );
-        
-        List<ReportTableColumn> filledDisplayColumns = reportTable.getFilledDisplayColumns();
-        
-        assertNotNull( filledDisplayColumns );
-        assertEquals( reportTable.getAllColumns().size(), filledDisplayColumns.size() );
     }
 
     @Test
@@ -509,11 +489,6 @@
         
         assertNotNull( prettyCrossTabColumns );
         assertEquals( 2, prettyCrossTabColumns.size() );
-        
-        List<ReportTableColumn> filledDisplayColumns = reportTable.getFilledDisplayColumns();
-        
-        assertNotNull( filledDisplayColumns );
-        assertEquals( reportTable.getAllColumns().size(), filledDisplayColumns.size() );
     }
 
     @Test
@@ -572,11 +547,6 @@
         
         assertNotNull( prettyCrossTabColumns );
         assertEquals( 4, prettyCrossTabColumns.size() );
-        
-        List<ReportTableColumn> filledDisplayColumns = reportTable.getFilledDisplayColumns();
-        
-        assertNotNull( filledDisplayColumns );
-        assertEquals( reportTable.getAllColumns().size(), filledDisplayColumns.size() );
     }
 
     @Test
@@ -653,11 +623,6 @@
         
         assertNotNull( prettyCrossTabColumns );
         assertEquals( 16, prettyCrossTabColumns.size() );
-        
-        List<ReportTableColumn> filledDisplayColumns = reportTable.getFilledDisplayColumns();
-        
-        assertNotNull( filledDisplayColumns );
-        assertEquals( reportTable.getAllColumns().size(), filledDisplayColumns.size() );
     }
 
     @Test
@@ -718,11 +683,6 @@
         
         assertNotNull( prettyCrossTabColumns );
         assertEquals( 4, prettyCrossTabColumns.size() );
-        
-        List<ReportTableColumn> filledDisplayColumns = reportTable.getFilledDisplayColumns();
-        
-        assertNotNull( filledDisplayColumns );
-        assertEquals( reportTable.getAllColumns().size(), filledDisplayColumns.size() );
     }
 
     @Test
@@ -790,11 +750,6 @@
         
         assertNotNull( prettyCrossTabColumns );
         assertEquals( 8, prettyCrossTabColumns.size() );
-        
-        List<ReportTableColumn> filledDisplayColumns = reportTable.getFilledDisplayColumns();
-        
-        assertNotNull( filledDisplayColumns );
-        assertEquals( reportTable.getAllColumns().size(), filledDisplayColumns.size() );
     }
 
     @Test
@@ -849,11 +804,6 @@
         
         assertNotNull( prettyCrossTabColumns );
         assertEquals( 2, prettyCrossTabColumns.size() );
-        
-        List<ReportTableColumn> filledDisplayColumns = reportTable.getFilledDisplayColumns();
-        
-        assertNotNull( filledDisplayColumns );
-        assertEquals( reportTable.getAllColumns().size(), filledDisplayColumns.size() );
     }
 
     @Test
@@ -912,10 +862,5 @@
         
         assertNotNull( prettyCrossTabColumns );
         assertEquals( 4, prettyCrossTabColumns.size() );
-        
-        List<ReportTableColumn> filledDisplayColumns = reportTable.getFilledDisplayColumns();
-        
-        assertNotNull( filledDisplayColumns );
-        assertEquals( reportTable.getAllColumns().size(), filledDisplayColumns.size() );
     }
 }

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/ListGrid.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/ListGrid.java	2010-12-22 09:29:03 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/ListGrid.java	2010-12-26 15:38:45 +0000
@@ -29,6 +29,9 @@
 
 import static org.hisp.dhis.system.util.MathUtils.getRounded;
 
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -48,6 +51,11 @@
     private String title;
     
     /**
+     * The subtitle of the grid.
+     */
+    private String subtitle;
+    
+    /**
      * A List which represents the column headers of the grid.
      */
     private List<String> headers;
@@ -81,9 +89,23 @@
         return title;
     }
 
-    public void setTitle( String title )
+    public Grid setTitle( String title )
     {
         this.title = title;
+        
+        return this;
+    }
+
+    public String getSubtitle()
+    {
+        return subtitle;
+    }
+
+    public Grid setSubtitle( String subtitle )
+    {
+        this.subtitle = subtitle;
+        
+        return this;
     }
 
     public List<String> getHeaders()
@@ -91,9 +113,21 @@
         return headers;
     }
     
-    public void addHeader( String value )
+    public Grid addHeader( String value )
     {
         headers.add( value );
+        
+        return this;
+    }
+    
+    public Grid replaceHeader( String currentHeader, String newHeader )
+    {
+        if ( headers.contains( currentHeader ) )
+        {
+            headers.set( headers.indexOf( currentHeader ), newHeader );
+        }
+        
+        return this;
     }
     
     public int getHeight()
@@ -108,16 +142,20 @@
         return ( grid != null && grid.size() > 0 ) ? grid.get( 0 ).size() : 0;
     }
     
-    public void nextRow()
+    public Grid nextRow()
     {
         grid.add( new ArrayList<String>() );
         
         currentRowIndex++;
+        
+        return this;
     }
     
-    public void addValue( String value )
+    public Grid addValue( String value )
     {
         grid.get( currentRowIndex ).add( value );
+        
+        return this;
     }
     
     public List<String> getRow( int rowIndex )
@@ -152,7 +190,7 @@
         return grid.get( rowIndex ).get( columnIndex );
     }
     
-    public void addColumn( List<String> columnValues )
+    public Grid addColumn( List<String> columnValues )
     {
         verifyGridState();
         
@@ -168,9 +206,40 @@
         {
             grid.get( rowIndex++ ).add( columnValues.get( columnIndex++ ) );
         }
-    }
-    
-    public void addRegressionColumn( int columnIndex )
+        
+        return this;
+    }
+    
+    public Grid removeColumn( int columnIndex )
+    {
+        verifyGridState();
+        
+        if ( headers.size() > 0 )
+        {
+            headers.remove( columnIndex );
+        }
+        
+        for ( List<String> row : grid )
+        {
+            row.remove( columnIndex );
+        }
+        
+        return this;
+    }
+    
+    public Grid removeColumn( String header )
+    {
+        int index = headers.indexOf( header );
+        
+        if ( index != -1 )
+        {
+            removeColumn( index );
+        }
+        
+        return this;
+    }
+    
+    public Grid addRegressionColumn( int columnIndex )
     {
         verifyGridState();
         
@@ -209,6 +278,36 @@
         }
 
         addColumn( regressionColumn );
+        
+        return this;
+    }
+    
+    public Grid fromResultSet( ResultSet resultSet )
+        throws SQLException
+    {
+        headers = new ArrayList<String>();
+        grid = new ArrayList<List<String>>();
+                
+        ResultSetMetaData metaData = resultSet.getMetaData();
+        
+        int cols = metaData.getColumnCount();
+        
+        for ( int i = 0; i < cols; i++ )
+        {
+            this.addHeader( String.valueOf( metaData.getColumnName( i + 1 ) ) );
+        }
+        
+        while ( resultSet.next() )
+        {
+            this.nextRow();
+            
+            for ( int i = 0; i < cols; i++ )
+            {
+                this.addValue( String.valueOf( resultSet.getObject( i + 1 ) ) );
+            }
+        }
+        
+        return this;
     }
 
     // ---------------------------------------------------------------------
@@ -216,7 +315,8 @@
     // ---------------------------------------------------------------------
 
     /**
-     * Verifies that all grid rows are of the same length.
+     * Verifies that all grid rows are of the same length, and that the number
+     * of headers is the same as number of columns or 0.
      */
     private void verifyGridState()
     {
@@ -231,6 +331,11 @@
             
             rowLength = row.size();
         }
+        
+        if ( rowLength != null && headers.size() != 0 && headers.size() != rowLength )
+        {
+            throw new IllegalStateException( "Number of headers is not 0 and not equal to the number of columns" );
+        }
     }
 
     // ---------------------------------------------------------------------

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/CodecUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/CodecUtils.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/CodecUtils.java	2010-12-26 15:38:45 +0000
@@ -48,6 +48,8 @@
     private static final String EMPTY_REPLACEMENT = "_";
     private static final String REGEX_NUMERIC = "([0-9]*)";
     private static final String SEPARATOR = "_";
+    
+    private static final String ILLEGAL_FILENAME_CHARS_REGEX = "[/\\?%*:|\"<>.]";
 
     /**
      * Encrypts a string with Base64 encoding.
@@ -91,74 +93,6 @@
         }
     }
     
-    /*
-    //TODO This is not the correct way of encoding values
-    
-    public static String unescape( String s )
-    {
-        StringBuffer sbuf = new StringBuffer();
-        int l = s.length();
-        int ch = -1;
-        int b, sumb = 0;
-        for ( int i = 0, more = -1; i < l; i++ )
-        {
-            switch ( ch = s.charAt( i ) )
-            {
-                case '%':
-                    ch = s.charAt( ++i );
-                    int hb = (Character.isDigit( (char) ch ) ? ch - '0' : 10 + Character.toLowerCase( (char) ch ) - 'a') & 0xF;
-                    ch = s.charAt( ++i );
-                    int lb = (Character.isDigit( (char) ch ) ? ch - '0' : 10 + Character.toLowerCase( (char) ch ) - 'a') & 0xF;
-                    b = (hb << 4) | lb;
-                    break;
-                case '+':
-                    b = ' ';
-                    break;
-                default:
-                    b = ch;
-            }
-            
-            if ( (b & 0xc0) == 0x80 )
-            { // 10xxxxxx (continuation byte)
-                sumb = (sumb << 6) | (b & 0x3f); // Add 6 bits to sumb
-                if ( --more == 0 )
-                    sbuf.append( (char) sumb ); // Add char to sbuf
-            }
-            else if ( (b & 0x80) == 0x00 )
-            { // 0xxxxxxx (yields 7 bits)
-                sbuf.append( (char) b ); // Store in sbuf
-            }
-            else if ( (b & 0xe0) == 0xc0 )
-            { // 110xxxxx (yields 5 bits)
-                sumb = b & 0x1f;
-                more = 1; // Expect 1 more byte
-            }
-            else if ( (b & 0xf0) == 0xe0 )
-            { // 1110xxxx (yields 4 bits)
-                sumb = b & 0x0f;
-                more = 2; // Expect 2 more bytes
-            }
-            else if ( (b & 0xf8) == 0xf0 )
-            { // 11110xxx (yields 3 bits)
-                sumb = b & 0x07;
-                more = 3; // Expect 3 more bytes
-            }
-            else if ( (b & 0xfc) == 0xf8 )
-            { // 111110xx (yields 2 bits)
-                sumb = b & 0x03;
-                more = 4; // Expect 4 more bytes
-            }
-            else
-            //if ((b & 0xfe) == 0xfc) { // 1111110x (yields 1 bit)
-                sumb = b & 0x01;
-                more = 5; // Expect 5 more bytes
-            }
-        }
-        
-        return sbuf.toString();
-    }
-    */
-
     /**
      * Database encodes the argument string. Remove non-character data from the
      * string, prefixes the string if it starts with a numeric character and
@@ -213,4 +147,20 @@
         
         return string;
     }
+    
+    public static String filenameEncode( String string )
+    {
+        if ( string != null )
+        {
+            string = string.replaceAll( ILLEGAL_FILENAME_CHARS_REGEX, "" );
+            
+            if ( string.length() > 255 )
+            {
+                string = string.substring( 0, 255 );
+            }
+        }
+        
+        return string;
+    }
 }
+

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/grid/GridTest.java'
--- dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/grid/GridTest.java	2010-12-22 09:16:14 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/grid/GridTest.java	2010-12-26 15:38:45 +0000
@@ -48,6 +48,10 @@
     {
         grid = new ListGrid();
 
+        grid.addHeader( "col1" );
+        grid.addHeader( "col2" );
+        grid.addHeader( "col3" );
+        
         grid.nextRow();        
         grid.addValue( "11" );
         grid.addValue( "12" );
@@ -77,6 +81,17 @@
     }
     
     @Test
+    public void testReplaceHeader()
+    {
+        assertTrue( grid.getHeaders().contains( "col2" ) );
+        
+        grid.replaceHeader( "col2", "Column2" );
+
+        assertFalse( grid.getHeaders().contains( "col2" ) );
+        assertTrue( grid.getHeaders().contains( "Column2" ) );
+    }
+    
+    @Test
     public void testGetRow()
     {
         List<String> rowA = grid.getRow( 0 );
@@ -145,6 +160,26 @@
     }
     
     @Test
+    public void testRemoveColumn()
+    {
+        assertEquals( 3, grid.getWidth() );
+        
+        grid.removeColumn( 2 );
+        
+        assertEquals( 2, grid.getWidth() );
+    }
+    
+    @Test
+    public void testRemoveColumnByHeader()
+    {
+        assertEquals( 3, grid.getWidth() );
+        
+        grid.removeColumn( "col2" );
+        
+        assertEquals( 2, grid.getWidth() );
+    }
+    
+    @Test
     public void testAddRegressionColumn()
     {
         grid = new ListGrid();        

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/CodecUtilsTest.java'
--- dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/CodecUtilsTest.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/CodecUtilsTest.java	2010-12-26 15:38:45 +0000
@@ -27,22 +27,33 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import junit.framework.TestCase;
+import org.junit.Test;
+
+import static junit.framework.Assert.*;
 
 /**
  * @author Lars Helge Overland
  * @version $Id$
  */
 public class CodecUtilsTest
-    extends TestCase
 {
+    @Test
     public void testEncrypt()
     {
         assertEquals( "ZGhpcw==", CodecUtils.encryptBase64( "dhis" ) );
     }
-    
+
+    @Test
     public void testDecrypt()
     {
         assertEquals( "dhis", CodecUtils.decryptBase64( "ZGhpcw==" ) );
     }
+    
+    @Test
+    public void testFilenameEncode()
+    {
+        assertEquals( "foobar", CodecUtils.filenameEncode( "foo?%*bar" ) );
+        assertEquals( "foobar", CodecUtils.filenameEncode( "%foo/:|bar<>" ) );
+        assertEquals( "foobar", CodecUtils.filenameEncode( "?foo.bar/" ) );
+    }
 }

=== added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/htmlGrid.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/htmlGrid.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/htmlGrid.vm	2010-12-26 15:38:45 +0000
@@ -0,0 +1,38 @@
+<style type="text/css">
+.gridTable th, .gridTable td
+{
+  text-align: center;
+  width: 150px;
+}
+
+.gridLeft td
+{
+  text-align: left;
+}
+</style>
+
+<h3>$!encoder.htmlEncode( $grid.title )</h3>
+
+<h5>$!encoder.htmlEncode( $grid.subtitle )</h5>
+
+<table class="listTable gridTable">
+
+<thead>
+<tr>
+#foreach( $header in $grid.getHeaders() )
+<th>$!encoder.htmlEncode( $header )</th>
+#end
+</tr>
+</thead>
+
+<tbody>
+#foreach( $row in $grid.getRows() )
+<tr>
+#foreach( $col in $row )
+<td #if( $velocityCount == 1 )style="text-align:left"#end>$!encoder.htmlEncode( $col )</td>
+#end
+</tr>
+#end
+</tbody>
+
+</table>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm	2010-12-03 05:41:34 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm	2010-12-26 15:38:45 +0000
@@ -35,11 +35,9 @@
     <script type="text/javascript" src="../dhis-web-commons/javascripts/commons.ajax.js"></script>
     <script type="text/javascript" src="../dhis-web-commons/javascripts/lists.js"></script>
     <script type="text/javascript" src="../dhis-web-commons/javascripts/date.js"></script>
-	
-	
+		
     <script type="text/javascript" src="../dhis-web-commons/css/${stylesheetDirectory}/dom.js"></script>
-	
-	
+		
     <script type="text/javascript" src="../main.js"></script>
   
     <script type="text/javascript" src="../request.js"></script>
@@ -47,24 +45,6 @@
       <script type="text/javascript" src="$javascript"></script>
     #end
 	
-	<script>
-		jQuery(document).ready( function()
-		{
-			jQuery.each(jQuery(":button, :submit"), function(i, item){
-				jQuery( item ).addClass( 'button' );
-			});
-			
-			jQuery.each(jQuery(":text, textarea, :password"), function(i, item){
-				jQuery( item ).addClass( 'text' );
-			});
-			
-			jQuery.each(jQuery("select"), function(i, item){
-				jQuery( item ).addClass( 'combobox' );
-			});			
-			
-		});
-	</script>
-
   </head>
   
   <body>

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/help/action/GetHelpContentAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/help/action/GetHelpContentAction.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/help/action/GetHelpContentAction.java	2010-12-26 15:38:45 +0000
@@ -32,6 +32,7 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.hisp.dhis.options.help.HelpManager;
+import org.hisp.dhis.util.ContextUtils;
 import org.hisp.dhis.util.StreamActionSupport;
 
 /**
@@ -66,7 +67,7 @@
     @Override
     protected String getContentType()
     {
-        return CONTENT_TYPE_HTML;
+        return ContextUtils.CONTENT_TYPE_HTML;
     }
 
     @Override

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/help/action/GetHelpItemsAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/help/action/GetHelpItemsAction.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/help/action/GetHelpItemsAction.java	2010-12-26 15:38:45 +0000
@@ -32,6 +32,7 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.hisp.dhis.options.help.HelpManager;
+import org.hisp.dhis.util.ContextUtils;
 import org.hisp.dhis.util.StreamActionSupport;
 
 /**
@@ -59,7 +60,7 @@
     @Override
     protected String getContentType()
     {
-        return CONTENT_TYPE_HTML;
+        return ContextUtils.CONTENT_TYPE_HTML;
     }
 
     @Override

=== added file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridCsvResult.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridCsvResult.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridCsvResult.java	2010-12-26 15:38:45 +0000
@@ -0,0 +1,129 @@
+package org.hisp.dhis.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.
+ */
+
+import java.io.OutputStream;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.struts2.ServletActionContext;
+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;
+
+import static org.hisp.dhis.system.util.CsvUtils.*;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class GridCsvResult
+    implements Result
+{
+    private static final String DEFAULT_FILENAME = "Grid.csv";
+
+    // -------------------------------------------------------------------------
+    // 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();
+
+        OutputStream out = response.getOutputStream();
+
+        String filename = CodecUtils.filenameEncode( StringUtils.defaultIfEmpty( grid.getTitle(), DEFAULT_FILENAME ) ) + ".csv";
+        
+        ContextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_TEXT, true, filename );
+
+        // ---------------------------------------------------------------------
+        // Write CSV to output stream
+        // ---------------------------------------------------------------------
+
+        Iterator<String> headers = grid.getHeaders().iterator();
+        
+        while ( headers.hasNext() )
+        {
+            out.write( csvEncode( headers.next() ).getBytes() );
+            
+            if ( headers.hasNext() )
+            {
+                out.write( SEPARATOR_B );
+            }
+        }
+
+        out.write( NEWLINE );
+        
+        for ( List<String> row : grid.getRows() )
+        {
+            Iterator<String> columns = row.iterator();
+            
+            while ( columns.hasNext() )
+            {
+                out.write( csvEncode( columns.next() ).getBytes() );
+                
+                if ( columns.hasNext() )
+                {
+                    out.write( SEPARATOR_B );
+                }
+            }
+            
+            out.write( NEWLINE );
+        }
+    }
+}

=== added file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridXlsResult.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridXlsResult.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridXlsResult.java	2010-12-26 15:38:45 +0000
@@ -0,0 +1,159 @@
+package org.hisp.dhis.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.
+ */
+
+import static org.hisp.dhis.system.util.MathUtils.isNumeric;
+
+import java.io.OutputStream;
+import java.util.List;
+
+import javax.servlet.http.HttpServletResponse;
+
+import jxl.Workbook;
+import jxl.write.Label;
+import jxl.write.Number;
+import jxl.write.WritableCellFormat;
+import jxl.write.WritableFont;
+import jxl.write.WritableSheet;
+import jxl.write.WritableWorkbook;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.struts2.ServletActionContext;
+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;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class GridXlsResult
+    implements Result
+{
+    private static final String DEFAULT_SHEET_NAME = "Sheet 1";
+    private static final String DEFAULT_FILENAME = "Grid.xls";
+    
+    private static final WritableCellFormat FORMAT_TTTLE = new WritableCellFormat( new WritableFont(
+        WritableFont.TAHOMA, 13, WritableFont.NO_BOLD, false ) );
+
+    private static final WritableCellFormat FORMAT_LABEL = new WritableCellFormat( new WritableFont(
+        WritableFont.ARIAL, 11, WritableFont.NO_BOLD, true ) );
+
+    private static final WritableCellFormat FORMAT_TEXT = new WritableCellFormat( new WritableFont( WritableFont.ARIAL,
+        11, WritableFont.NO_BOLD, false ) );
+
+    // -------------------------------------------------------------------------
+    // 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();
+
+        OutputStream out = response.getOutputStream();
+
+        String filename = CodecUtils.filenameEncode( StringUtils.defaultIfEmpty( grid.getTitle(), DEFAULT_FILENAME ) ) + ".xls";
+                
+        ContextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_EXCEL, true, filename );
+        
+        // ---------------------------------------------------------------------
+        // Create workbook and write to output stream
+        // ---------------------------------------------------------------------
+
+        WritableWorkbook workbook = Workbook.createWorkbook( out );
+
+        String sheetName = StringUtils.defaultIfEmpty( grid.getTitle(), DEFAULT_SHEET_NAME );
+        
+        WritableSheet sheet = workbook.createSheet( sheetName, 0 );
+
+        int rowNumber = 1;
+
+        int columnIndex = 0;
+
+        sheet.addCell( new Label( 0, rowNumber++, grid.getTitle(), FORMAT_TTTLE ) );
+
+        rowNumber++;
+
+        for ( String header : grid.getHeaders() )
+        {
+            sheet.addCell( new Label( columnIndex++, rowNumber, header, FORMAT_LABEL ) );
+        }
+
+        rowNumber++;
+
+        for ( List<String> row : grid.getRows() )
+        {
+            columnIndex = 0;
+
+            for ( String column : row )
+            {
+                if ( isNumeric( column ) )
+                {
+                    sheet.addCell( new Number( columnIndex++, rowNumber, Double.valueOf( column ), FORMAT_TEXT ) );
+                }
+                else
+                {
+                    sheet.addCell( new Label( columnIndex++, rowNumber, column, FORMAT_TEXT ) );
+                }
+            }
+
+            rowNumber++;
+        }
+
+        workbook.write();
+
+        workbook.close();        
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/ContextUtils.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/ContextUtils.java	2010-10-21 14:24:15 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/ContextUtils.java	2010-12-26 15:38:45 +0000
@@ -32,6 +32,9 @@
 import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.hisp.dhis.system.util.DateUtils;
 
 /**
  * @author Lars Helge Overland
@@ -39,6 +42,15 @@
  */
 public class ContextUtils
 {
+    public static final String CONTENT_TYPE_PDF = "application/pdf";
+    public static final String CONTENT_TYPE_ZIP = "application/zip";
+    public static final String CONTENT_TYPE_JSON = "application/json";
+    public static final String CONTENT_TYPE_HTML = "text/html";
+    public static final String CONTENT_TYPE_TEXT = "text/plain";
+    public static final String CONTENT_TYPE_XML = "text/xml";
+    public static final String CONTENT_TYPE_CSV = "text/csv";
+    public static final String CONTENT_TYPE_EXCEL = "application/vnd.ms-excel";
+    
     private static final String SEPARATOR = "/";
     private static final String PORT_SEPARATOR = ":";    
     private static final String PROTOCOL = "http://";;
@@ -70,4 +82,23 @@
         
         return baseUrl;
     }
+    
+    public static void configureResponse( HttpServletResponse response, String contentType, boolean disallowCache, String filename )
+    {
+        if ( contentType != null )
+        {
+            response.setContentType( contentType );
+        }
+        
+        if ( disallowCache )
+        {   
+            response.addHeader( "Cache-Control", "no-cache" );
+            response.addHeader( "Expires", DateUtils.getExpiredHttpDateString() );
+        } 
+
+        if ( filename != null )
+        {
+            response.addHeader( "Content-Disposition", "attachment; filename=\"" + filename + "\"" );
+        }
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/StreamActionSupport.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/StreamActionSupport.java	2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/StreamActionSupport.java	2010-12-26 15:38:45 +0000
@@ -32,7 +32,6 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.struts2.ServletActionContext;
-import org.hisp.dhis.system.util.DateUtils;
 import org.hisp.dhis.system.util.StreamUtils;
 
 import com.opensymphony.xwork2.ActionSupport;
@@ -44,14 +43,6 @@
 public abstract class StreamActionSupport
     extends ActionSupport
 {
-    protected static final String CONTENT_TYPE_PDF = "application/pdf";
-    protected static final String CONTENT_TYPE_ZIP = "application/zip";
-    protected static final String CONTENT_TYPE_JSON = "application/json";
-    protected static final String CONTENT_TYPE_HTML = "text/html";
-    protected static final String CONTENT_TYPE_TEXT = "text/plain";
-    protected static final String CONTENT_TYPE_XML = "text/xml";
-    protected static final String CONTENT_TYPE_EXCEL = "application/vnd.ms-excel";
-    
     // -------------------------------------------------------------------------
     // ActionSupport implementation
     // -------------------------------------------------------------------------
@@ -63,21 +54,7 @@
         
         HttpServletResponse response = ServletActionContext.getResponse();
         
-        if ( getContentType() != null )
-        {
-            response.setContentType( getContentType() );
-        }
-        
-        if ( getFilename() != null )
-        {
-            response.addHeader( "Content-Disposition", "attachment; filename=\"" + getFilename() + "\"" );
-        }
-        
-        if ( disallowCache() )
-        {
-            response.addHeader( "Cache-Control", "no-cache" );
-            response.addHeader( "Expires", DateUtils.getExpiredHttpDateString() );
-        }
+        ContextUtils.configureResponse( response, getContentType(), disallowCache(), getFilename() );
         
         try
         {

=== 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	2010-12-03 05:41:34 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml	2010-12-26 15:38:45 +0000
@@ -23,13 +23,18 @@
 		<result-types>
 			<result-type name="plainTextErrorResult"
 				class="org.hisp.dhis.result.PlainTextErrorResult" />
-			<result-type name="chart" class="org.hisp.dhis.result.ChartResult" />
+			<result-type name="chart" 
+				class="org.hisp.dhis.result.ChartResult" />
 			<result-type name="velocity-xml"
 				class="org.hisp.dhis.result.VelocityXMLResult" />
 			<result-type name="velocity-json"
 				class="org.hisp.dhis.result.VelocityJsonResult" />
 			<result-type name="outputStreamResult"
 				class="org.hisp.dhis.result.OutputStreamResult" />
+			<result-type name="gridCsvResult"
+				class="org.hisp.dhis.result.GridCsvResult" />
+			<result-type name="gridXlsResult"
+				class="org.hisp.dhis.result.GridXlsResult" />
 		</result-types>
 
 		<interceptors>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/GetDataElementCategoryListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/GetDataElementCategoryListAction.java	2010-12-20 17:34:30 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/GetDataElementCategoryListAction.java	2010-12-26 15:38:45 +0000
@@ -33,7 +33,6 @@
 import java.util.Collections;
 import java.util.List;
 
-import org.hisp.dhis.datadictionary.DataDictionary;
 import org.hisp.dhis.dataelement.DataElementCategory;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.dataelement.comparator.DataElementCategoryNameComparator;

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/categorycombo/GetDataElementCategoryComboListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/categorycombo/GetDataElementCategoryComboListAction.java	2010-12-20 17:34:30 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/categorycombo/GetDataElementCategoryComboListAction.java	2010-12-26 15:38:45 +0000
@@ -33,14 +33,11 @@
 import java.util.Collections;
 import java.util.List;
 
-import org.hisp.dhis.datadictionary.DataDictionary;
 import org.hisp.dhis.dataelement.DataElementCategoryCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.dataelement.comparator.DataElementCategoryComboNameComparator;
 import org.hisp.dhis.paging.ActionPagingSupport;
 
-import com.opensymphony.xwork2.Action;
-
 /**
  * @author Abyot Asalefew
  * @version $Id$

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/concept/GetConceptListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/concept/GetConceptListAction.java	2010-12-20 17:34:30 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/concept/GetConceptListAction.java	2010-12-26 15:38:45 +0000
@@ -33,14 +33,11 @@
 import java.util.Collections;
 import java.util.List;
 
+import org.hisp.dhis.concept.Concept;
 import org.hisp.dhis.concept.ConceptService;
-import org.hisp.dhis.concept.Concept;
 import org.hisp.dhis.concept.comparator.ConceptNameComparator;
-import org.hisp.dhis.dataelement.DataElementCategoryCombo;
 import org.hisp.dhis.paging.ActionPagingSupport;
 
-import com.opensymphony.xwork2.ActionSupport;
-
 /**
  * @author Dang Duy Hieu
  * @version $Id$

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/EditSectionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/EditSectionAction.java	2010-12-22 04:05:46 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/EditSectionAction.java	2010-12-26 15:38:45 +0000
@@ -40,7 +40,6 @@
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.dataelement.comparator.DataElementGroupNameComparator;
 import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.dataset.Section;
 import org.hisp.dhis.dataset.SectionService;
 import org.hisp.dhis.options.displayproperty.DisplayPropertyHandler;

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/AddUserGroupAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/AddUserGroupAction.java	2010-12-23 12:27:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/AddUserGroupAction.java	2010-12-26 15:38:45 +0000
@@ -1,5 +1,32 @@
 package org.hisp.dhis.user.action;
 
+/*
+ * 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.
+ */
+
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -11,9 +38,9 @@
 
 import com.opensymphony.xwork2.Action;
 
-public class AddUserGroupAction implements Action
+public class AddUserGroupAction 
+    implements Action
 {
-
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -56,27 +83,18 @@
 
     public String execute() throws Exception
     {
-
-        
-        
         Set<User> userList = new HashSet<User>();
         
         for( Integer groupMember : groupMembers )
         {
             User user = userStore.getUser( groupMember );
-            userList.add( user );
-           
-            
+            userList.add( user ); 
         }
         
         UserGroup userGroup = new UserGroup( name, userList );
         
         userGroupService.addUserGroup( userGroup );
         
-        
-        
-        
         return SUCCESS;
     }
-
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/AddUserGroupFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/AddUserGroupFormAction.java	2010-12-23 12:27:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/AddUserGroupFormAction.java	2010-12-26 15:38:45 +0000
@@ -1,5 +1,32 @@
 package org.hisp.dhis.user.action;
 
+/*
+ * 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.
+ */
+
 import java.util.ArrayList;
 import java.util.List;
 
@@ -8,9 +35,9 @@
 
 import com.opensymphony.xwork2.Action;
 
-public class AddUserGroupFormAction implements Action
+public class AddUserGroupFormAction 
+    implements Action
 {
-
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/UpdateUserGroupAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/UpdateUserGroupAction.java	2010-12-23 12:27:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/UpdateUserGroupAction.java	2010-12-26 15:38:45 +0000
@@ -1,5 +1,32 @@
 package org.hisp.dhis.user.action;
 
+/*
+ * 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.
+ */
+
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -59,9 +86,6 @@
     public String execute()
         throws Exception
     {
-
-        System.out.println("  groupMembers size : "+ groupMembers.size());
-        
         Set<User> userList = new HashSet<User>();
 
         for ( Integer groupMember : groupMembers )
@@ -79,5 +103,4 @@
         
         return SUCCESS;
     }
-
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/ValidateUserAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/ValidateUserAction.java	2010-09-14 09:03:41 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/ValidateUserAction.java	2010-12-26 15:38:45 +0000
@@ -61,6 +61,7 @@
     // -------------------------------------------------------------------------
     // Input
     // -------------------------------------------------------------------------
+    
     private Integer id;
 
     public void setId( Integer id )
@@ -78,6 +79,7 @@
     // -------------------------------------------------------------------------
     // Output
     // -------------------------------------------------------------------------
+    
     private String message;
 
     public String getMessage()
@@ -88,12 +90,12 @@
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
+    
     public String execute()
         throws Exception
     {
         if ( username != null )
         {
-
             UserCredentials match = userStore.getUserCredentialsByUsername( username );
 
             if ( match != null && (id == null || match.getId() != id) )
@@ -102,7 +104,6 @@
 
                 return ERROR;
             }
-
         }
 
         message = i18n.getString( "everything_is_ok" );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/ValidateUserGroupAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/ValidateUserGroupAction.java	2010-12-23 12:27:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/ValidateUserGroupAction.java	2010-12-26 15:38:45 +0000
@@ -1,14 +1,39 @@
 package org.hisp.dhis.user.action;
 
-import java.util.ArrayList;
+/*
+ * 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.
+ */
 
 import org.hisp.dhis.user.UserGroup;
 import org.hisp.dhis.user.UserGroupService;
 
-import com.opensymphony.xwork2.ActionSupport;
+import com.opensymphony.xwork2.Action;
 
 public class ValidateUserGroupAction
-    extends ActionSupport
+    implements Action
 {
     // -------------------------------------------------------------------------
     // Dependencies
@@ -37,12 +62,12 @@
         throws Exception
     {
         UserGroup group = userGroupService.getUserGroupByName( name );
-        
-        if( (id==null && group!= null ) || ( id!= null && id!= group.getId())){
-            
+
+        if ( ( id == null && group != null ) || ( id != null && id != group.getId() ) )
+        {
             return INPUT;
         }
+        
         return SUCCESS;
     }
-
 }

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/ExportExcelAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/ExportExcelAction.java	2010-12-02 19:03:23 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/ExportExcelAction.java	2010-12-26 15:38:45 +0000
@@ -58,13 +58,13 @@
 import org.hisp.dhis.mapping.export.SVGUtils;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.util.ContextUtils;
 import org.hisp.dhis.util.StreamActionSupport;
 
 /**
  * @author Tran Thanh Tri
  * @version $Id$
  */
-
 public class ExportExcelAction
     extends StreamActionSupport
 {
@@ -333,7 +333,7 @@
     @Override
     protected String getContentType()
     {
-        return CONTENT_TYPE_EXCEL;
+        return ContextUtils.CONTENT_TYPE_EXCEL;
     }
 
     @Override

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/ExportImageAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/ExportImageAction.java	2010-12-03 12:40:38 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/ExportImageAction.java	2010-12-26 15:38:45 +0000
@@ -26,6 +26,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+
 import java.io.OutputStream;
 
 import javax.servlet.http.HttpServletResponse;

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportDesignAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportDesignAction.java	2010-11-23 08:13:14 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportDesignAction.java	2010-12-26 15:38:45 +0000
@@ -33,6 +33,7 @@
 
 import org.hisp.dhis.report.Report;
 import org.hisp.dhis.report.ReportService;
+import org.hisp.dhis.util.ContextUtils;
 import org.hisp.dhis.util.StreamActionSupport;
 
 /**
@@ -81,7 +82,7 @@
     @Override
     protected String getContentType()
     {
-        return CONTENT_TYPE_XML;
+        return ContextUtils.CONTENT_TYPE_XML;
     }
 
     @Override

=== 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	2010-11-29 22:36:15 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/RenderReportAction.java	2010-12-26 15:38:45 +0000
@@ -42,6 +42,7 @@
 import org.hisp.dhis.report.Report;
 import org.hisp.dhis.report.ReportService;
 import org.hisp.dhis.system.util.StreamUtils;
+import org.hisp.dhis.util.ContextUtils;
 import org.hisp.dhis.util.StreamActionSupport;
 
 /**
@@ -116,7 +117,7 @@
     @Override
     protected String getContentType()
     {
-        return CONTENT_TYPE_PDF;
+        return ContextUtils.CONTENT_TYPE_PDF;
     }
 
     @Override

=== added 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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/ExportTableAction.java	2010-12-26 15:38:45 +0000
@@ -0,0 +1,103 @@
+package org.hisp.dhis.reporting.tablecreator.action;
+
+/*
+ * 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.
+ */
+
+import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.reporttable.ReportTableService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class ExportTableAction
+    implements Action
+{
+    private static final String DEFAULT_TYPE = "html";
+    
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private ReportTableService reportTableService;
+
+    public void setReportTableService( ReportTableService reportTableService )
+    {
+        this.reportTableService = reportTableService;
+    }
+    
+    private I18nFormat format;
+
+    public void setFormat( I18nFormat format )
+    {
+        this.format = format;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private Integer id;
+    
+    public void setId( Integer id )
+    {
+        this.id = id;
+    }
+
+    private String type;
+
+    public void setType( String type )
+    {
+        this.type = type;
+    }
+
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    private Grid grid;
+
+    public Grid getGrid()
+    {
+        return grid;
+    }
+
+    // -------------------------------------------------------------------------
+    // Result implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+        grid = reportTableService.getPrettyReportTableGrid( id, format );
+        
+        return type != null ? type : DEFAULT_TYPE;
+    }    
+}

=== removed file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GenerateTableDataWorkbookAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GenerateTableDataWorkbookAction.java	2010-04-13 11:48:30 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GenerateTableDataWorkbookAction.java	1970-01-01 00:00:00 +0000
@@ -1,98 +0,0 @@
-package org.hisp.dhis.reporting.tablecreator.action;
-
-/*
- * 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.
- */
-
-import java.io.OutputStream;
-
-import javax.servlet.http.HttpServletResponse;
-
-import org.hisp.dhis.i18n.I18nFormat;
-import org.hisp.dhis.util.StreamActionSupport;
-import org.hisp.dhis.workbook.WorkbookService;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class GenerateTableDataWorkbookAction
-    extends StreamActionSupport
-{
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private WorkbookService workbookService;
-
-    public void setWorkbookService( WorkbookService workbookService )
-    {
-        this.workbookService = workbookService;
-    }
-    
-    private I18nFormat format;
-
-    public void setFormat( I18nFormat format )
-    {
-        this.format = format;
-    }
-
-    // -------------------------------------------------------------------------
-    // Input
-    // -------------------------------------------------------------------------
-
-    private Integer id;
-
-    public void setId( Integer id )
-    {
-        this.id = id;
-    }
-
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-
-    @Override
-    protected String execute( HttpServletResponse response, OutputStream out )
-        throws Exception
-    {
-        workbookService.writeReportTableData( out, id, format );
-        
-        return SUCCESS;
-    }
-
-    @Override
-    protected String getContentType()
-    {
-        return CONTENT_TYPE_EXCEL;
-    }
-
-    @Override
-    protected String getFilename()
-    {
-        return "ReportTable.xls";
-    }
-}

=== removed file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetDisplayTableOptionsAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetDisplayTableOptionsAction.java	2010-10-29 12:39:33 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetDisplayTableOptionsAction.java	1970-01-01 00:00:00 +0000
@@ -1,109 +0,0 @@
-package org.hisp.dhis.reporting.tablecreator.action;
-
-/*
- * 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.
- */
-
-import java.util.List;
-
-import org.hisp.dhis.i18n.I18nFormat;
-import org.hisp.dhis.reporttable.ReportTable;
-import org.hisp.dhis.reporttable.ReportTableColumn;
-import org.hisp.dhis.reporttable.ReportTableService;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class GetDisplayTableOptionsAction
-    implements Action
-{
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private ReportTableService reportTableService;
-
-    public void setReportTableService( ReportTableService reportTableService )
-    {
-        this.reportTableService = reportTableService;
-    }
-    
-    private I18nFormat format;
-
-    public void setFormat( I18nFormat format )
-    {
-        this.format = format;
-    }
-
-    // -------------------------------------------------------------------------
-    // Input
-    // -------------------------------------------------------------------------
-
-    private Integer id;
-
-    public void setId( Integer id )
-    {
-        this.id = id;
-    }
-    
-    private ReportTable reportTable;
-
-    public ReportTable getReportTable()
-    {
-        return reportTable;
-    }
-
-    // -------------------------------------------------------------------------
-    // Output
-    // -------------------------------------------------------------------------
-
-    private List<ReportTableColumn> columns;
-
-    public List<ReportTableColumn> getColumns()
-    {
-        return columns;
-    }
-    
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-
-    public String execute()
-    {
-        reportTable = reportTableService.getReportTable( id );
-        
-        reportTable.setRelativePeriods( reportTable.getRelatives().getRelativePeriods( 1, format, true ) ); //TODO check
-        reportTable.setI18nFormat( format );
-        reportTable.init();
-        
-        columns = reportTable.getFilledDisplayColumns();
-        
-        return SUCCESS;
-    }
-}

=== removed file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetTableDataAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetTableDataAction.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetTableDataAction.java	1970-01-01 00:00:00 +0000
@@ -1,93 +0,0 @@
-package org.hisp.dhis.reporting.tablecreator.action;
-
-/*
- * 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.
- */
-
-import org.hisp.dhis.i18n.I18nFormat;
-import org.hisp.dhis.reporttable.ReportTableData;
-import org.hisp.dhis.reporttable.ReportTableService;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class GetTableDataAction
-    implements Action
-{
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private ReportTableService reportTableService;
-
-    public void setReportTableService( ReportTableService reportTableService )
-    {
-        this.reportTableService = reportTableService;
-    }
-
-    private I18nFormat format;
-
-    public void setFormat( I18nFormat format )
-    {
-        this.format = format;
-    }
-    
-    // -------------------------------------------------------------------------
-    // Input
-    // -------------------------------------------------------------------------
-
-    private Integer id;
-
-    public void setId( Integer id )
-    {
-        this.id = id;
-    }
-    
-    // -------------------------------------------------------------------------
-    // Output
-    // -------------------------------------------------------------------------
-
-    private ReportTableData data;
-
-    public ReportTableData getData()
-    {
-        return data;
-    }
-    
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-
-    public String execute()
-    {
-        data = reportTableService.getReportTableData( id, format );
-        
-        return SUCCESS;
-    } 
-}

=== removed file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetTableDataExportAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetTableDataExportAction.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetTableDataExportAction.java	1970-01-01 00:00:00 +0000
@@ -1,119 +0,0 @@
-package org.hisp.dhis.reporting.tablecreator.action;
-
-/*
- * 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.
- */
-
-import java.io.InputStream;
-
-import org.hisp.dhis.common.ServiceProvider;
-import org.hisp.dhis.i18n.I18nFormat;
-import org.hisp.dhis.importexport.ExportParams;
-import org.hisp.dhis.importexport.ExportService;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Lars Helge Overland
- * @version $Id: NoAction.java 3229 2007-04-10 17:41:29Z stianast $
- */
-public class GetTableDataExportAction
-    implements Action
-{
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private ServiceProvider<ExportService> serviceProvider;
-
-    public void setServiceProvider( ServiceProvider<ExportService> serviceProvider )
-    {
-        this.serviceProvider = serviceProvider;
-    }
-
-    private I18nFormat format;
-
-    public void setFormat( I18nFormat format )
-    {
-        this.format = format;
-    }
-
-    // -------------------------------------------------------------------------
-    // Input
-    // -------------------------------------------------------------------------
-
-    private Integer id;
-
-    public void setId( Integer id )
-    {
-        this.id = id;
-    }
-    
-    private String exportFormat;
-
-    public void setExportFormat( String exportFormat )
-    {
-        this.exportFormat = exportFormat;
-    }
-
-    // -------------------------------------------------------------------------
-    // Output
-    // -------------------------------------------------------------------------
-
-    private InputStream inputStream;
-
-    public InputStream getInputStream()
-    {
-        return inputStream;
-    }
-    
-    private String fileName;
-
-    public String getFileName()
-    {
-        return fileName;
-    }
-
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-
-    public String execute() throws Exception
-    {
-        ExportService exportService = serviceProvider.provide( exportFormat );
-        
-        ExportParams params = new ExportParams();
-        
-        params.getReportTables().add( id );
-        params.setFormat( format );
-        
-        inputStream = exportService.exportData( params );
-        
-        fileName = "ReportTable.zip";
-        
-        return SUCCESS;
-    }
-}

=== removed file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveDisplayTableAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveDisplayTableAction.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveDisplayTableAction.java	1970-01-01 00:00:00 +0000
@@ -1,106 +0,0 @@
-package org.hisp.dhis.reporting.tablecreator.action;
-
-/*
- * 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.
- */
-
-import java.util.List;
-
-import org.hisp.dhis.reporttable.ReportTable;
-import org.hisp.dhis.reporttable.ReportTableColumn;
-import org.hisp.dhis.reporttable.ReportTableService;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class SaveDisplayTableAction
-    implements Action
-{
-    private static final String SEPARATOR = "-";
-
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private ReportTableService reportTableService;
-
-    public void setReportTableService( ReportTableService reportTableService )
-    {
-        this.reportTableService = reportTableService;
-    }
-
-    // -------------------------------------------------------------------------
-    // Input
-    // -------------------------------------------------------------------------
-
-    private Integer id;
-
-    public void setId( Integer id )
-    {
-        this.id = id;
-    }
-
-    private List<String> column;
-
-    public void setColumn( List<String> column )
-    {
-        this.column = column;
-    }
-
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-
-    public String execute()
-    {
-        ReportTable reportTable = reportTableService.getReportTable( id );
-        
-        reportTable.getDisplayColumns().clear();
-        
-        for ( String col : column )
-        {
-            String[] columns = col.split( SEPARATOR );
-            
-            if ( columns.length > 1 )
-            {            
-                ReportTableColumn displayColumn = new ReportTableColumn();
-                
-                displayColumn.setName( columns[0] );
-                displayColumn.setHeader( columns[1] );
-                displayColumn.setHidden( columns.length > 2 ? Boolean.valueOf( columns[2] ) : false );
-                
-                reportTable.getDisplayColumns().add( displayColumn );
-            }
-        }
-        
-        reportTableService.updateReportTable( reportTable );
-        
-        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	2010-12-15 17:52:50 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml	2010-12-26 15:38:45 +0000
@@ -234,42 +234,7 @@
     <property name="reportTableService"
       ref="org.hisp.dhis.reporttable.ReportTableService"/>
   </bean>
-  
-  <bean id="org.hisp.dhis.reporting.tablecreator.action.GetTableDataExportAction"
-    class="org.hisp.dhis.reporting.tablecreator.action.GetTableDataExportAction"
-    scope="prototype">
-    <property name="serviceProvider"
-      ref="exportServiceProvider"/>
-  </bean>
-  
-  <bean id="org.hisp.dhis.reporting.tablecreator.action.GenerateTableDataWorkbookAction"
-    class="org.hisp.dhis.reporting.tablecreator.action.GenerateTableDataWorkbookAction"
-    scope="prototype">
-    <property name="workbookService"
-      ref="org.hisp.dhis.workbook.WorkbookService"/>
-  </bean>
-  
-  <bean id="org.hisp.dhis.reporting.tablecreator.action.GetTableDataAction"
-    class="org.hisp.dhis.reporting.tablecreator.action.GetTableDataAction"
-    scope="prototype">
-    <property name="reportTableService"
-      ref="org.hisp.dhis.reporttable.ReportTableService"/>
-  </bean>
-  
-  <bean id="org.hisp.dhis.reporting.tablecreator.action.GetDisplayTableOptionsAction"
-    class="org.hisp.dhis.reporting.tablecreator.action.GetDisplayTableOptionsAction"
-    scope="prototype">
-    <property name="reportTableService"
-      ref="org.hisp.dhis.reporttable.ReportTableService"/>
-  </bean>
-  
-  <bean id="org.hisp.dhis.reporting.tablecreator.action.SaveDisplayTableAction"
-    class="org.hisp.dhis.reporting.tablecreator.action.SaveDisplayTableAction"
-    scope="prototype">
-    <property name="reportTableService"
-      ref="org.hisp.dhis.reporttable.ReportTableService"/>
-  </bean>
-  
+    
   <bean id="org.hisp.dhis.reporting.tablecreator.action.AddReportTableToDashboardAction"
     class="org.hisp.dhis.reporting.tablecreator.action.AddReportTableToDashboardAction"
     scope="prototype">
@@ -287,6 +252,13 @@
     <property name="dimensionService"
       ref="org.hisp.dhis.dimension.DimensionService"/>
   </bean>
+  
+  <bean id="org.hisp.dhis.reporting.tablecreator.action.ExportTableAction"
+    class="org.hisp.dhis.reporting.tablecreator.action.ExportTableAction"
+    scope="prototype">
+    <property name="reportTableService"
+      ref="org.hisp.dhis.reporttable.ReportTableService"/>
+  </bean>    
     
   <!-- ReportViewer -->
   

=== 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	2010-12-15 17:52:50 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties	2010-12-26 15:38:45 +0000
@@ -300,5 +300,5 @@
 get_chart = Get chart
 group_set = Group set
 get_report = Get report
-get_report_as_xsl = Get report as Excel
-get_report_as_csv = Get report as CSV
\ No newline at end of file
+get_report_as_xls = Download as Excel
+get_report_as_csv = Download as CSV
\ 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	2010-12-15 17:52:50 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml	2010-12-26 15:38:45 +0000
@@ -237,40 +237,6 @@
       <param name="onExceptionReturn">plainTextError</param>
     </action>
     
-    <action name="getTableDataExport" class="org.hisp.dhis.reporting.tablecreator.action.GetTableDataExportAction">
-      <result name="success" type="stream">
-        <param name="contentType">application/zip</param>
-        <param name="inputName">inputStream</param>
-        <param name="contentDisposition">filename="${fileName}"</param>
-        <param name="bufferSize">10240</param>
-      </result>
-    </action>
-    
-    <action name="generateTableDataWorkbook" class="org.hisp.dhis.reporting.tablecreator.action.GenerateTableDataWorkbookAction">
-      <result name="success" type="outputStreamResult"/>
-    </action>
-    
-    <action name="getTableData" class="org.hisp.dhis.reporting.tablecreator.action.GetTableDataAction">
-      <result name="success" type="velocity">/main.vm</result>
-      <param name="page">/dhis-web-reporting/responseReportTableData.vm</param>
-      <param name="menu">/dhis-web-reporting/menu.vm</param>
-    </action>
-    
-    <action name="getBlankTableData" class="org.hisp.dhis.reporting.tablecreator.action.GetTableDataAction">
-      <result name="success" type="velocity">/dhis-web-reporting/responseBlankReportTableData.vm</result>
-    </action>
-    
-    <action name="displayTable" class="org.hisp.dhis.reporting.tablecreator.action.GetDisplayTableOptionsAction">
-      <result name="success" type="velocity">/main.vm</result>
-      <param name="page">/dhis-web-reporting/displayTableForm.vm</param>
-      <param name="javascripts">javascript/table.js</param>	  
-    </action>
-    
-    <action name="saveDisplayTable" class="org.hisp.dhis.reporting.tablecreator.action.SaveDisplayTableAction">
-      <result name="success" type="velocity">/dhis-web-reporting/responseSuccess.vm</result>
-      <param name="onExceptionReturn">plainTextError</param>
-    </action>
-    
     <action name="addReportTableToDashboard" class="org.hisp.dhis.reporting.tablecreator.action.AddReportTableToDashboardAction">
       <result name="success" type="velocity-xml">/dhis-web-reporting/responseSuccess.vm</result>
       <param name="onExceptionReturn">plainTextError</param>
@@ -280,7 +246,15 @@
       <result name="success" type="velocity">/dhis-web-commons/ajax/xmlDataElements.vm</result>
       <param name="onExceptionReturn">plainTextError</param>
     </action>
-        		
+    
+    <action name="exportTable" class="org.hisp.dhis.reporting.tablecreator.action.ExportTableAction">
+      <result name="csv" type="gridCsvResult"/>
+      <result name="xls" type="gridXlsResult"/>
+      <result name="html" type="velocity">/main.vm</result>
+      <param name="page">/dhis-web-commons/ajax/htmlGrid.vm</param>
+      <param name="menu">/dhis-web-reporting/menu.vm</param>      
+    </action>
+    
     <!-- PivotTable -->
     
     <action name="displayPivotTableForm" class="org.hisp.dhis.reporting.action.NoAction">

=== removed file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/displayTableForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/displayTableForm.vm	2010-10-29 12:39:33 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/displayTableForm.vm	1970-01-01 00:00:00 +0000
@@ -1,57 +0,0 @@
-
-<script type="text/javascript">
-$(function() {
-	$("#columnTable").sortable({
-		placeholder: 'ui-state-highlight'
-	});
-	$("#columnTable").disableSelection();		
-});
-
-</script>
-
-<style>
-	#columnTable { list-style-type: none; margin: 0; padding: 0; width: 582px; }
-	#columnTable li { margin: 0 1px 1px 1px; padding: 1px; padding-left: 5px; font-size: 12pt;cursor:pointer }
-	.ui-state-highlight { height: 1.5em; line-height: 1.2em; }
-</style>
-
-<input type="hidden" id="reportTableId" value="$!reportTable.id">
-
-<h3>$i18n.getString( "display_report_table" )</h3>
-
-#if( $reportTable.hasDynamicColumns() )
-
-<span id="info">$i18n.getString( 'cannot_create_display_columns_dynamic_columns' )</span>
-<p><input type="button" value="$i18n.getString( "back" )" onclick="window.location.href='displayManageTableForm.action'" style="width:120px"></p>
-
-#else
-
-<h4>$encoder.htmlEncode( $reportTable.name )</h4>
-
-<p>
-<table>
-	<tr>
-		<th style="width:400px">$i18n.getString( "column" )</th>
-		<th style="width:55px;">$i18n.getString( "visible" )</td>
-		<th style="width:90px;">$i18n.getString( "move" )</th>
-	</tr>
-</table>
-<ul id="columnTable"> 
-#foreach( $column in $columns )
-<li class="ui-state-default" name="dataElementGroupOrder" value="$group.id" title="$i18n.getString( 'sort_order_help' )">
-	<table>
-		<tr>
-			<td style="width:400px"><input type="text" id="$!encoder.htmlEncode( $column.name )" value="$!column.header" style="width:390px"/></td>
-			<td style="width:55px;text-align:center"><input type="checkbox" #if ( !$column.hidden )checked="checked"#end></td>
-			<td style="width:90px; color:#808080;text-align:center;padding-left:5px">$i18n.getString( "click_and_drag" )</td>
-		</tr>
-	</table>
-</li>
-#end
-</ul> 
-</p>
-
-<p><input type="button" value="$i18n.getString( "save" )" onclick="saveDisplayTable()" style="width:120px"><input
-          type="button" value="$i18n.getString( "cancel" )" onclick="window.location.href='displayManageTableForm.action'" style="width:120px"></p>
-
-#end

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm	2010-12-15 17:52:50 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm	2010-12-26 15:38:45 +0000
@@ -73,10 +73,10 @@
     <tr>        
         <td>
         #if ( $mode == "table" )
-            <input type="button" value="$i18n.getString( 'get_report' )" onclick="generateReport( 'html' )" style="width:120px">
-            <input type="button" value="$i18n.getString( 'back' )" onclick="javascript:window.location.href='displayManageTableForm.action'" style="width:120px"><br><br>
-            <input type="button" value="$i18n.getString( 'get_report_as_xsl' )" onclick="generateReport( 'xsl' )" style="width:120px">
-            <input type="button" value="$i18n.getString( 'get_report_as_csv' )" onclick="generateReport( 'csv' )" style="width:120px">
+            <input type="button" value="$i18n.getString( 'get_report' )" onclick="generateReport( 'html' )" style="width:140px">
+            <input type="button" value="$i18n.getString( 'back' )" onclick="javascript:window.location.href='displayManageTableForm.action'" style="width:140px"><br><br>
+            <input type="button" value="$i18n.getString( 'get_report_as_xls' )" onclick="generateReport( 'xls' )" style="width:140px">
+            <input type="button" value="$i18n.getString( 'get_report_as_csv' )" onclick="generateReport( 'csv' )" style="width:140px">
         #end
         #if ( $mode == "report" )
             <input type="button" value="$i18n.getString( 'get_report' )" onclick="generateReport( '' )" style="width:120px">

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js	2010-12-15 18:02:33 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js	2010-12-26 15:38:45 +0000
@@ -1,8 +1,4 @@
 
-var FORMAT_HTML = "html";
-var FORMAT_XSL = "xsl";
-var FORMAT_CSV = "csv";
-
 var MODE_REPORT = "report";
 var MODE_TABLE = "table";
 
@@ -97,18 +93,7 @@
         }
         else if ( $( "#mode" ).val() == MODE_TABLE )
         {
-        	if ( outputFormat == FORMAT_HTML )
-        	{
-        		window.location.href = "getTableData.action?id=" + $( "#id" ).val();
-        	}
-        	else if ( outputFormat == FORMAT_XSL )
-        	{
-        		window.location.href = "generateTableDataWorkbook.action?id=" + $( "#id" ).val();
-        	}
-        	else if ( outputFormat == FORMAT_CSV )
-        	{
-        		window.location.href = "getTableDataExport.action?exportFormat=CSV&id=" + $( "#id" ).val();
-        	}
+        	window.location.href = "exportTable.action?id=" + $( "#id" ).val() + "&type=" + outputFormat;
         }
     }
     else if ( statusMessage == null )

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.js	2010-12-15 17:52:50 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.js	2010-12-26 15:38:45 +0000
@@ -246,36 +246,3 @@
         request.send( "addReportTableToDashboard.action?id=" + id );
     }
 }
-
-// -----------------------------------------------------------------------------
-// Display
-// -----------------------------------------------------------------------------
-
-function saveDisplayTable()
-{
-    var params = "id=" + document.getElementById( "reportTableId" ).value + "&";
-    
-    var table = document.getElementById( "columnTable" );
-    
-    var inputs = table.getElementsByTagName( "input" );
-    
-    for ( var i = 0; i < inputs.length; i+=2 )
-    {
-        var column = inputs[i].id;
-        var header = inputs[i].value;
-        var hidden = !( inputs[i+1].checked );
-        
-        params += "column=" + column + "-" + header + "-" + hidden + "&";
-    }
-    
-    var request = new Request();
-    request.setResponseTypeXML( 'message' );
-    request.setCallbackSuccess( saveDisplayTableReceived );
-    request.sendAsPost( params );
-    request.send( "saveDisplayTable.action" );
-}
-
-function saveDisplayTableReceived( messageElement )
-{
-    window.location.href = 'displayManageTableForm.action';
-}

=== removed directory 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/style'
=== removed file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/style/dhis-web-reporting.css'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/style/dhis-web-reporting.css	2010-12-25 14:36:08 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/style/dhis-web-reporting.css	1970-01-01 00:00:00 +0000
@@ -1,11 +0,0 @@
-
-.gridTable th, .gridTable td
-{
-  text-align: center;
-  width: 150px;
-}
-
-.gridLeft td
-{
-  text-align: left;
-}

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewTableForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewTableForm.vm	2010-12-15 17:52:50 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewTableForm.vm	2010-12-26 15:38:45 +0000
@@ -30,8 +30,7 @@
 					<td onclick="showTableDetails( $table.id )">$encoder.htmlEncode( $table.name )</td>
 					<td style="text-align:right">
 						<a href="getReportParams.action?id=$table.id&mode=table" title="$i18n.getString( "create" )"><img src="../images/start_process.png" alt="$i18n.getString( "create" )"></a>
-						<a href="displayAddTableForm.action?id=$table.id&mode=$table.mode&dimension=$table.isDimensional()" title="$i18n.getString( "edit" )"><img src="../images/edit.png" alt="$i18n.getString( "edit" )"></a>
-						<a href="displayTable.action?id=$table.id" title="$i18n.getString( "display" )"><img src="../images/display.png" alt="$i18n.getString( "display" )"></a>
+						<a href="displayAddTableForm.action?id=$table.id&mode=$table.mode&dimension=$table.isDimensional()" title="$i18n.getString( "edit" )"><img src="../images/edit.png" alt="$i18n.getString( "edit" )"></a>						
 						<a href="javascript:addReportTableToDashboard( '$table.id' )" title="$i18n.getString( 'add_to_dashboard' )"><img src="../images/add_to_dashboard.png" alt="$i18n.getString( 'add_to_dashboard' )"></a>
 						<a href="javascript:removeTable( $table.id, '$encoder.jsEncode( $table.name )' )" title="$i18n.getString( "remove" )"><img src="../images/delete.png" alt="$i18n.getString( "remove" )"></a>
 						<a href="javascript:showTableDetails( $table.id )" title="$i18n.getString( "show_details" )"><img src="../images/information.png" alt="$i18n.getString( "show_details" )"></a>