← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2901: Removed report table related classes which now are redundant

 

------------------------------------------------------------
revno: 2901
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-02-23 22:08:31 +0100
message:
  Removed report table related classes which now are redundant
removed:
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement/
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement/CreateReportTableStatement.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement/RemoveReportTableStatement.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement/ReportTableStatement.java
  dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableManagerTest.java
  dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableServiceTest.java
  dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableStatementTest.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableInternalProcess.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/JDBCReportTableManager.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/ReportTableManager.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/ListGrid.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridJasperResult.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridJrxmlResult.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridPdfResult.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/RenderReportAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/CreateTableAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/RemoveTableAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js


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

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java	2011-02-22 23:05:45 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java	2011-02-23 21:08:31 +0000
@@ -41,9 +41,7 @@
     String ID = ReportTableService.class.getName();
 
     /**
-     * Generates and sets report parameters for reporting period, parent organisation 
-     * unit and organisation unit. Delegates to <code>createReportTable( ReportTable, boolean )</code> 
-     * to generate the table.
+     * Populated data mart with the relevant aggregated data for this ReportTable.
      * 
      * @param id the identifier.
      * @param mode the mode, can be <l>dataelements</i>, <i>indicators</i>, and <i>datasets</i>.
@@ -53,25 +51,8 @@
      *        report parameter, bot parent organisation unit and organisation unit.
      * @param format the I18nFormat to use.
      */
-    void createReportTable( int id, String mode, Integer reportingPeriod, 
-        Integer organisationUnitId, boolean doDataMart, I18nFormat format );
-    
-    /**
-     * Creates a report table. Exports the relevant data to data mart, updates
-     * the existing database table name, add potential regression columns and data
-     * and generates the table. 
-     * 
-     * @param reportTable the ReportTable to create.
-     * @param doDataMart indicators whether to perform datamart before processing.
-     */
-    void createReportTable( ReportTable reportTable, boolean doDataMart );
-    
-    /**
-     * Removes a ReportTable.
-     * 
-     * @param reportTable the ReportTable to remove.
-     */
-    void removeReportTable( ReportTable reportTable );
+    void populateReportTableDataMart( int id, String mode, Integer reportingPeriod, 
+        Integer organisationUnitId, I18nFormat format );
     
     /**
      * Saves a ReportTable.

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableInternalProcess.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableInternalProcess.java	2011-02-22 23:05:45 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableInternalProcess.java	2011-02-23 21:08:31 +0000
@@ -33,7 +33,6 @@
 
 /**
  * @author Lars Helge Overland
- * @version $Id$
  */
 public class ReportTableInternalProcess
     extends AbstractStatementInternalProcess implements SerialToGroup
@@ -86,13 +85,6 @@
         this.organisationUnitId = organisationUnitId;
     }
     
-    private boolean doDataMart;
-        
-    public void setDoDataMart( boolean doDataMart )
-    {
-        this.doDataMart = doDataMart;
-    }
-
     private I18nFormat format;
 
     public void setFormat( I18nFormat format )
