← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7733: Data mart, aggregating to temporary tables and copying data after the process is done, this in or...

 

------------------------------------------------------------
revno: 7733
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-07-26 18:50:38 +0200
message:
  Data mart, aggregating to temporary tables and copying data after the process is done, this in order to reduce the time where the database indexes are off
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableCreator.java
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/DataMartManager.java
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/JdbcDataMartManager.java
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementBuilder.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedDataValueBatchHandler.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedIndicatorValueBatchHandler.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedOrgUnitDataValueBatchHandler.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedOrgUnitIndicatorValueBatchHandler.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/AbstractStatementBuilder.java


--
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-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableCreator.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableCreator.java	2012-06-18 07:02:55 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableCreator.java	2012-07-26 16:50:38 +0000
@@ -65,10 +65,10 @@
 
     public void execute()
     {
-        createSilently( statementBuilder.getCreateAggregatedDataValueTable(), "aggregateddatavalue" );
-        createSilently( statementBuilder.getCreateAggregatedOrgUnitDataValueTable(), "aggregatedorgunitdatavalue" );
-        createSilently( statementBuilder.getCreateAggregatedIndicatorTable(), "aggregatedindicatorvalue" );
-        createSilently( statementBuilder.getCreateAggregatedOrgUnitIndicatorTable(), "aggregatedorgunitindicatorvalue" );
+        createSilently( statementBuilder.getCreateAggregatedDataValueTable( false ), "aggregateddatavalue" );
+        createSilently( statementBuilder.getCreateAggregatedOrgUnitDataValueTable( false ), "aggregatedorgunitdatavalue" );
+        createSilently( statementBuilder.getCreateAggregatedIndicatorTable( false ), "aggregatedindicatorvalue" );
+        createSilently( statementBuilder.getCreateAggregatedOrgUnitIndicatorTable( false ), "aggregatedorgunitindicatorvalue" );
         createSilently( statementBuilder.getCreateDataSetCompletenessTable(), "aggregateddatasetcompleteness" );
         createSilently( statementBuilder.getCreateOrgUnitDataSetCompletenessTable(), "aggregatedorgunitdatasetcompleteness" );
         

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/DataMartManager.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/DataMartManager.java	2012-07-25 16:22:03 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/DataMartManager.java	2012-07-26 16:50:38 +0000
@@ -58,4 +58,16 @@
     void deleteAggregatedOrgUnitIndicatorValues( Collection<Integer> periodIds );
 
     void deleteAggregatedOrgUnitDataValues( Collection<Integer> periodIds );
+    
+    void createTempAggregatedTables();
+    
+    void dropTempAggregatedTables();
+    
+    void copyAggregatedDataValuesFromTemp();
+    
+    void copyAggregatedIndicatorValuesFromTemp();
+    
+    void copyAggregatedOrgUnitDataValuesFromTemp();
+    
+    void copyAggregatedOrgUnitIndicatorValuesFromTemp();
 }

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/JdbcDataMartManager.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/JdbcDataMartManager.java	2012-07-25 16:22:03 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/JdbcDataMartManager.java	2012-07-26 16:50:38 +0000
@@ -42,6 +42,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.dataelement.DataElementOperand;
+import org.hisp.dhis.jdbc.StatementBuilder;
 
 /**
  * @author Lars Helge Overland
@@ -62,6 +63,13 @@
         this.statementManager = statementManager;
     }
     
+    private StatementBuilder statementBuilder;
+
+    public void setStatementBuilder( StatementBuilder statementBuilder )
+    {
+        this.statementBuilder = statementBuilder;
+    }
+
     // -------------------------------------------------------------------------
     // DataMartManager implementation
     // -------------------------------------------------------------------------
@@ -127,6 +135,10 @@
         }
     }
 
+    // -------------------------------------------------------------------------
+    // AggregatedDataValue
+    // -------------------------------------------------------------------------
+
     @Override
     public void createAggregatedValueIndex( boolean dataElement, boolean indicator )
     {
@@ -206,7 +218,11 @@
 
         statementManager.getHolder().executeUpdate( sql );
     }
-    
+
+    // -------------------------------------------------------------------------
+    // AggregatedOrgUnitDataValue
+    // -------------------------------------------------------------------------
+
     @Override
     public void createAggregatedOrgUnitValueIndex( boolean dataElement, boolean indicator )
     {
@@ -285,5 +301,57 @@
             "WHERE periodid IN ( " + getCommaDelimitedString( periodIds ) + " )";
 
         statementManager.getHolder().executeUpdate( sql );
-    }    
+    }
+
+    // -------------------------------------------------------------------------
+    // Data mart tables
+    // -------------------------------------------------------------------------
+
+    public void createTempAggregatedTables()
+    {
+        executeSilently( statementBuilder.getCreateAggregatedDataValueTable( true ) );
+        executeSilently( statementBuilder.getCreateAggregatedIndicatorTable( true ) );
+        executeSilently( statementBuilder.getCreateAggregatedOrgUnitDataValueTable( true ) );
+        executeSilently( statementBuilder.getCreateAggregatedOrgUnitIndicatorTable( true ) );
+    }
+    
+    public void dropTempAggregatedTables()
+    {
+        executeSilently( "drop table aggregateddatavalue_temp" );
+        executeSilently( "drop table aggregatedindicatorvalue_temp" );
+        executeSilently( "drop table aggregatedorgunitdatavalue_temp" );
+        executeSilently( "drop table aggregatedorgunitindicatorvalue_temp" );
+    }
+    
+    public void copyAggregatedDataValuesFromTemp()
+    {
+        executeSilently( "insert into aggregateddatavalue select * from aggregateddatavalue_temp" );
+    }
+
+    public void copyAggregatedIndicatorValuesFromTemp()
+    {
+        executeSilently( "insert into aggregatedindicatorvalue select * from aggregatedindicatorvalue_temp" );
+    }
+
+    public void copyAggregatedOrgUnitDataValuesFromTemp()
+    {
+        executeSilently( "insert into aggregatedorgunitdatavalue select * from aggregatedorgunitdatavalue_temp" );
+    }
+
+    public void copyAggregatedOrgUnitIndicatorValuesFromTemp()
+    {
+        executeSilently( "insert into aggregatedorgunitindicatorvalue select * from aggregatedorgunitindicatorvalue_temp" );
+    }
+
+    private void executeSilently( String sql )
+    {
+        try
+        {
+            statementManager.getHolder().executeUpdate( sql, true );
+        }
+        catch ( Exception ex )
+        {
+            log.debug( ex.getMessage() );
+        }
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java	2012-07-25 16:22:03 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java	2012-07-26 16:50:38 +0000
@@ -201,6 +201,15 @@
         notifier.clear( id, DATAMART ).notify( id, DATAMART, "Data mart export process started" );
 
         // ---------------------------------------------------------------------
+        // Recreate temporary tables
+        // ---------------------------------------------------------------------
+
+        dataMartManager.dropTempAggregatedTables();
+        dataMartManager.createTempAggregatedTables();
+        
+        clock.logTime( "Recreated temporary tables" );
+        
+        // ---------------------------------------------------------------------
         // Replace null with empty collection
         // ---------------------------------------------------------------------
 
@@ -307,37 +316,19 @@
         
         clock.logTime( "Populated crosstab table, " + SystemUtils.getMemoryString() );
 
+        final boolean isIndicators = indicators != null && indicators.size() > 0;
+        
         // ---------------------------------------------------------------------
         // 1. Create aggregated data cache
         // ---------------------------------------------------------------------
 
-        final boolean isIndicators = indicators != null && indicators.size() > 0;
-        
         crossTabService.createAggregatedDataCache( indicatorOperands, key );
         
         clock.logTime( "Created aggregated data cache, number of indicator operands: " + indicatorOperands.size() + ", operands with data: " + allOperands.size() );
-        notifier.notify( id, DATAMART, "Dropping database indexes" );
-        
-        // ---------------------------------------------------------------------
-        // 2. Drop potential indexes
-        // ---------------------------------------------------------------------
-
-        dataMartManager.dropAggregatedValueIndex( true, isIndicators );
-        
-        clock.logTime( "Dropped potential indexes" );
-        notifier.notify( id, DATAMART, "Deleting existing data element data" );
-        
-        // ---------------------------------------------------------------------
-        // 3. Delete existing aggregated datavalues
-        // ---------------------------------------------------------------------
-
-        dataMartManager.deleteAggregatedDataValues( periodIds );
-        
-        clock.logTime( "Deleted existing aggregated datavalues" );
-        notifier.notify( id, DATAMART, "Exporting data for data elements" );
-        
-        // ---------------------------------------------------------------------
-        // 4. Export data element values
+        notifier.notify( id, DATAMART, "Exporting data for data element data" );
+        
+        // ---------------------------------------------------------------------
+        // 2. Export data element values
         // ---------------------------------------------------------------------
 
         List<List<OrganisationUnit>> organisationUnitPages = new PaginatedList<OrganisationUnit>( organisationUnits ).setNumberOfPages( cpuCores ).getPages();
@@ -358,16 +349,34 @@
         }
         
         clock.logTime( "Exported values for data element operands (" + allOperands.size() + "), pages: " + organisationUnitPages.size() + ", " + SystemUtils.getMemoryString() );
-        notifier.notify( id, DATAMART, "Deleting existing indicator data" );
-        
-        // ---------------------------------------------------------------------
-        // 5. Delete existing aggregated indicatorvalues
-        // ---------------------------------------------------------------------
-
-        dataMartManager.deleteAggregatedIndicatorValues( periodIds );
-        
-        clock.logTime( "Deleted existing aggregated indicatorvalues" );
-        notifier.notify( id, DATAMART, "Exporting data for indicators" );
+        notifier.notify( id, DATAMART, "Dropping data element data indexes" );
+
+        // ---------------------------------------------------------------------
+        // 3. Drop potential indexes
+        // ---------------------------------------------------------------------
+
+        dataMartManager.dropAggregatedValueIndex( true, isIndicators ); //TODO
+        
+        clock.logTime( "Dropped potential indexes" );
+        notifier.notify( id, DATAMART, "Deleting existing data element data" );
+        
+        // ---------------------------------------------------------------------
+        // 4. Delete existing aggregated data values
+        // ---------------------------------------------------------------------
+
+        dataMartManager.deleteAggregatedDataValues( periodIds );
+        
+        clock.logTime( "Deleted existing data element data" );
+        notifier.notify( id, DATAMART, "Copying data element data from temporary table" );
+
+        // ---------------------------------------------------------------------
+        // 5. Copy aggregated data values from temporary table
+        // ---------------------------------------------------------------------
+
+        dataMartManager.copyAggregatedDataValuesFromTemp();
+        
+        clock.logTime( "Copied data element data from temporary table" );
+        notifier.notify( id, DATAMART, "Exporting data for indicator data" );
         
         // ---------------------------------------------------------------------
         // 6. Export indicator values
@@ -387,8 +396,7 @@
         }
         
         clock.logTime( "Exported values for indicators (" + indicators.size() + "), pages: " + organisationUnitPages.size() + ", " + SystemUtils.getMemoryString() );
-        notifier.notify( id, DATAMART, "Creating database indexes" );
-
+        
         // ---------------------------------------------------------------------
         // 7. Drop aggregated data cache
         // ---------------------------------------------------------------------
@@ -396,9 +404,28 @@
         crossTabService.dropAggregatedDataCache( key );
         
         clock.logTime( "Dropped aggregated data cache, " + SystemUtils.getMemoryString() );
-
-        // ---------------------------------------------------------------------
-        // 8. Create potential indexes
+        notifier.notify( id, DATAMART, "Deleting existing indicator data" );
+
+        // ---------------------------------------------------------------------
+        // 8. Delete existing aggregated indicator values
+        // ---------------------------------------------------------------------
+
+        dataMartManager.deleteAggregatedIndicatorValues( periodIds );
+        
+        clock.logTime( "Deleted existing indicator data" );
+        notifier.notify( id, DATAMART, "Copying indicator data from temporary table" );
+
+        // ---------------------------------------------------------------------
+        // 9. Copy aggregated data values from temporary table
+        // ---------------------------------------------------------------------
+
+        dataMartManager.copyAggregatedIndicatorValuesFromTemp();
+        
+        clock.logTime( "Copied aggregated indicator data from temporary table" );
+        notifier.notify( id, DATAMART, "Creating indexes" );
+        
+        // ---------------------------------------------------------------------
+        // 10. Create potential indexes
         // ---------------------------------------------------------------------
         
         dataMartManager.createAggregatedValueIndex( true, isIndicators );
@@ -419,28 +446,10 @@
             crossTabService.createAggregatedOrgUnitDataCache( indicatorOperands, key );
             
             clock.logTime( "Created aggregated org unit data cache" );
-            notifier.notify( id, DATAMART, "Dropping database indexes" );
-            
-            // -----------------------------------------------------------------
-            // 2. Drop potential indexes
-            // -----------------------------------------------------------------
-
-            dataMartManager.dropAggregatedOrgUnitValueIndex( true, isIndicators );
-
-            clock.logTime( "Dropped potential org unit indexes" );
-            notifier.notify( id, DATAMART, "Deleting existing data element data" );
-
-            // ---------------------------------------------------------------------
-            // 3. Delete existing aggregated datavalues
-            // ---------------------------------------------------------------------
-
-            dataMartManager.deleteAggregatedOrgUnitDataValues( periodIds );
-            
-            clock.logTime( "Deleted existing aggregated org unit datavalues" );
-            notifier.notify( id, DATAMART, "Exporting data for data elements" );
-
-            // ---------------------------------------------------------------------
-            // 4. Export data element values
+            notifier.notify( id, DATAMART, "Exporting org unit data element data" );
+            
+            // ---------------------------------------------------------------------
+            // 2. Export data element values
             // ---------------------------------------------------------------------
 
             Collection<OrganisationUnit> groupOrganisationUnits = new HashSet<OrganisationUnit>( organisationUnits );
@@ -465,17 +474,35 @@
             }
             
             clock.logTime( "Exported values for data element operands (" + allOperands.size() + "), pages: " + organisationUnitPages.size()  + ", " + SystemUtils.getMemoryString() );
-            notifier.notify( id, DATAMART, "Deleting existing indicator data" );
-            
-            // ---------------------------------------------------------------------
-            // 5. Delete existing aggregated indicatorvalues
-            // ---------------------------------------------------------------------
-
-            dataMartManager.deleteAggregatedOrgUnitIndicatorValues( periodIds );
-            
-            clock.logTime( "Deleted existing aggregated org unit indicatorvalues" );
-            notifier.notify( id, DATAMART, "Exporting data for indicators" );
-
+            notifier.notify( id, DATAMART, "Dropping data element data indexes" );
+
+            // -----------------------------------------------------------------
+            // 3. Drop potential indexes
+            // -----------------------------------------------------------------
+
+            dataMartManager.dropAggregatedOrgUnitValueIndex( true, isIndicators ); //TODO
+
+            clock.logTime( "Dropped potential org unit indexes" );
+            notifier.notify( id, DATAMART, "Deleting existing data element data" );
+
+            // ---------------------------------------------------------------------
+            // 4. Delete existing aggregated data values
+            // ---------------------------------------------------------------------
+
+            dataMartManager.deleteAggregatedOrgUnitDataValues( periodIds );
+            
+            clock.logTime( "Deleted existing aggregated org unit datavalues" );
+            notifier.notify( id, DATAMART, "Exporting data for data elements" );
+
+            // ---------------------------------------------------------------------
+            // 5. Copy aggregated org unit data values from temporary table
+            // ---------------------------------------------------------------------
+
+            dataMartManager.copyAggregatedOrgUnitDataValuesFromTemp();
+            
+            clock.logTime( "Copied aggregated org unit data element data from temporary table" );
+            notifier.notify( id, DATAMART, "Exporting org unit indicator data" );
+            
             // ---------------------------------------------------------------------
             // 6. Export indicator values
             // ---------------------------------------------------------------------
@@ -494,7 +521,6 @@
             }
             
             clock.logTime( "Exported values for indicators (" + indicators.size() + "), pages: " + organisationUnitPages.size() + ", " + SystemUtils.getMemoryString() );
-            notifier.notify( id, DATAMART, "Creating database indexes" );
 
             // ---------------------------------------------------------------------
             // 7. Drop aggregated data cache
@@ -503,9 +529,28 @@
             crossTabService.dropAggregatedOrgUnitDataCache( key );
             
             clock.logTime( "Dropped aggregated org unit data cache, " + SystemUtils.getMemoryString() );
-
-            // ---------------------------------------------------------------------
-            // 8. Create potential indexes
+            notifier.notify( id, DATAMART, "Deleting existing indicator data" );
+
+            // ---------------------------------------------------------------------
+            // 8. Delete existing aggregated indicatorvalues
+            // ---------------------------------------------------------------------
+
+            dataMartManager.deleteAggregatedOrgUnitIndicatorValues( periodIds );
+            
+            clock.logTime( "Deleted existing aggregated org unit indicatorvalues" );
+            notifier.notify( id, DATAMART, "Copying indicator data from temporary table" );
+
+            // ---------------------------------------------------------------------
+            // 9. Copy aggregated org unit indicator values from temporary table
+            // ---------------------------------------------------------------------
+
+            dataMartManager.copyAggregatedOrgUnitIndicatorValuesFromTemp();
+            
+            clock.logTime( "Copied aggregated org unit indicator data from temporary table" );
+            notifier.notify( id, DATAMART, "Creating data element indexes" );
+            
+            // ---------------------------------------------------------------------
+            // 10. Create potential indexes
             // ---------------------------------------------------------------------
 
             dataMartManager.createAggregatedOrgUnitValueIndex( true, isIndicators );
@@ -515,10 +560,11 @@
         }
 
         // ---------------------------------------------------------------------
-        // Drop crosstab table
+        // Drop crosstab and temporary tables
         // ---------------------------------------------------------------------
 
         crossTabService.dropCrossTabTable( key );
+        dataMartManager.dropTempAggregatedTables();
         
         clock.logTime( "Dropped crosstab table" );
         clock.logTime( "Data mart export process completed" );

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml	2012-07-25 16:22:03 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml	2012-07-26 16:50:38 +0000
@@ -26,7 +26,8 @@
   <!-- DataMartManager -->
   
   <bean id="org.hisp.dhis.datamart.DataMartManager" class="org.hisp.dhis.datamart.JdbcDataMartManager">
-	<property name="statementManager" ref="statementManager" />
+	<property name="statementManager" ref="statementManager" />
+	<property name="statementBuilder" ref="statementBuilder" />
   </bean>
   
   <!-- Crosstab -->

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementBuilder.java	2012-07-10 07:16:10 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementBuilder.java	2012-07-26 16:50:38 +0000
@@ -63,24 +63,24 @@
     /**
      * Creates a create table statement for the aggregated datavalue table.
      */
