=== 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 columnValues );
-
- /**
- * Column must hold numeric data.
+ Grid addColumn( List 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 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 PRETTY_COLUMNS = new HashMap() { {
+ 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 displayColumns = new ArrayList();
-
// -------------------------------------------------------------------------
// 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 getFilledDisplayColumns()
- {
- List columns = getAllColumns();
-
- List displayColumns = new ArrayList( 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 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 getDisplayColumns()
- {
- return displayColumns;
- }
-
- public void setDisplayColumns( List 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 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 row : data.getRows() )
- {
- final Iterator 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 converters = new ArrayList();
-
- 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 @@
- CSV
-
-
-
-
- XLS
@@ -364,16 +358,6 @@
-
-
-
-
-
-
-
-
-
=== 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 row = new TreeMap();
-
- 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 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 results, OutputStream out, I18n i18n, OrganisationUnit unit, DataSet dataSet );
void writeValidationResult( List 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 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 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 @@
-
-
+ class="org.hisp.dhis.workbook.impl.JExcelWorkbookService"/>
=== 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 @@
-
-
-
-
-
-
=== 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 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
=== 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 filledDisplayColumns = reportTable.getFilledDisplayColumns();
-
- assertNotNull( filledDisplayColumns );
- assertEquals( reportTable.getAllColumns().size(), filledDisplayColumns.size() );
}
@Test
@@ -319,11 +314,6 @@
assertNotNull( prettyCrossTabColumns );
assertEquals( 2, prettyCrossTabColumns.size() );
-
- List filledDisplayColumns = reportTable.getFilledDisplayColumns();
-
- assertNotNull( filledDisplayColumns );
- assertEquals( reportTable.getAllColumns().size(), filledDisplayColumns.size() );
}
@Test
@@ -382,11 +372,6 @@
assertNotNull( prettyCrossTabColumns );
assertEquals( 4, prettyCrossTabColumns.size() );
-
- List filledDisplayColumns = reportTable.getFilledDisplayColumns();
-
- assertNotNull( filledDisplayColumns );
- assertEquals( reportTable.getAllColumns().size(), filledDisplayColumns.size() );
}
@Test
@@ -449,11 +434,6 @@
assertNotNull( prettyCrossTabColumns );
assertEquals( 8, prettyCrossTabColumns.size() );
-
- List filledDisplayColumns = reportTable.getFilledDisplayColumns();
-
- assertNotNull( filledDisplayColumns );
- assertEquals( reportTable.getAllColumns().size(), filledDisplayColumns.size() );
}
@Test
@@ -509,11 +489,6 @@
assertNotNull( prettyCrossTabColumns );
assertEquals( 2, prettyCrossTabColumns.size() );
-
- List filledDisplayColumns = reportTable.getFilledDisplayColumns();
-
- assertNotNull( filledDisplayColumns );
- assertEquals( reportTable.getAllColumns().size(), filledDisplayColumns.size() );
}
@Test
@@ -572,11 +547,6 @@
assertNotNull( prettyCrossTabColumns );
assertEquals( 4, prettyCrossTabColumns.size() );
-
- List filledDisplayColumns = reportTable.getFilledDisplayColumns();
-
- assertNotNull( filledDisplayColumns );
- assertEquals( reportTable.getAllColumns().size(), filledDisplayColumns.size() );
}
@Test
@@ -653,11 +623,6 @@
assertNotNull( prettyCrossTabColumns );
assertEquals( 16, prettyCrossTabColumns.size() );
-
- List filledDisplayColumns = reportTable.getFilledDisplayColumns();
-
- assertNotNull( filledDisplayColumns );
- assertEquals( reportTable.getAllColumns().size(), filledDisplayColumns.size() );
}
@Test
@@ -718,11 +683,6 @@
assertNotNull( prettyCrossTabColumns );
assertEquals( 4, prettyCrossTabColumns.size() );
-
- List filledDisplayColumns = reportTable.getFilledDisplayColumns();
-
- assertNotNull( filledDisplayColumns );
- assertEquals( reportTable.getAllColumns().size(), filledDisplayColumns.size() );
}
@Test
@@ -790,11 +750,6 @@
assertNotNull( prettyCrossTabColumns );
assertEquals( 8, prettyCrossTabColumns.size() );
-
- List filledDisplayColumns = reportTable.getFilledDisplayColumns();
-
- assertNotNull( filledDisplayColumns );
- assertEquals( reportTable.getAllColumns().size(), filledDisplayColumns.size() );
}
@Test
@@ -849,11 +804,6 @@
assertNotNull( prettyCrossTabColumns );
assertEquals( 2, prettyCrossTabColumns.size() );
-
- List filledDisplayColumns = reportTable.getFilledDisplayColumns();
-
- assertNotNull( filledDisplayColumns );
- assertEquals( reportTable.getAllColumns().size(), filledDisplayColumns.size() );
}
@Test
@@ -912,10 +862,5 @@
assertNotNull( prettyCrossTabColumns );
assertEquals( 4, prettyCrossTabColumns.size() );
-
- List 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 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 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() );
currentRowIndex++;
+
+ return this;
}
- public void addValue( String value )
+ public Grid addValue( String value )
{
grid.get( currentRowIndex ).add( value );
+
+ return this;
}
public List getRow( int rowIndex )
@@ -152,7 +190,7 @@
return grid.get( rowIndex ).get( columnIndex );
}
- public void addColumn( List columnValues )
+ public Grid addColumn( List 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 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();
+ grid = new ArrayList>();
+
+ 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 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 @@
+
+
+
$!encoder.htmlEncode( $grid.title )
+
+
$!encoder.htmlEncode( $grid.subtitle )
+
+
+
+
+
+#foreach( $header in $grid.getHeaders() )
+
$!encoder.htmlEncode( $header )
+#end
+
+
+
+
+#foreach( $row in $grid.getRows() )
+
+#foreach( $col in $row )
+
$!encoder.htmlEncode( $col )
+#end
+
+#end
+
+
+
\ 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 @@
-
-
+
-
-
+
@@ -47,24 +45,6 @@
#end
-
-
=== 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 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 row : grid.getRows() )
+ {
+ Iterator 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 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 @@
-
+
+
+
=== 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 userList = new HashSet();
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 userList = new HashSet();
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 columns;
-
- public List 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 serviceProvider;
-
- public void setServiceProvider( ServiceProvider 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 column;
-
- public void setColumn( List 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 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -287,6 +252,13 @@
+
+
+
+
=== 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 @@
plainTextError
-
-
- application/zip
- inputStream
- filename="${fileName}"
- 10240
-
-
-
-
-
-
-
-
- /main.vm
- /dhis-web-reporting/responseReportTableData.vm
- /dhis-web-reporting/menu.vm
-
-
-
- /dhis-web-reporting/responseBlankReportTableData.vm
-
-
-
- /main.vm
- /dhis-web-reporting/displayTableForm.vm
- javascript/table.js
-
-
-
- /dhis-web-reporting/responseSuccess.vm
- plainTextError
-
-
/dhis-web-reporting/responseSuccess.vm
plainTextError
@@ -280,7 +246,15 @@
/dhis-web-commons/ajax/xmlDataElements.vm
plainTextError
-
+
+
+
+
+ /main.vm
+ /dhis-web-commons/ajax/htmlGrid.vm
+ /dhis-web-reporting/menu.vm
+
+
=== 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 @@
-
-
-
-
-
-
-
-