@@ -116,6 +108,6 @@
     @Override
     public void executeStatements()
     {
-        reportTableService.createReportTable( id, mode, reportingPeriod, organisationUnitId, doDataMart, format );
+        reportTableService.populateReportTableDataMart( id, mode, reportingPeriod, organisationUnitId, format );
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java	2011-02-23 19:20:08 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java	2011-02-23 21:08:31 +0000
@@ -45,8 +45,6 @@
 import java.util.List;
 import java.util.Map;
 
-import org.amplecode.quick.BatchHandler;
-import org.amplecode.quick.BatchHandlerFactory;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -61,7 +59,6 @@
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.indicator.Indicator;
-import org.hisp.dhis.jdbc.batchhandler.GenericBatchHandler;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.Period;
@@ -127,13 +124,6 @@
     {
         this.organisationUnitService = organisationUnitService;
     }
-
-    private BatchHandlerFactory batchHandlerFactory;
-    
-    public void setBatchHandlerFactory( BatchHandlerFactory batchHandlerFactory )
-    {
-        this.batchHandlerFactory = batchHandlerFactory;
-    }
     
     private DataMartService dataMartService;
     
@@ -154,107 +144,29 @@
     // -------------------------------------------------------------------------
 
     @Transactional
-    public void createReportTable( int id, String mode, Integer reportingPeriod, 
-        Integer organisationUnitId, boolean doDataMart, I18nFormat format )
+    public void populateReportTableDataMart( int id, String mode, Integer reportingPeriod, Integer organisationUnitId, I18nFormat format )
     {
         ReportTable reportTable = getReportTable( id, mode );
         
         reportTable = initDynamicMetaObjects( reportTable, reportingPeriod, organisationUnitId, format );
-
-        createReportTable( reportTable, doDataMart );
+        
+        if ( reportTable.hasDataElements() || reportTable.hasIndicators() )
+        {
+            dataMartService.export( getIdentifiers( DataElement.class, reportTable.getDataElements() ),
+                getIdentifiers( Indicator.class, reportTable.getIndicators() ),
+                getIdentifiers( Period.class, reportTable.getAllPeriods() ),
+                getIdentifiers( OrganisationUnit.class, reportTable.getAllUnits() ) );
+        }
+        
+        if ( reportTable.hasDataSets() )
+        {
+            completenessService.exportDataSetCompleteness( getIdentifiers( DataSet.class, reportTable.getDataSets() ),
+                getIdentifiers( Period.class, reportTable.getAllPeriods() ),
+                getIdentifiers( OrganisationUnit.class, reportTable.getAllUnits() ) );
+        }
     }
     
     @Transactional
-    public void createReportTable( ReportTable reportTable, boolean doDataMart )
-    {
-        log.info( "Process started for report table: " + reportTable.getName() );
-        
-        // ---------------------------------------------------------------------
-        // Exporting relevant data to data mart
-        // ---------------------------------------------------------------------
-
-        if ( doDataMart )
-        {
-            if ( reportTable.hasDataElements() || reportTable.hasIndicators() )
-            {
-                dataMartService.export( getIdentifiers( DataElement.class, reportTable.getDataElements() ),
-                    getIdentifiers( Indicator.class, reportTable.getIndicators() ),
-                    getIdentifiers( Period.class, reportTable.getAllPeriods() ),
-                    getIdentifiers( OrganisationUnit.class, reportTable.getAllUnits() ) );
-            }
-            
-            if ( reportTable.hasDataSets() )
-            {
-                completenessService.exportDataSetCompleteness( getIdentifiers( DataSet.class, reportTable.getDataSets() ),
-                    getIdentifiers( Period.class, reportTable.getAllPeriods() ),
-                    getIdentifiers( OrganisationUnit.class, reportTable.getAllUnits() ) );
-            }
-        }
-        
-        // ---------------------------------------------------------------------
-        // Creating report table
-        // ---------------------------------------------------------------------
-        
-        reportTableManager.createReportTable( reportTable );
-
-        // ---------------------------------------------------------------------
-        // Updating existing table name after deleting the database table
-        // ---------------------------------------------------------------------
-        
-        reportTable.updateExistingTableName();
-        
-        updateReportTable( reportTable );
-        
-        log.info( "Created report table: " + reportTable.getName() );
-
-        // ---------------------------------------------------------------------
-        // Creating grid
-        // ---------------------------------------------------------------------
-
-        Grid grid = getGrid( reportTable );
-
-        if ( reportTable.isRegression() )
-        {
-            // -----------------------------------------------------------------
-            // The start index of the crosstab columns is derived by
-            // subtracting the total number of columns with the number of
-            // crosstab columns, since they come last in the report table.
-            // -----------------------------------------------------------------
-
-            int numberOfColumns = reportTable.getColumns().size(); // TODO test
-            int startColumnIndex = grid.getWidth() - numberOfColumns;
-        
-            addRegressionToGrid( grid, startColumnIndex, numberOfColumns );
-            
-            log.info( "Added regression to report table: " + reportTable.getName() );
-        }
-
-        // ---------------------------------------------------------------------
-        // Populating report table from grid
-        // ---------------------------------------------------------------------
-        
-        BatchHandler<Object> batchHandler = batchHandlerFactory.createBatchHandler( GenericBatchHandler.class );
-
-        batchHandler.setTableName( reportTable.getTableName() );        
-        batchHandler.init();
-        
-        for ( List<Object> row : grid.getRows() )
-        {
-            batchHandler.addObject( row );
-        }
-        
-        batchHandler.flush();       
-
-        log.info( "Populated report table: " + reportTable.getTableName() );
-    }
-
-    @Transactional
-    public void removeReportTable( ReportTable reportTable )
-    {
-        reportTableManager.removeReportTable( reportTable );
-    }
-
-    @Transactional
     public Grid getReportTableGrid( int id, I18nFormat format, Integer reportingPeriod, Integer organisationUnitId )
     {
         ReportTable reportTable = getReportTable( id );
@@ -438,8 +350,10 @@
      * @param numberOfColumns the number of columns.
      * @return a grid.
      */
-    private Grid addRegressionToGrid( Grid grid, int startColumnIndex, int numberOfColumns )
+    private Grid addRegressionToGrid( Grid grid, int numberOfColumns )
     {
+        int startColumnIndex = grid.getWidth() - numberOfColumns;
+        
         for ( int i = 0; i < numberOfColumns; i++ )
         {
             int columnIndex = i + startColumnIndex;

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/JDBCReportTableManager.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/JDBCReportTableManager.java	2011-02-17 16:56:33 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/JDBCReportTableManager.java	2011-02-23 21:08:31 +0000
@@ -35,20 +35,14 @@
 
 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.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOption;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.indicator.Indicator;
-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.statement.CreateReportTableStatement;
-import org.hisp.dhis.reporttable.statement.RemoveReportTableStatement;
-import org.hisp.dhis.reporttable.statement.ReportTableStatement;
 import org.hisp.dhis.system.util.ConversionUtils;
 import org.hisp.dhis.system.util.TextUtils;
 
@@ -59,8 +53,6 @@
 public class JDBCReportTableManager
     implements ReportTableManager
 {
-    private static final Log log = LogFactory.getLog( JDBCReportTableManager.class );
-
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -72,63 +64,10 @@
         this.statementManager = statementManager;
     }
 
-    private StatementBuilder statementBuilder;
-
-    public void setStatementBuilder( StatementBuilder statementBuilder )
-    {
-        this.statementBuilder = statementBuilder;
-    }
-
     // -------------------------------------------------------------------------
     // ReportTableManager implementation
     // -------------------------------------------------------------------------
 
-    public void createReportTable( ReportTable reportTable )
-    {
-        removeReportTable( reportTable );
-
-        StatementHolder holder = statementManager.getHolder();
-
-        ReportTableStatement statement = new CreateReportTableStatement( reportTable, statementBuilder );
-
-        log.debug( "Creating report table with SQL statement: '" + statement.getStatement() + "'" );
-
-        try
-        {
-            holder.getStatement().executeUpdate( statement.getStatement() );
-        }
-        catch ( Exception ex )
-        {
-            log.info( "SQL: '" + statement.getStatement() + "'" );
-
-            throw new RuntimeException( "Failed to create table: " + reportTable.getTableName(), ex );
-        }
-        finally
-        {
-            holder.close();
-        }
-    }
-
-    public void removeReportTable( ReportTable reportTable )
-    {
-        StatementHolder holder = statementManager.getHolder();
-
-        ReportTableStatement statement = new RemoveReportTableStatement( reportTable );
-
-        try
-        {
-            holder.getStatement().executeUpdate( statement.getStatement() );
-        }
-        catch ( Exception ex )
-        {
-            log.info( "Table does not exist: " + reportTable.getTableName() );
-        }
-        finally
-        {
-            holder.close();
-        }
-    }
-
     public Map<String, Double> getAggregatedValueMap( ReportTable reportTable )
     {
         // TODO move agg value methods to agg datavalueservice and move this method to service layer?

=== 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	2011-02-17 02:05:46 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/ReportTableManager.java	2011-02-23 21:08:31 +0000
@@ -40,20 +40,6 @@
     String ID = ReportTableManager.class.getName();
     
     /**
-     * Creates a report table in the database.
-     * 
-     * @param reportTable the report table to create.
-     */
-    void createReportTable( ReportTable reportTable );
-    
-    /**
-     * Deletes a ReportTable.
-     * 
-     * @param reportTable the ReportTable to delete.
-     */
-    void removeReportTable( ReportTable reportTable );
-    
-    /**
      * Generates a map with a key identifiying the dimensions of each value.
      * 
      * @param reportTable the ReportTable for which to create the value map.

=== removed directory 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement'
=== removed file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement/CreateReportTableStatement.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement/CreateReportTableStatement.java	2011-02-23 19:20:08 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement/CreateReportTableStatement.java	1970-01-01 00:00:00 +0000
@@ -1,157 +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 static org.hisp.dhis.reporttable.ReportTable.*;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.hisp.dhis.common.IdentifiableObject;
-import org.hisp.dhis.dataelement.DataElementCategoryOption;
-import org.hisp.dhis.jdbc.StatementBuilder;
-import org.hisp.dhis.reporttable.ReportTable;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class CreateReportTableStatement
-    extends ReportTableStatement
-{    
-    // -------------------------------------------------------------------------
-    // Constructor
-    // -------------------------------------------------------------------------
-
-    public CreateReportTableStatement( ReportTable reportTable, StatementBuilder statementBuilder )
-    {        
-        super( reportTable, statementBuilder );
-        
-        this.statementBuilder = statementBuilder;
-    }
-
-    // -------------------------------------------------------------------------
-    // ReportTableStatement implementation
-    // -------------------------------------------------------------------------
-
-    @Override
-    protected void init( ReportTable reportTable )
-    {
-        StringBuffer buffer = new StringBuffer();
-        
-        buffer.append( "CREATE TABLE " + reportTable.getTableName() + " ( " );
-
-        // ---------------------------------------------------------------------
-        // Identifier
-        // ---------------------------------------------------------------------
-
-        for ( String column : reportTable.getIndexColumns() )
-        {
-            buffer.append( column + SPACE + NUMERIC_COLUMN_TYPE + SEPARATOR );
-        }
-
-        // ---------------------------------------------------------------------
-        // Name
-        // ---------------------------------------------------------------------
-
-        for ( String column : reportTable.getIndexNameColumns() )
-        {
-            buffer.append( column + SPACE + LONG_TEXT_COLUMN_TYPE + SEPARATOR );
-        }
-
-        // ---------------------------------------------------------------------
-        // Param reporting month name
-        // ---------------------------------------------------------------------
-
-        buffer.append( ReportTable.REPORTING_MONTH_COLUMN_NAME + SPACE + LONG_TEXT_COLUMN_TYPE + SEPARATOR );
-
-        // ---------------------------------------------------------------------
-        // Param organisation unit name
-        // ---------------------------------------------------------------------
-
-        buffer.append( ReportTable.PARAM_ORGANISATIONUNIT_COLUMN_NAME + SPACE + LONG_TEXT_COLUMN_TYPE + SEPARATOR );
-
-        // ---------------------------------------------------------------------
-        // Organisation unit is parent
-        // ---------------------------------------------------------------------
-
-        buffer.append( ReportTable.ORGANISATION_UNIT_IS_PARENT_COLUMN_NAME + SPACE + SHORT_TEXT_COLUMN_TYPE + SEPARATOR );
-        
-        // ---------------------------------------------------------------------
-        // Crosstab
-        // ---------------------------------------------------------------------
-
-        for ( List<IdentifiableObject> column : reportTable.getColumns() )
-        {
-            buffer.append( getColumnName( column ) + SPACE + statementBuilder.getDoubleColumnType() + SEPARATOR );
-        }
-
-        // ---------------------------------------------------------------------
-        // Total
-        // ---------------------------------------------------------------------
-
-        if ( reportTable.doTotal() )
-        {
-            for ( DataElementCategoryOption categoryOption : reportTable.getCategoryCombo().getCategoryOptions() )
-            {
-                buffer.append( databaseEncode( categoryOption.getShortName() ) + SPACE + statementBuilder.getDoubleColumnType() + SEPARATOR );
-            }
-            
-            buffer.append( ReportTable.TOTAL_COLUMN_NAME + SPACE + statementBuilder.getDoubleColumnType() + SEPARATOR );
-        }
-        
-        // ---------------------------------------------------------------------
-        // Regression
-        // ---------------------------------------------------------------------
-
-        if ( reportTable.isRegression() )
-        {
-            for ( List<IdentifiableObject> column : reportTable.getColumns() )
-            {
-                buffer.append( REGRESSION_COLUMN_PREFIX + getColumnName( column ) + SPACE + statementBuilder.getDoubleColumnType() + SEPARATOR );
-            }            
-        }
-
-        // ---------------------------------------------------------------------
-        // Primary key
-        // ---------------------------------------------------------------------
-
-        buffer.append( "PRIMARY KEY ( " );
-        
-        Iterator<String> indexColumns = reportTable.getIndexColumns().iterator();
-        
-        while ( indexColumns.hasNext() )
-        {
-            buffer.append( indexColumns.next() + ( indexColumns.hasNext() ? SEPARATOR : SPACE ) );
-        }
-        
-        buffer.append( ") )" );
-        
-        statement = buffer.toString();
-    }
-}

=== removed file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement/RemoveReportTableStatement.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement/RemoveReportTableStatement.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement/RemoveReportTableStatement.java	1970-01-01 00:00:00 +0000
@@ -1,59 +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 org.hisp.dhis.reporttable.ReportTable;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class RemoveReportTableStatement
-    extends ReportTableStatement
-{
-    // -------------------------------------------------------------------------
-    // Constructor
-    // -------------------------------------------------------------------------
-
-    public RemoveReportTableStatement( ReportTable reportTable )
-    {
-        super( reportTable );
-    }
-
-    // -------------------------------------------------------------------------
-    // ReportTableStatement implementation
-    // -------------------------------------------------------------------------
-
-    @Override
-    protected void init( ReportTable reportTable )
-    {
-        String sql = "DROP TABLE " + reportTable.getExistingTableName();
-        
-        statement = sql;
-    }
-}

=== removed file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement/ReportTableStatement.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement/ReportTableStatement.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement/ReportTableStatement.java	1970-01-01 00:00:00 +0000
@@ -1,97 +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 org.amplecode.quick.Statement;
-import org.hisp.dhis.jdbc.StatementBuilder;
-import org.hisp.dhis.reporttable.ReportTable;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public abstract class ReportTableStatement
-    implements Statement
-{
-    protected static final String NUMERIC_COLUMN_TYPE = "INTEGER NOT NULL";
-    protected static final String SHORT_TEXT_COLUMN_TYPE = "VARCHAR (15)";
-    protected static final String LONG_TEXT_COLUMN_TYPE = "VARCHAR (40)";
-    protected static final String SPACE = " ";
-    protected static final String SEPARATOR = ", ";
-    protected static final String QUERY_PARAM_ID = ":";
-
-    protected StatementBuilder statementBuilder;
-    
-    protected String statement;
-
-    // -------------------------------------------------------------------------
-    // Constructors
-    // -------------------------------------------------------------------------
-
-    @SuppressWarnings( "unused" )
-    private ReportTableStatement()
-    {
-    }
-    
-    public ReportTableStatement( ReportTable reportTable )
-    {
-        init( reportTable );
-    }
-    
-    public ReportTableStatement( ReportTable reportTable, StatementBuilder statementBuilder )
-    {
-        this.statementBuilder = statementBuilder;
-        
-        init( reportTable );
-    }
-
-    // -------------------------------------------------------------------------
-    // Public methods
-    // -------------------------------------------------------------------------
-
-    public String getStatement()
-    {
-        return statement;
-    }
-    
-    public void setString( String param, String value )
-    {
-        statement = statement.replace( QUERY_PARAM_ID + param, value );
-    }
-    
-    public void setInt( String param, Integer value )
-    {        
-        statement = statement.replace( QUERY_PARAM_ID + param, String.valueOf( value ) );
-    }
-    
-    // -------------------------------------------------------------------------
-    // Abstract methods
-    // -------------------------------------------------------------------------
-
-    protected abstract void init( ReportTable reportTable );
-}

=== 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	2011-02-18 20:20:07 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml	2011-02-23 21:08:31 +0000
@@ -33,7 +33,6 @@
   <bean id="org.hisp.dhis.reporttable.jdbc.ReportTableManager"
     class="org.hisp.dhis.reporttable.jdbc.JDBCReportTableManager">
 	<property name="statementManager" ref="statementManager"/>
-	<property name="statementBuilder" ref="statementBuilder"/>
   </bean>
 
   <bean id="org.hisp.dhis.reporttable.ReportTableStore"
@@ -54,7 +53,6 @@
       ref="org.hisp.dhis.period.PeriodService"/>
     <property name="organisationUnitService"
       ref="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
-    <property name="batchHandlerFactory" ref="batchHandlerFactory"/>
     <property name="dataMartService"
       ref="org.hisp.dhis.datamart.DataMartService"/>
     <property name="completenessService"

=== removed file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableManagerTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableManagerTest.java	2011-02-17 15:37:19 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableManagerTest.java	1970-01-01 00:00:00 +0000
@@ -1,262 +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.
- */
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.hisp.dhis.DhisTest;
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategoryCombo;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
-import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.i18n.I18nFormat;
-import org.hisp.dhis.indicator.Indicator;
-import org.hisp.dhis.indicator.IndicatorType;
-import org.hisp.dhis.mock.MockI18nFormat;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.period.MonthlyPeriodType;
-import org.hisp.dhis.period.Period;
-import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.period.RelativePeriods;
-import org.hisp.dhis.period.YearlyPeriodType;
-import org.hisp.dhis.reporttable.jdbc.ReportTableManager;
-import org.junit.Test;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class ReportTableManagerTest
-    extends DhisTest
-{
-    private ReportTableManager reportTableManager;
-
-    private List<DataElement> dataElements;
-    private List<Indicator> indicators;
-    private List<DataSet> dataSets;
-    private List<Period> periods;
-    private List<Period> relativePeriods;
-    private List<OrganisationUnit> units;
-
-    private PeriodType monthlyPeriodType;
-    private PeriodType yearlyPeriodType;
-
-    private DataElementCategoryOptionCombo categoryOptionComboA;
-    private DataElementCategoryOptionCombo categoryOptionComboB;
-        
-    private DataElementCategoryCombo categoryComboA;
-    
-    private DataElement dataElementA;
-    private DataElement dataElementB;
-        
-    private IndicatorType indicatorType;
-    
-    private Indicator indicatorA;
-    private Indicator indicatorB;
-    
-    private DataSet dataSetA;
-    private DataSet dataSetB;
-    
-    private Period periodA;
-    private Period periodB;
-    private Period periodC;
-    private Period periodD;
-    
-    private OrganisationUnit unitA;
-    private OrganisationUnit unitB;
-
-    private RelativePeriods relatives;
-        
-    private I18nFormat i18nFormat;
-
-    // -------------------------------------------------------------------------
-    // Fixture
-    // -------------------------------------------------------------------------
-
-    @Override
-    public void setUpTest()
-        throws Exception
-    {
-        reportTableManager = (ReportTableManager) getBean( ReportTableManager.ID );
-
-        dataElements = new ArrayList<DataElement>();
-        indicators = new ArrayList<Indicator>();
-        dataSets = new ArrayList<DataSet>();
-        periods = new ArrayList<Period>();
-        relativePeriods = new ArrayList<Period>();
-        units = new ArrayList<OrganisationUnit>();
-        
-        monthlyPeriodType = PeriodType.getPeriodTypeByName( MonthlyPeriodType.NAME );
-        yearlyPeriodType = PeriodType.getPeriodTypeByName( YearlyPeriodType.NAME );
-        
-        indicatorType = createIndicatorType( 'A' );
-
-        categoryOptionComboA = createCategoryOptionCombo( 'A', 'A', 'B' );
-        categoryOptionComboB = createCategoryOptionCombo( 'B', 'C', 'D' );
-        
-        categoryOptionComboA.setId( 'A' );
-        categoryOptionComboB.setId( 'B' );
-        
-        categoryComboA = new DataElementCategoryCombo( "CategoryComboA" );        
-        categoryComboA.setId( 'A' );
-        categoryComboA.getOptionCombos().add( categoryOptionComboA );
-        categoryComboA.getOptionCombos().add( categoryOptionComboB );
-                
-        dataElementA = createDataElement( 'A' );
-        dataElementB = createDataElement( 'B' );
-        
-        dataElementA.setId( 'A' );
-        dataElementB.setId( 'B' );
-        
-        dataElements.add( dataElementA );
-        dataElements.add( dataElementB );
-        
-        indicatorA = createIndicator( 'A', indicatorType );
-        indicatorB = createIndicator( 'B', indicatorType );
-        
-        indicatorA.setId( 'A' );
-        indicatorB.setId( 'B' );
-        
-        indicators.add( indicatorA );
-        indicators.add( indicatorB );
-        
-        dataSetA = createDataSet( 'A', monthlyPeriodType );
-        dataSetB = createDataSet( 'B', monthlyPeriodType );
-        
-        dataSetA.setId( 'A' );
-        dataSetB.setId( 'B' );
-        
-        dataSets.add( dataSetA );
-        dataSets.add( dataSetB );
-        
-        periodA = createPeriod( monthlyPeriodType, getDate( 2008, 1, 1 ), getDate( 2008, 1, 31 ) );
-        periodB = createPeriod( monthlyPeriodType, getDate( 2008, 2, 1 ), getDate( 2008, 2, 28 ) );
-        
-        periodA.setId( 'A' );
-        periodB.setId( 'B' );
-        
-        periods.add( periodA );
-        periods.add( periodB );
-
-        periodC = createPeriod( monthlyPeriodType, getDate( 2008, 3, 1 ), getDate( 2008, 3, 31 ) );
-        periodD = createPeriod( yearlyPeriodType, getDate( 2008, 1, 1 ), getDate( 2008, 12, 31 ) );
-        
-        periodC.setId( 'C' );
-        periodD.setId( 'D' );
-        
-        periodC.setName( RelativePeriods.REPORTING_MONTH );
-        periodD.setName( RelativePeriods.THIS_YEAR );
-        
-        relativePeriods.add( periodC );
-        relativePeriods.add( periodD );
-        
-        unitA = createOrganisationUnit( 'A' );
-        unitB = createOrganisationUnit( 'B' );
-        
-        unitA.setId( 'A' );
-        unitB.setId( 'B' );
-        
-        units.add( unitA );
-        units.add( unitB );
-
-        relatives = new RelativePeriods();
-        
-        relatives.setReportingMonth( true );
-        relatives.setThisYear( true );
-        
-        i18nFormat = new MockI18nFormat();
-    }
-
-    @Override
-    public boolean emptyDatabaseAfterTest()
-    {
-        return true;
-    }
-
-    // -------------------------------------------------------------------------
-    // Tests
-    // -------------------------------------------------------------------------
-
-    @Test
-    public void testCreateReportTable()
-    {
-        ReportTable reportTable = new ReportTable( "Immunization", false,
-            new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, true, true, false, relatives, null, i18nFormat, "january_2000" );
-
-        reportTable.init();
-        
-        reportTableManager.createReportTable( reportTable );
-        
-        reportTable = new ReportTable( "Immunization", false,
-            dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
-            null, true, true, false, relatives, null, i18nFormat, "january_2000" );
-
-        reportTable.init();
-        
-        reportTableManager.createReportTable( reportTable );
-        
-        reportTable = new ReportTable( "Immunization", false,
-            new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
-            null, true, true, false, relatives, null, i18nFormat, "january_2000" );
-
-        reportTable.init();
-        
-        reportTableManager.createReportTable( reportTable );
-    }
-
-    @Test
-    public void testRemoveReportTable()
-    {
-        ReportTable reportTable = new ReportTable( "Immunization", false,
-            new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
-            null, true, true, false, relatives, null, i18nFormat, "january_2000" );
-
-        reportTable.init();
-        
-        reportTableManager.removeReportTable( reportTable );
-
-        reportTable = new ReportTable( "Immunization", false,
-            dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
-            null, true, true, false, relatives, null, i18nFormat, "january_2000" );
-
-        reportTable.init();
-        
-        reportTableManager.removeReportTable( reportTable );
-
-        reportTable = new ReportTable( "Immunization", false,
-            new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
-            null, true, true, false, relatives, null, i18nFormat, "january_2000" );
-
-        reportTable.init();
-        
-        reportTableManager.removeReportTable( reportTable );
-    }
-}
-

=== removed file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableServiceTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableServiceTest.java	2011-02-17 15:37:19 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableServiceTest.java	1970-01-01 00:00:00 +0000
@@ -1,514 +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.
- */
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.amplecode.quick.BatchHandler;
-import org.amplecode.quick.BatchHandlerFactory;
-import org.hisp.dhis.DhisTest;
-import org.hisp.dhis.aggregation.AggregatedDataValue;
-import org.hisp.dhis.aggregation.AggregatedIndicatorValue;
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategory;
-import org.hisp.dhis.dataelement.DataElementCategoryCombo;
-import org.hisp.dhis.dataelement.DataElementCategoryOption;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
-import org.hisp.dhis.dataelement.DataElementCategoryService;
-import org.hisp.dhis.dataelement.DataElementService;
-import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.dataset.DataSetService;
-import org.hisp.dhis.i18n.I18nFormat;
-import org.hisp.dhis.indicator.Indicator;
-import org.hisp.dhis.indicator.IndicatorService;
-import org.hisp.dhis.indicator.IndicatorType;
-import org.hisp.dhis.jdbc.batchhandler.AggregatedDataValueBatchHandler;
-import org.hisp.dhis.jdbc.batchhandler.AggregatedIndicatorValueBatchHandler;
-import org.hisp.dhis.mock.MockI18nFormat;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.period.MonthlyPeriodType;
-import org.hisp.dhis.period.Period;
-import org.hisp.dhis.period.PeriodService;
-import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.period.RelativePeriods;
-import org.hisp.dhis.period.YearlyPeriodType;
-import org.junit.Test;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class ReportTableServiceTest
-    extends DhisTest
-{
-    private ReportTableService reportTableService;
-    
-    private BatchHandlerFactory batchHandlerFactory;
-    
-    private List<DataElement> dataElements;
-    private List<DataElementCategoryOptionCombo> categoryOptionCombos;
-    private List<Indicator> indicators;
-    private List<DataSet> dataSets;
-    private List<Period> periods;
-    private List<Period> relativePeriods;
-    private List<OrganisationUnit> units;
-
-    private PeriodType montlyPeriodType;
-    private PeriodType yearlyPeriodType;
-
-    private DataElement dataElementA;
-    private DataElement dataElementB;
-
-    private DataElementCategoryOption categoryOptionA;
-    private DataElementCategoryOption categoryOptionB;
-    
-    private DataElementCategory categoryA;
-    
-    private DataElementCategoryCombo categoryComboA;
-    
-    private DataElementCategoryOptionCombo categoryOptionComboA;
-    private DataElementCategoryOptionCombo categoryOptionComboB;  
-
-    private IndicatorType indicatorType;
-    
-    private Indicator indicatorA;
-    private Indicator indicatorB;
-    
-    private DataSet dataSetA;
-    private DataSet dataSetB;
-    
-    private Period periodA;
-    private Period periodB;
-    private Period periodC;
-    private Period periodD;
-    
-    private OrganisationUnit unitA;
-    private OrganisationUnit unitB;
-    
-    private int dataElementIdA;
-    private int dataElementIdB;
-    
-    private int categoryOptionComboIdA;
-    private int categoryOptionComboIdB;
-    
-    private int indicatorIdA;
-    private int indicatorIdB;
-    
-    private int periodIdA;
-    private int periodIdB;
-    
-    private int unitIdA;
-    private int unitIdB;
-
-    private RelativePeriods relatives;
-        
-    private I18nFormat i18nFormat;
-
-    // -------------------------------------------------------------------------
-    // Fixture
-    // -------------------------------------------------------------------------
-
-    @Override
-    public void setUpTest()
-        throws Exception
-    {
-        reportTableService = (ReportTableService) getBean( ReportTableService.ID );
-        
-        dataElementService = (DataElementService) getBean( DataElementService.ID );
-        
-        categoryService = (DataElementCategoryService) getBean( DataElementCategoryService.ID );        
-        
-        indicatorService = (IndicatorService) getBean( IndicatorService.ID );
-        dataSetService = (DataSetService) getBean( DataSetService.ID );
-        periodService = (PeriodService) getBean( PeriodService.ID );
-        organisationUnitService = (OrganisationUnitService) getBean( OrganisationUnitService.ID );
-        
-        batchHandlerFactory = (BatchHandlerFactory) getBean( "batchHandlerFactory" );
-        
-        dataElements = new ArrayList<DataElement>();
-        categoryOptionCombos = new ArrayList<DataElementCategoryOptionCombo>();
-        indicators = new ArrayList<Indicator>();
-        dataSets = new ArrayList<DataSet>();
-        periods = new ArrayList<Period>();
-        relativePeriods = new ArrayList<Period>();
-        units = new ArrayList<OrganisationUnit>();
-        
-        montlyPeriodType = PeriodType.getPeriodTypeByName( MonthlyPeriodType.NAME );
-        yearlyPeriodType = PeriodType.getPeriodTypeByName( YearlyPeriodType.NAME );        
-        
-        // ---------------------------------------------------------------------
-        // Setup Dimensions
-        // ---------------------------------------------------------------------
-
-        categoryOptionA = new DataElementCategoryOption( "Male" );
-        categoryOptionB = new DataElementCategoryOption( "Female" );
-        
-        categoryService.addDataElementCategoryOption( categoryOptionA );
-        categoryService.addDataElementCategoryOption( categoryOptionB );
-
-        categoryA = new DataElementCategory( "Gender" );
-        categoryA.getCategoryOptions().add( categoryOptionA );
-        categoryA.getCategoryOptions().add( categoryOptionB );
-
-        categoryService.addDataElementCategory( categoryA );
-
-        categoryComboA = new DataElementCategoryCombo( "Gender" );
-        categoryComboA.getCategories().add( categoryA );        
-        
-        categoryService.addDataElementCategoryCombo( categoryComboA );
-        
-        categoryService.generateOptionCombos( categoryComboA );
-
-        Iterator<DataElementCategoryOptionCombo> categoryOptionCombosIterator = categoryService.getAllDataElementCategoryOptionCombos().iterator();
-        
-        categoryOptionCombosIterator.next(); // Omit default
-        categoryOptionComboA = categoryOptionCombosIterator.next();
-        categoryOptionComboB = categoryOptionCombosIterator.next();
-        
-        categoryOptionComboIdA = categoryOptionComboA.getId();
-        categoryOptionComboIdB = categoryOptionComboB.getId();
-                
-        categoryOptionCombos.add( categoryOptionComboA );        
-        categoryOptionCombos.add( categoryOptionComboB );
-        
-        // ---------------------------------------------------------------------
-        // Setup DataElements
-        // ---------------------------------------------------------------------
-
-        dataElementA = createDataElement( 'A' );
-        dataElementB = createDataElement( 'B' );
-        
-        dataElementIdA = dataElementService.addDataElement( dataElementA );
-        dataElementIdB = dataElementService.addDataElement( dataElementB );
-                
-        dataElements.add( dataElementA );
-        dataElements.add( dataElementB );
-
-        // ---------------------------------------------------------------------
-        // Setup Indicators
-        // ---------------------------------------------------------------------
-
-        indicatorType = createIndicatorType( 'A' );
-        
-        indicatorService.addIndicatorType( indicatorType );
-        
-        indicatorA = createIndicator( 'A', indicatorType );
-        indicatorB = createIndicator( 'B', indicatorType );
-        
-        indicatorIdA = indicatorService.addIndicator( indicatorA );
-        indicatorIdB = indicatorService.addIndicator( indicatorB );
-                
-        indicators.add( indicatorA );
-        indicators.add( indicatorB );
-
-        // ---------------------------------------------------------------------
-        // Setup DataSets
-        // ---------------------------------------------------------------------
-
-        dataSetA = createDataSet( 'A', montlyPeriodType );
-        dataSetB = createDataSet( 'B', montlyPeriodType );
-        
-        dataSetService.addDataSet( dataSetA );
-        dataSetService.addDataSet( dataSetB );
-        
-        dataSets.add( dataSetA );
-        dataSets.add( dataSetB );
-
-        // ---------------------------------------------------------------------
-        // Setup Periods
-        // ---------------------------------------------------------------------
-
-        periodA = createPeriod( montlyPeriodType, getDate( 2008, 1, 1 ), getDate( 2008, 1, 31 ) );
-        periodB = createPeriod( montlyPeriodType, getDate( 2008, 2, 1 ), getDate( 2008, 2, 28 ) );
-        
-        periodIdA = periodService.addPeriod( periodA );
-        periodIdB = periodService.addPeriod( periodB );
-                
-        periods.add( periodA );
-        periods.add( periodB );
-
-        periodC = createPeriod( montlyPeriodType, getDate( 2008, 3, 1 ), getDate( 2008, 3, 31 ) );
-        periodD = createPeriod( yearlyPeriodType, getDate( 2008, 1, 1 ), getDate( 2008, 12, 31 ) );
-        
-        periodService.addPeriod( periodC );
-        periodService.addPeriod( periodD );
-        
-        periodC.setName( RelativePeriods.REPORTING_MONTH );
-        periodD.setName( RelativePeriods.THIS_YEAR );
-        
-        relativePeriods.add( periodC );
-        relativePeriods.add( periodD );
-
-        // ---------------------------------------------------------------------
-        // Setup OrganisationUnits
-        // ---------------------------------------------------------------------
-
-        unitA = createOrganisationUnit( 'A' );
-        unitB = createOrganisationUnit( 'B' );
-        
-        unitIdA = organisationUnitService.addOrganisationUnit( unitA );
-        unitIdB = organisationUnitService.addOrganisationUnit( unitB );
-        
-        units.add( unitA );
-        units.add( unitB );
-
-        relatives = new RelativePeriods();
-        
-        relatives.setReportingMonth( true );
-        relatives.setThisYear( true );
-        
-        i18nFormat = new MockI18nFormat();
-        
-        BatchHandler<AggregatedIndicatorValue> indicatorValueBatchHandler = batchHandlerFactory.createBatchHandler( AggregatedIndicatorValueBatchHandler.class );
-        
-        indicatorValueBatchHandler.init();
-        
-        indicatorValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdA, periodIdA, 8, unitIdA, 8, 1, 11, 0, 0 ) );
-        indicatorValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdA, periodIdA, 8, unitIdB, 8, 1, 12, 0, 0 ) );
-        indicatorValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdA, periodIdA, 8, unitIdA, 8, 1, 13, 0, 0 ) );
-        indicatorValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdA, periodIdA, 8, unitIdB, 8, 1, 14, 0, 0 ) );
-        indicatorValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdA, periodIdB, 8, unitIdA, 8, 1, 15, 0, 0 ) );
-        indicatorValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdA, periodIdB, 8, unitIdB, 8, 1, 16, 0, 0 ) );
-        indicatorValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdA, periodIdB, 8, unitIdA, 8, 1, 17, 0, 0 ) );
-        indicatorValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdA, periodIdB, 8, unitIdB, 8, 1, 18, 0, 0 ) );        
-        indicatorValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdB, periodIdA, 8, unitIdA, 8, 1, 19, 0, 0 ) );
-        indicatorValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdB, periodIdA, 8, unitIdB, 8, 1, 20, 0, 0 ) );
-        indicatorValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdB, periodIdA, 8, unitIdA, 8, 1, 21, 0, 0 ) );
-        indicatorValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdB, periodIdA, 8, unitIdB, 8, 1, 22, 0, 0 ) );
-        indicatorValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdB, periodIdB, 8, unitIdA, 8, 1, 23, 0, 0 ) );
-        indicatorValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdB, periodIdB, 8, unitIdB, 8, 1, 24, 0, 0 ) );
-        indicatorValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdB, periodIdB, 8, unitIdA, 8, 1, 25, 0, 0 ) );
-        indicatorValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdB, periodIdB, 8, unitIdB, 8, 1, 26, 0, 0 ) );
-        
-        indicatorValueBatchHandler.flush();
-        
-        BatchHandler<AggregatedDataValue> dataValueBatchHandler = batchHandlerFactory.createBatchHandler( AggregatedDataValueBatchHandler.class );
-        
-        dataValueBatchHandler.init();
-        
-        dataValueBatchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdB, periodIdA, 8, unitIdA, 8, 11 ) );
-        dataValueBatchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdB, periodIdA, 8, unitIdB, 8, 12 ) );
-        dataValueBatchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdB, periodIdB, 8, unitIdA, 8, 13 ) );
-        dataValueBatchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdB, periodIdB, 8, unitIdB, 8, 14 ) );
-        dataValueBatchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdA, periodIdA, 8, unitIdA, 8, 15 ) );
-        dataValueBatchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdA, periodIdA, 8, unitIdB, 8, 16 ) );
-        dataValueBatchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdA, periodIdB, 8, unitIdA, 8, 17 ) );
-        dataValueBatchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdA, periodIdB, 8, unitIdB, 8, 18 ) );        
-        dataValueBatchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdB, periodIdA, 8, unitIdA, 8, 19 ) );
-        dataValueBatchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdB, periodIdA, 8, unitIdB, 8, 20 ) );
-        dataValueBatchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdB, periodIdB, 8, unitIdA, 8, 21 ) );
-        dataValueBatchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdB, periodIdB, 8, unitIdB, 8, 22 ) );
-        dataValueBatchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdA, periodIdA, 8, unitIdA, 8, 23 ) );
-        dataValueBatchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdA, periodIdA, 8, unitIdB, 8, 24 ) );
-        dataValueBatchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdA, periodIdB, 8, unitIdA, 8, 25 ) );
-        dataValueBatchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdA, periodIdB, 8, unitIdB, 8, 26 ) );
-        
-        dataValueBatchHandler.flush();
-    }
-    
-    @Override
-    public boolean emptyDatabaseAfterTest()
-    {
-        return true;
-    }
-
-    // -------------------------------------------------------------------------
-    // Tests
-    // -------------------------------------------------------------------------
-
-    @Test
-    public void testCreateDataElementReportTableA()
-    {
-        ReportTable reportTable = new ReportTable( "Prescriptions", false,
-            dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, true, true, false, relatives, null, i18nFormat, "january_2000" );
-
-        reportTableService.saveReportTable( reportTable );
-        
-        reportTable.init();
-        
-        reportTableService.createReportTable( reportTable, false );
-    }
-
-    @Test
-    public void testCreateDataElementReportTableB()
-    {
-        ReportTable reportTable = new ReportTable( "Prescriptions", false,
-            dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, false, false, true, relatives, null, i18nFormat, "january_2000" );
-
-        reportTableService.saveReportTable( reportTable );
-        
-        reportTable.init();
-        
-        reportTableService.createReportTable( reportTable, false );
-    }
-
-    @Test
-    public void testCreateDataElementReportTableC()
-    {
-        ReportTable reportTable = new ReportTable( "Prescriptions", false,
-            dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
-            null, true, false, true, relatives, null, i18nFormat, "january_2000" );
-
-        reportTableService.saveReportTable( reportTable );
-        
-        reportTable.init();
-        
-        reportTableService.createReportTable( reportTable, false );
-    }
-
-    @Test
-    public void testCreateDataElementWithCategoryOptionComboReportTableA()
-    {
-        ReportTable reportTable = new ReportTable( "Prescriptions", false,
-            dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
-            categoryComboA, true, true, false, relatives, null, i18nFormat, "january_2000" );
-
-        reportTableService.saveReportTable( reportTable );
-        
-        reportTable.init();
-        
-        reportTableService.createReportTable( reportTable, false );
-    }
-
-    @Test    
-    public void testCreateDataElementWithCategoryOptionComboReportTableB()
-    {
-        ReportTable reportTable = new ReportTable( "Prescriptions", false,
-            dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
-            categoryComboA, false, false, true, relatives, null, i18nFormat, "january_2000" );
-
-        reportTableService.saveReportTable( reportTable );
-        
-        reportTable.init();
-        
-        reportTableService.createReportTable( reportTable, false );
-    }
-
-    @Test
-    public void testCreateDataElementWithCategoryOptionComboReportTableC()
-    {
-        ReportTable reportTable = new ReportTable( "Prescriptions", false,
-            dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
-            categoryComboA, true, false, true, relatives, null, i18nFormat, "january_2000" );
-
-        reportTableService.saveReportTable( reportTable );
-        
-        reportTable.init();
-        
-        reportTableService.createReportTable( reportTable, false );
-    }
-
-    @Test
-    public void testCreateIndicatorReportTableA()
-    {
-        ReportTable reportTable = new ReportTable( "Prescriptions", false,
-            new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
-            null, true, true, false, relatives, null, i18nFormat, "january_2000" );
-
-        reportTableService.saveReportTable( reportTable );
-        
-        reportTable.init();
-        
-        reportTableService.createReportTable( reportTable, false );
-    }
-
-    @Test
-    public void testCreateIndicatorReportTableB()
-    {
-        ReportTable reportTable = new ReportTable( "Prescriptions", false,
-            new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
-            null, false, false, true, relatives, null, i18nFormat, "january_2000" );
-
-        reportTableService.saveReportTable( reportTable );
-        
-        reportTable.init();
-        
-        reportTableService.createReportTable( reportTable, false );
-    }
-
-    @Test
-    public void testCreateIndicatorReportTableC()
-    {
-        ReportTable reportTable = new ReportTable( "Prescriptions", false,
-            new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
-            null, true, false, true, relatives, null, i18nFormat, "january_2000" );
-
-        reportTableService.saveReportTable( reportTable );
-        
-        reportTable.init();
-        
-        reportTableService.createReportTable( reportTable, false );
-    }
-
-    @Test
-    public void testCreateDataSetReportTableA()
-    {
-        ReportTable reportTable = new ReportTable( "Prescriptions", false,
-            new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
-            null, true, true, false, relatives, null, i18nFormat, "january_2000" );
-
-        reportTableService.saveReportTable( reportTable );
-        
-        reportTable.init();
-        
-        reportTableService.createReportTable( reportTable, false );
-    }
-
-    @Test
-    public void testCreateDataSetReportTableB()
-    {
-        ReportTable reportTable = new ReportTable( "Prescriptions", false,
-            new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, false, false, true, relatives, null, i18nFormat, "january_2000" );
-
-        reportTableService.saveReportTable( reportTable );
-        
-        reportTable.init();
-        
-        reportTableService.createReportTable( reportTable, false );
-    }
-
-    @Test
-    public void testCreateDataSetReportTableC()
-    {
-        ReportTable reportTable = new ReportTable( "Prescriptions", false,
-            new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, true, false, true, relatives, null, i18nFormat, "january_2000" );
-
-        reportTableService.saveReportTable( reportTable );
-        
-        reportTable.init();
-        
-        reportTableService.createReportTable( reportTable, false );
-    }
-}