-    String getCreateAggregatedDataValueTable();
+    String getCreateAggregatedDataValueTable( boolean temp );
 
     /**
      * Creates a create table statement for the aggregated organisation unit
      * group datavalue table.
      */
-    String getCreateAggregatedOrgUnitDataValueTable();
+    String getCreateAggregatedOrgUnitDataValueTable( boolean temp );
     
     /**
      * Creates a create table statement for the aggregated indicatorvalue table.
      */
-    String getCreateAggregatedIndicatorTable();
+    String getCreateAggregatedIndicatorTable( boolean temp );
 
     /**
      * Creates a create table statement for the aggregated organisation unit
      * group indicatorvalue table.
      */
-    String getCreateAggregatedOrgUnitIndicatorTable();
+    String getCreateAggregatedOrgUnitIndicatorTable( boolean temp );
 
     /**
      * Creates a create table statement for the aggregated datasetcompleteness table.

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedDataValueBatchHandler.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedDataValueBatchHandler.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedDataValueBatchHandler.java	2012-07-26 16:50:38 +0000
@@ -53,7 +53,7 @@
     
     protected void setTableName()
     {
-        statementBuilder.setTableName( "aggregateddatavalue" );
+        statementBuilder.setTableName( "aggregateddatavalue_temp" );
     }
     
     protected void setUniqueColumns()

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedIndicatorValueBatchHandler.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedIndicatorValueBatchHandler.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedIndicatorValueBatchHandler.java	2012-07-26 16:50:38 +0000
@@ -53,7 +53,7 @@
 
     protected void setTableName()
     {
-        statementBuilder.setTableName( "aggregatedindicatorvalue" );
+        statementBuilder.setTableName( "aggregatedindicatorvalue_temp" );
     }
 
     protected void setUniqueColumns()

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedOrgUnitDataValueBatchHandler.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedOrgUnitDataValueBatchHandler.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedOrgUnitDataValueBatchHandler.java	2012-07-26 16:50:38 +0000
@@ -52,7 +52,7 @@
     
     protected void setTableName()
     {
-        statementBuilder.setTableName( "aggregatedorgunitdatavalue" );
+        statementBuilder.setTableName( "aggregatedorgunitdatavalue_temp" );
     }
     
     protected void setUniqueColumns()

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedOrgUnitIndicatorValueBatchHandler.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedOrgUnitIndicatorValueBatchHandler.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedOrgUnitIndicatorValueBatchHandler.java	2012-07-26 16:50:38 +0000
@@ -52,7 +52,7 @@
 
     protected void setTableName()
     {
-        statementBuilder.setTableName( "aggregatedorgunitindicatorvalue" );
+        statementBuilder.setTableName( "aggregatedorgunitindicatorvalue_temp" );
     }
 
     protected void setUniqueColumns()

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/AbstractStatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/AbstractStatementBuilder.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/AbstractStatementBuilder.java	2012-07-26 16:50:38 +0000
@@ -46,10 +46,10 @@
         return QUOTE + value + QUOTE;
     }
 
-    public String getCreateAggregatedDataValueTable()
+    public String getCreateAggregatedDataValueTable( boolean temp )
     {
         return
-            "CREATE TABLE aggregateddatavalue ( " +
+            "CREATE TABLE aggregateddatavalue" + ( temp ? "_temp" : "" ) + " ( " +
             "dataelementid INTEGER, " +
             "categoryoptioncomboid INTEGER, " +
             "periodid INTEGER, " +
@@ -59,10 +59,10 @@
             "value " + getDoubleColumnType() + " );";
     }
 
-    public String getCreateAggregatedOrgUnitDataValueTable()
+    public String getCreateAggregatedOrgUnitDataValueTable( boolean temp )
     {
         return
-            "CREATE TABLE aggregatedorgunitdatavalue ( " +
+            "CREATE TABLE aggregatedorgunitdatavalue" + ( temp ? "_temp" : "" ) + " ( " +
             "dataelementid INTEGER, " +
             "categoryoptioncomboid INTEGER, " +
             "periodid INTEGER, " +
@@ -73,10 +73,10 @@
             "value " + getDoubleColumnType() + " );";
     }
     
-    public String getCreateAggregatedIndicatorTable()
+    public String getCreateAggregatedIndicatorTable( boolean temp )
     {
         return
-            "CREATE TABLE aggregatedindicatorvalue ( " +
+            "CREATE TABLE aggregatedindicatorvalue" + ( temp ? "_temp" : "" ) + " ( " +
             "indicatorid INTEGER, " +
             "periodid INTEGER, " +
             "organisationunitid INTEGER, " +
@@ -89,10 +89,10 @@
             "denominatorvalue " + getDoubleColumnType() + " );";
     }
 
-    public String getCreateAggregatedOrgUnitIndicatorTable()
+    public String getCreateAggregatedOrgUnitIndicatorTable( boolean temp )
     {
         return
-            "CREATE TABLE aggregatedorgunitindicatorvalue ( " +
+            "CREATE TABLE aggregatedorgunitindicatorvalue" + ( temp ? "_temp" : "" ) + " ( " +
             "indicatorid INTEGER, " +
             "periodid INTEGER, " +
             "organisationunitid INTEGER, " +