=== removed file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableStatementTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableStatementTest.java	2011-02-17 15:37:19 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableStatementTest.java	1970-01-01 00:00:00 +0000
@@ -1,200 +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.
- */
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotNull;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-
-import org.hisp.dhis.DhisSpringTest;
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategoryCombo;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
-import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.i18n.I18nFormat;
-import org.hisp.dhis.indicator.Indicator;
-import org.hisp.dhis.indicator.IndicatorType;
-import org.hisp.dhis.jdbc.StatementBuilder;
-import org.hisp.dhis.mock.MockI18nFormat;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.period.MonthlyPeriodType;
-import org.hisp.dhis.period.Period;
-import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.period.RelativePeriods;
-import org.hisp.dhis.period.YearlyPeriodType;
-import org.hisp.dhis.reporttable.statement.CreateReportTableStatement;
-import org.hisp.dhis.reporttable.statement.RemoveReportTableStatement;
-import org.hisp.dhis.reporttable.statement.ReportTableStatement;
-import org.junit.Test;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class ReportTableStatementTest
-    extends DhisSpringTest
-{
-    private StatementBuilder statementBuilder;
-    
-    private List<DataElement> dataElements;
-    private List<DataElementCategoryOptionCombo> categoryOptionCombos;
-    private List<Indicator> indicators;
-    private List<DataSet> dataSets;
-    private List<Period> periods;
-    private List<Period> relativePeriods;
-    private List<OrganisationUnit> units;
-
-    private DataElementCategoryCombo categoryCombo;
-    
-    private PeriodType monthlyPeriodType;
-    private PeriodType yearlyPeriodType;
-    
-    private IndicatorType indicatorType;
-
-    private RelativePeriods relatives;
-        
-    private I18nFormat i18nFormat;
-
-    // -------------------------------------------------------------------------
-    // Fixture
-    // -------------------------------------------------------------------------
-
-    @Override
-    public void setUpTest()
-        throws Exception
-    {
-        statementBuilder = (StatementBuilder) getBean( "statementBuilder" );
-        
-        dataElements = new ArrayList<DataElement>();
-        categoryOptionCombos = new ArrayList<DataElementCategoryOptionCombo>();
-        indicators = new ArrayList<Indicator>();
-        dataSets = new ArrayList<DataSet>();
-        periods = new ArrayList<Period>();
-        relativePeriods = new ArrayList<Period>();
-        units = new ArrayList<OrganisationUnit>();
-        
-        monthlyPeriodType = PeriodType.getPeriodTypeByName( MonthlyPeriodType.NAME );
-        yearlyPeriodType = PeriodType.getPeriodTypeByName( YearlyPeriodType.NAME );
-        
-        dataElements.add( createDataElement( 'A' ) );
-        dataElements.add( createDataElement( 'B' ) );
-        
-        categoryOptionCombos.add( createCategoryOptionCombo( 'A', 'A', 'B' ) );
-        categoryOptionCombos.add( createCategoryOptionCombo( 'B', 'C', 'D' ) );
-
-        categoryCombo = new DataElementCategoryCombo( "CategoryComboA" );
-        categoryCombo.setId( 'A' );
-        categoryCombo.setOptionCombos( new HashSet<DataElementCategoryOptionCombo>( categoryOptionCombos ) );
-        
-        indicatorType = createIndicatorType( 'A' );
-        
-        indicators.add( createIndicator( 'A', indicatorType ) );
-        indicators.add( createIndicator( 'B', indicatorType ) );
-        
-        dataSets.add( createDataSet( 'A', monthlyPeriodType ) );
-        dataSets.add( createDataSet( 'B', monthlyPeriodType ) );
-                
-        periods.add( createPeriod( monthlyPeriodType, getDate( 2008, 1, 1 ), getDate( 2008, 1, 31 ) ) );
-        periods.add( createPeriod( monthlyPeriodType, getDate( 2008, 2, 1 ), getDate( 2008, 2, 28 ) ) );
-
-        Period periodC = createPeriod( monthlyPeriodType, getDate( 2008, 3, 1 ), getDate( 2008, 3, 31 ) );
-        Period periodD = createPeriod( yearlyPeriodType, getDate( 2008, 1, 1 ), getDate( 2008, 12, 31 ) );
-        
-        periodC.setName( RelativePeriods.REPORTING_MONTH );
-        periodD.setName( RelativePeriods.THIS_YEAR );
-        
-        periods.add( periodC );
-        periods.add( periodD );
-        
-        units.add( createOrganisationUnit( 'A' ) );
-        units.add( createOrganisationUnit( 'B' ) );        
-
-        relatives = new RelativePeriods();
-        
-        relatives.setReportingMonth( true );
-        relatives.setThisYear( true );
-
-        i18nFormat = new MockI18nFormat();
-    }
-
-    // -------------------------------------------------------------------------
-    // Tests
-    // -------------------------------------------------------------------------
-
-    @Test
-    public void testCreateReportTableStatement()
-    {
-        ReportTable reportTable = new ReportTable( "Immunization", false,
-            new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
-            null, true, true, false, relatives, null, i18nFormat, "january_2000" );
-        
-        reportTable.init();
-        
-        ReportTableStatement statement = new CreateReportTableStatement( reportTable, statementBuilder );
-
-        assertNotNull( statement.getStatement() );
-        
-        reportTable = new ReportTable( "Immunization", false,
-            dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
-            null, true, true, false, relatives, null, i18nFormat, "january_2000" );
-
-        reportTable.init();
-        
-        statement = new CreateReportTableStatement( reportTable, statementBuilder );
-        
-        assertNotNull( statement.getStatement() );
-        
-        reportTable = new ReportTable( "Immunization", false,
-            new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
-            null, true, true, false, relatives, null, i18nFormat, "january_2000" );
-
-        reportTable.init();
-        
-        statement = new CreateReportTableStatement( reportTable, statementBuilder );
-
-        assertNotNull( statement.getStatement() );
-    }
-
-    @Test
-    public void testRemoveReportTableStatement()
-    {
-        ReportTable reportTable = new ReportTable( "Immunization", false,
-            new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
-            null, true, true, false, relatives, null, i18nFormat, "january_2000" );
-
-        reportTable.init();
-        
-        ReportTableStatement statement = new RemoveReportTableStatement( reportTable );
-        
-        assertNotNull( statement.getStatement() );
-        assertEquals( "DROP TABLE _report_immunization", statement.getStatement() );
-    }
-}

=== 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	2011-02-23 14:27:49 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/ListGrid.java	2011-02-23 21:08:31 +0000
@@ -482,19 +482,6 @@
                 return 0;
             }
             
-            /*
-            if ( isNumeric( list1.get( columnIndex ) ) && isNumeric( list2.get( columnIndex ) ) )
-            {
-                final Double value1 = Double.valueOf( list1.get( columnIndex ) );
-                final Double value2 = Double.valueOf( list2.get( columnIndex ) );
-                
-                return order > 0 ? value2.compareTo( value1 ) : value1.compareTo( value2 );
-            }
-            
-            final String value1 = list1.get( columnIndex );
-            final String value2 = list2.get( columnIndex );            
-            */
-            
             if ( list1.get( columnIndex ) == null || !( list1.get( columnIndex ) instanceof Comparable<?> ) || 
                 list2.get( columnIndex ) == null || !( list2.get( columnIndex ) instanceof Comparable<?> ) )
             {

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridJasperResult.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridJasperResult.java	2011-02-23 19:20:08 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridJasperResult.java	2011-02-23 21:08:31 +0000
@@ -89,6 +89,8 @@
         
         grid = _grid != null ? _grid : grid; 
 
+        System.out.println( "GRID IN JASPER RESULT " + grid );
+
         // ---------------------------------------------------------------------
         // Configure response
         // ---------------------------------------------------------------------
@@ -97,7 +99,7 @@
 
         String filename = CodecUtils.filenameEncode( StringUtils.defaultIfEmpty( grid.getTitle(), DEFAULT_FILENAME ) ) + ".pdf";
         
-        ContextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_PDF, true, filename, true );
+        ContextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_PDF, true, filename, false );
         
         // ---------------------------------------------------------------------
         // Write jrxml based on Velocity template

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridJrxmlResult.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridJrxmlResult.java	2011-02-23 14:27:49 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridJrxmlResult.java	2011-02-23 21:08:31 +0000
@@ -81,7 +81,7 @@
         Grid _grid = (Grid) invocation.getStack().findValue( "grid" );
         
         grid = _grid != null ? _grid : grid; 
-
+        
         // ---------------------------------------------------------------------
         // Configure response
         // ---------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridPdfResult.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridPdfResult.java	2011-02-23 14:27:49 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridPdfResult.java	2011-02-23 21:08:31 +0000
@@ -91,7 +91,7 @@
 
         String filename = CodecUtils.filenameEncode( StringUtils.defaultIfEmpty( grid.getTitle(), DEFAULT_FILENAME ) ) + ".pdf";
         
-        ContextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_PDF, true, filename, true );
+        ContextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_PDF, true, filename, false );
 
         // ---------------------------------------------------------------------
         // Write PDF to output stream

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/RenderReportAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/RenderReportAction.java	2011-02-23 19:20:08 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/RenderReportAction.java	2011-02-23 21:08:31 +0000
@@ -133,8 +133,6 @@
             
             Grid grid = reportTableService.getReportTableGrid( reportTable.getId(), format, reportingPeriod, organisationUnitId );
             
-            System.out.println( grid );
-            
             print = JasperFillManager.fillReport( jasperReport, null, grid );
         }
         else // Assume SQL report and provide JDBC connection

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/CreateTableAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/CreateTableAction.java	2010-12-15 17:52:50 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/CreateTableAction.java	2011-02-23 21:08:31 +0000
@@ -89,13 +89,6 @@
         this.mode = mode;
     }
 
-    private boolean doDataMart;
-
-    public void setDoDataMart( boolean doDataMart )
-    {
-        this.doDataMart = doDataMart;
-    }
-
     private Integer reportingPeriod;
 
     public void setReportingPeriod( Integer reportingPeriod )
@@ -127,7 +120,6 @@
         process.setMode( mode );
         process.setReportingPeriod( reportingPeriod );
         process.setOrganisationUnitId( organisationUnitId );
-        process.setDoDataMart( doDataMart );
         process.setFormat( format );
 
         processCoordinator.requestProcessExecution( executor );

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/RemoveTableAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/RemoveTableAction.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/RemoveTableAction.java	2011-02-23 21:08:31 +0000
@@ -73,8 +73,6 @@
             
             if ( table != null )
             {
-                reportTableService.removeReportTable( table );
-                
                 reportTableService.deleteReportTable( table );
             }
         }

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js	2011-02-23 19:20:08 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js	2011-02-23 21:08:31 +0000
@@ -40,28 +40,21 @@
 	}
 		
     setWaitMessage( i18n_please_wait );
-        
-    var url = "createTable.action?id=" + $( "#id" ).val() + 
-    	"&doDataMart=" + $( "#doDataMart" ).val() + "&mode=" + $( "#mode" ).val();
-    
-    if ( $( "#reportingPeriod" ).length )
-    {
-        url += "&reportingPeriod=" + $( "#reportingPeriod" ).val();
-    }
-        
-    if ( paramOrganisationUnit != null )
-    {
-        url += "&organisationUnitId=" + paramOrganisationUnit;
-    }
-    
-    var request = new Request();
-    request.setCallbackSuccess( generateReportReceived );    
-    request.send( url );
-}
-
-function generateReportReceived( messageElement )
-{   
-    getReportStatus();
+    
+    var doDataMart = ( $( "#doDataMart" ).length && $( "#doDataMart" ).val() == "true" );
+    
+    if ( doDataMart )
+    {    
+	    var url = "createTable.action?" + getUrlParams();
+	    
+	    var request = new Request();
+	    request.setCallbackSuccess( getReportStatus );    
+	    request.send( url );
+    }
+    else
+    {
+    	viewReport();
+    }
 }
 
 function getReportStatus()
@@ -81,47 +74,49 @@
     
     if ( finished == "true" )
     {
-        setMessage( i18n_process_completed );
-        
-        var urlParams = "id=" + $( "#id" ).val();
-        
-	    if ( $( "#reportingPeriod" ).length )
-	    {
-	        urlParams += "&reportingPeriod=" + $( "#reportingPeriod" ).val();
-	    }
-	        
-	    if ( paramOrganisationUnit != null )
-	    {
-	        urlParams += "&organisationUnitId=" + paramOrganisationUnit;
-	    }
-    
-        if ( $( "#mode" ).val() == MODE_REPORT )
-        {
-        	window.location.href = "renderReport.action?" + urlParams;
-        }
-        else if ($( "#mode" ).val() == MODE_TABLE )
-        {
-        	window.location.href = "exportTable.action?type=html&" + urlParams;
-        }
-    }
-    else if ( statusMessage == null )
-    {
-        setWaitMessage( i18n_please_wait );
-        
-        waitAndGetReportStatus( 1000 );
+        setMessage( i18n_process_completed );        
+    	viewReport();
     }
     else
     {
-        setWaitMessage( i18n_please_wait + " - " + statusMessage );
+        setTimeout( "getReportStatus();", millis );
+    }
+}
+
+function viewReport( urlParams )
+{
+	var mode = $( "#mode" ).val();
+	
+    if ( mode == MODE_REPORT )
+    {
+    	window.location.href = "renderReport.action?" + getUrlParams();
+    }
+    else // MODE_TABLE
+    {
+    	window.location.href = "exportTable.action?type=html&" + getUrlParams();
+    }
+}
+
+function getUrlParams()
+{
+	 var url = "id=" + $( "#id" ).val() + "&mode=" + $( "#mode" ).val();
+	    
+    if ( $( "#reportingPeriod" ).length )
+    {
+        url += "&reportingPeriod=" + $( "#reportingPeriod" ).val();
+    }
         
-        waitAndGetReportStatus( 1000 );
+    if ( paramOrganisationUnit != null )
+    {
+        url += "&organisationUnitId=" + paramOrganisationUnit;
     }
+	
+	return url;
 }
 
-function waitAndGetReportStatus( millis )
-{
-    setTimeout( "getReportStatus();", millis );
-}
+// -----------------------------------------------------------------------------
+// Report table
+// -----------------------------------------------------------------------------
 
 function exportReport( type )
 {