← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2213: Merged r2030 from 2.0.5

 

------------------------------------------------------------
revno: 2213
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2010-11-29 15:51:31 +0100
message:
  Merged r2030 from 2.0.5
modified:
  dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataarchive/jdbc/JdbcDataArchiveStore.java
  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/DerbyStatementBuilder.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.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-administration/src/main/java/org/hisp/dhis/dataarchive/jdbc/JdbcDataArchiveStore.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataarchive/jdbc/JdbcDataArchiveStore.java	2010-11-02 08:28:21 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataarchive/jdbc/JdbcDataArchiveStore.java	2010-11-29 14:51:31 +0000
@@ -72,96 +72,138 @@
     public void archiveData( Date startDate, Date endDate )
     {
         // Move data from datavalue to datavaluearchive
-        String sql = "INSERT INTO datavaluearchive ( " 
-            + "SELECT d.* FROM datavalue AS d "
-            + "JOIN period AS p ON (d.periodid=p.periodid) " 
-            + "WHERE p.startdate>='" + getMediumDateString( startDate ) + "' " 
-            + "AND p.enddate<='" + getMediumDateString( endDate ) + "' );";
+        
+        String sql =
+            "INSERT INTO datavaluearchive ( " +
+                "SELECT d.* FROM datavalue AS d " +
+                "JOIN period as p ON ( d.periodid=p.periodid ) " +
+                "WHERE p.startdate>='" + getMediumDateString( startDate ) + "' " +
+                "AND p.enddate<='" + getMediumDateString( endDate ) + "' );";
 
-        log.info( sql );
+        log.info( sql );        
         jdbcTemplate.execute( sql );
-
+        
         // Delete data from datavalue
-        sql = statementBuilder.archiveData( getMediumDateString( startDate ), getMediumDateString( endDate ) );
-
-        log.info( sql );
-        jdbcTemplate.execute( sql );
-        
+        
+        sql = 
+            "DELETE FROM datavalue WHERE EXISTS ( " +
+                "SELECT d.* FROM datavalue AS d " +
+                "JOIN period AS p ON ( d.periodid=p.periodid ) " +
+                "WHERE p.startdate>='" + getMediumDateString( startDate ) + "' " +
+                "AND p.enddate<='" + getMediumDateString( endDate ) + "' )";
+        
+        log.info( sql );        
+        jdbcTemplate.execute( sql ); 
     }
 
     public void unArchiveData( Date startDate, Date endDate )
     {
         // Move data from datavalue to datavaluearchive
-        String sql = "INSERT INTO datavalue ( " 
-            + "SELECT a.* FROM datavaluearchive AS a "
-            + "JOIN period AS p ON (a.periodid=p.periodid) " 
-            + "WHERE p.startdate>='" + getMediumDateString( startDate ) + "' " 
-            + "AND p.enddate<='" + getMediumDateString( endDate ) + "' );";
-
-        log.info( sql );
-        jdbcTemplate.execute( sql );
-
+        
+        String sql =
+            "INSERT INTO datavalue ( " +
+                "SELECT a.* FROM datavaluearchive AS a " +
+                "JOIN period as p ON ( a.periodid=p.periodid ) " +
+                "WHERE p.startdate>='" + getMediumDateString( startDate ) + "' " +
+                "AND p.enddate<='" + getMediumDateString( endDate ) + "' );";
+
+        log.info( sql );        
+        jdbcTemplate.execute( sql ); 
+        
         // Delete data from datavalue
 
-        sql = statementBuilder.unArchiveData( getMediumDateString( startDate ), getMediumDateString( endDate ) );
-
-        log.info( sql );
-        jdbcTemplate.execute( sql );
+        sql = 
+            "DELETE FROM datavaluearchive WHERE EXISTS ( " +
+                "SELECT a.* FROM datavaluearchive AS a " +
+                "JOIN period AS p ON ( a.periodid=p.periodid ) " +
+                "WHERE p.startdate>='" + getMediumDateString( startDate ) + "' " +
+                "AND p.enddate<='" + getMediumDateString( endDate ) + "' )";
         
+        log.info( sql );        
+        jdbcTemplate.execute( sql ); 
     }
-
+    
     public int getNumberOfOverlappingValues()
     {
-        String sql = "SELECT COUNT(*) FROM datavaluearchive AS a "
-            + "JOIN datavalue AS d ON (a.dataelementid=d.dataelementid " 
-            + "AND a.periodid=d.periodid "
-            + "AND a.sourceid=d.sourceid " 
-            + "AND a.categoryoptioncomboid=d.categoryoptioncomboid);";
-
-        log.info( sql );
-
+        String sql =
+            "SELECT COUNT(*) FROM datavaluearchive a " +
+            "JOIN datavalue d ON (a.dataelementid=d.dataelementid AND a.periodid=d.periodid AND a.sourceid=d.sourceid AND a.categoryoptioncomboid=d.categoryoptioncomboid);";
+
+        log.info( sql );        
         return jdbcTemplate.queryForInt( sql );
     }
-
+    
     public int getNumberOfArchivedValues()
     {
-        String sql = "SELECT COUNT(*) as dem FROM datavaluearchive;";
-
-        log.info( sql );
+        String sql = "SELECT COUNT(*) FROM datavaluearchive;";
+        
+        log.info( sql );        
         return jdbcTemplate.queryForInt( sql );
     }
-
+    
     public void deleteRegularOverlappingData()
     {
-        String sql = statementBuilder.deleteRegularOverlappingData();
-
-        log.info( sql );
+        String sql =
+            "DELETE FROM datavalue WHERE EXISTS ( " +
+                "SELECT d.* FROM datavalue AS d " +
+                "JOIN datavaluearchive AS a " +
+                "ON ( d.dataelementid=a.dataelementid " +
+                "AND d.periodid=a.periodid " +
+                "AND d.sourceid=a.sourceid " +
+                "AND d.categoryoptioncomboid=a.categoryoptioncomboid ) )";
+        
+        log.info( sql );        
         jdbcTemplate.execute( sql );
     }
-
+    
     public void deleteArchivedOverlappingData()
     {
-        String sql = statementBuilder.deleteArchivedOverlappingData();
+        String sql =
+            "DELETE FROM datavaluearchive WHERE EXISTS ( " +
+                "SELECT a.* FROM datavaluearchive AS a " +
+                "JOIN datavalue AS d " +
+                "ON ( a.dataelementid=d.dataelementid " +
+                "AND a.periodid=d.periodid " +
+                "AND a.sourceid=d.sourceid " +
+                "AND a.categoryoptioncomboid=d.categoryoptioncomboid ) )";
 
-        log.info( sql );
+        log.info( sql );        
         jdbcTemplate.execute( sql );
-    }
+    }    
 
     public void deleteOldestOverlappingData()
     {
         // Delete overlaps from datavalue which are older than datavaluearchive
-        String sql = statementBuilder.deleteOldestOverlappingDataValue();
-
-        log.info( sql );
+        
+        String sql =
+            "DELETE FROM datavalue WHERE EXISTS ( " +
+                "SELECT d.* FROM datavalue AS d " +
+                "JOIN datavaluearchive AS a " +
+                "ON ( d.dataelementid=a.dataelementid " +
+                "AND d.periodid=a.periodid " +
+                "AND d.sourceid=a.sourceid " +
+                "AND d.categoryoptioncomboid=a.categoryoptioncomboid " +
+                "AND d.lastupdated<a.lastupdated ) )";
+        
+        log.info( sql );        
         jdbcTemplate.execute( sql );
-
+        
         // Delete overlaps from datavaluearchive which are older than datavalue
-        sql = statementBuilder.deleteOldestOverlappingArchiveData();
-
-        log.info( sql );
+        
+        sql =
+            "DELETE FROM datavaluearchive WHERE EXISTS ( " +
+                "SELECT a.* FROM datavaluearchive AS a " +
+                "JOIN datavalue AS d " +
+                "ON ( a.dataelementid=d.dataelementid " +
+                "AND a.periodid=d.periodid " +
+                "AND a.sourceid=d.sourceid " +
+                "AND a.categoryoptioncomboid=d.categoryoptioncomboid " + 
+                "AND a.lastupdated<=d.lastupdated ) )";
+        
+        log.info( sql );        
         jdbcTemplate.execute( sql );
     }
-
+    
     // -------------------------------------------------------------------------
     // Implementation methods for Patient data values
     // -------------------------------------------------------------------------

=== 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	2010-11-24 09:49:54 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementBuilder.java	2010-11-29 14:51:31 +0000
@@ -119,18 +119,6 @@
     
     String getDeflatedDataValues( int dataElementId, String dataElementName, int categoryOptionComboId,
     	String periodIds, int organisationUnitId, String organisationUnitName, int lowerBound, int upperBound );
-    	
-    String archiveData( String startDate, String endDate );
-    
-    String unArchiveData( String startDate, String endDate );
-    
-    String deleteRegularOverlappingData();
-    
-    String deleteArchivedOverlappingData();
-    
-    String deleteOldestOverlappingDataValue();
-    
-    String deleteOldestOverlappingArchiveData();
     
     String archivePatientData ( String startDate, String endDate );
     

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/DerbyStatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/DerbyStatementBuilder.java	2010-11-24 09:49:54 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/DerbyStatementBuilder.java	2010-11-29 14:51:31 +0000
@@ -220,67 +220,6 @@
             "AND ( CAST( dv.value AS " + getDoubleColumnType() + " ) < '" + lowerBound + "' " +
             "OR CAST( dv.value AS " + getDoubleColumnType() + " ) > '" + upperBound + "' )";
    }
-    
-   public String archiveData( String startDate, String endDate ){
-        
-        return  "DELETE FROM datavaluearchive AS a " +
-                "USING period AS p " +
-                "WHERE a.periodid=p.periodid " +
-                "AND p.startdate>='" + startDate + "' " +
-                "AND p.enddate<='" + endDate + "'";
-   }
-   
-   public String unArchiveData( String startDate, String endDate ){
-       
-       return  "DELETE FROM datavaluearchive AS a " +
-           "USING period AS p " +
-           "WHERE a.periodid=p.periodid " +
-           "AND p.startdate>='" +  startDate + "' " +
-           "AND p.enddate<='" +  endDate + "'";
-   }
-   
-   public String deleteRegularOverlappingData(){
-       
-       return "DELETE FROM datavalue AS d " +
-           "USING datavaluearchive AS a " +
-           "WHERE d.dataelementid=a.dataelementid " +
-           "AND d.periodid=a.periodid " +
-           "AND d.sourceid=a.sourceid " +
-           "AND d.categoryoptioncomboid=a.categoryoptioncomboid";
-
-   }
-
-   public String deleteArchivedOverlappingData(){
-
-       return "DELETE FROM datavaluearchive AS a " +
-           "USING datavalue AS d " +
-           "WHERE a.dataelementid=d.dataelementid " +
-           "AND a.periodid=d.periodid " +
-           "AND a.sourceid=d.sourceid " +
-           "AND a.categoryoptioncomboid=d.categoryoptioncomboid";
-   }
-
-   public String deleteOldestOverlappingDataValue(){
-       
-       return "DELETE FROM datavalue AS d " +
-           "USING datavaluearchive AS a " +
-           "WHERE d.dataelementid=a.dataelementid " +
-           "AND d.periodid=a.periodid " +
-           "AND d.sourceid=a.sourceid " +
-           "AND d.categoryoptioncomboid=a.categoryoptioncomboid " +
-           "AND d.lastupdated<a.lastupdated";
-   }
-   
-   public String deleteOldestOverlappingArchiveData(){
-       
-       return "DELETE FROM datavaluearchive AS a " +
-           "USING datavalue AS d " +
-           "WHERE a.dataelementid=d.dataelementid " +
-           "AND a.periodid=d.periodid " +
-           "AND a.sourceid=d.sourceid " +
-           "AND a.categoryoptioncomboid=d.categoryoptioncomboid " +
-           "AND a.lastupdated<=d.lastupdated";
-   }
    
    public String archivePatientData ( String startDate, String endDate )
    {

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java	2010-11-24 23:33:43 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java	2010-11-29 14:51:31 +0000
@@ -221,73 +221,6 @@
             "OR CAST( dv.value AS " + getDoubleColumnType() + " ) > '" + upperBound + "' )";
     }
     
-    public String archiveData( String startDate, String endDate )
-    {
-       return "DELETE FROM datavalue AS a " +
-            "WHERE EXISTS (" +
-            "SELECT 1 FROM period AS p " +
-            "WHERE a.periodid=p.periodid " +
-            "AND p.startdate>='" + startDate + "' " +
-            "AND p.enddate<='" + endDate + "')";
-    }
-   
-    public String unArchiveData( String startDate, String endDate )
-    {
-       return "DELETE FROM datavaluearchive AS a " +
-           "WHERE EXISTS (" +
-           "SELECT 1 FROM period AS p " +
-           "WHERE a.periodid=p.periodid " +
-           "AND p.startdate>='" + startDate + "' " +
-           "AND p.enddate<='" + endDate + "')";
-    }
-   
-    public String deleteRegularOverlappingData()
-    {       
-       return "DELETE FROM datavalue AS d " +
-           "WHERE EXISTS (" +
-           "SELECT 1 FROM datavaluearchive AS a " +
-           "WHERE d.dataelementid=a.dataelementid " +
-           "AND d.periodid=a.periodid " +
-           "AND d.sourceid=a.sourceid " +
-           "AND d.categoryoptioncomboid=a.categoryoptioncomboid)";
-
-    }
-
-    public String deleteArchivedOverlappingData()
-    {
-       return "DELETE FROM datavaluearchive AS a " +
-           "WHERE EXISTS (" +
-           "SELECT 1 FROM datavalue AS d " +
-           "WHERE a.dataelementid=d.dataelementid " +
-           "AND a.periodid=d.periodid " +
-           "AND a.sourceid=d.sourceid " +
-           "AND a.categoryoptioncomboid=d.categoryoptioncomboid)";
-    }
-
-    public String deleteOldestOverlappingDataValue()
-    {       
-       return "DELETE FROM datavalue AS d " +
-           "WHERE EXISTS (" +
-           "SELECT 1 FROM datavaluearchive AS a " +
-           "WHERE d.dataelementid=a.dataelementid " +
-           "AND d.periodid=a.periodid " +
-           "AND d.sourceid=a.sourceid " +
-           "AND d.categoryoptioncomboid=a.categoryoptioncomboid " +
-           "AND d.lastupdated<a.lastupdated)";
-    }
-   
-    public String deleteOldestOverlappingArchiveData()
-    {       
-       return "DELETE FROM datavaluearchive AS a " +
-           "WHERE EXISTS (" +
-           "SELECT 1 FROM datavalue AS d " +
-           "WHERE a.dataelementid=d.dataelementid " +
-           "AND a.periodid=d.periodid " +
-           "AND a.sourceid=d.sourceid " +
-           "AND a.categoryoptioncomboid=d.categoryoptioncomboid " +
-           "AND a.lastupdated<=d.lastupdated)";
-    }
-    
     public String archivePatientData ( String startDate, String endDate )
     {
         return "DELETE FROM patientdatavalue AS pdv " 

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java	2010-11-24 23:33:43 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java	2010-11-29 14:51:31 +0000
@@ -222,68 +222,7 @@
             "AND ( dv.value < '" + lowerBound + "' " +
             "OR  dv.value > '" + upperBound + "' )";
    }
-   
-    public String archiveData( String startDate, String endDate )
-    {
-        return "DELETE d FROM datavalue AS d " +
-             "INNER JOIN period as p " +
-             "WHERE d.periodid=p.periodid " +
-             "AND p.startdate>='" + startDate + "' " +
-             "AND p.enddate<='" + endDate + "'";
-    }
-    
-    public String unArchiveData( String startDate, String endDate )
-    {    
-        return "DELETE a FROM datavaluearchive AS a " +
-            "INNER JOIN period AS p " +
-            "WHERE a.periodid=p.periodid " +
-            "AND p.startdate>='" + startDate + "' " +
-            "AND p.enddate<='" + endDate + "'";
-    }
-    
-    public String deleteRegularOverlappingData()
-    {    
-        return "DELETE d FROM datavalue AS d " +
-            "INNER JOIN datavaluearchive AS a " +
-            "WHERE d.dataelementid=a.dataelementid " +
-            "AND d.periodid=a.periodid " +
-            "AND d.sourceid=a.sourceid " +
-            "AND d.categoryoptioncomboid=a.categoryoptioncomboid";
-
-    }
-    
-    public String deleteArchivedOverlappingData()
-    {
-        return "DELETE a FROM datavaluearchive AS a " +
-            "INNER JOIN datavalue AS d " +
-            "WHERE a.dataelementid=d.dataelementid " +
-            "AND a.periodid=d.periodid " +
-            "AND a.sourceid=d.sourceid " +
-            "AND a.categoryoptioncomboid=d.categoryoptioncomboid";
-    }
-    
-    public String deleteOldestOverlappingDataValue()
-    {    
-        return "DELETE d FROM datavalue AS d " +
-            "INNER JOIN datavaluearchive AS a " +
-            "WHERE d.dataelementid=a.dataelementid " +
-            "AND d.periodid=a.periodid " +
-            "AND d.sourceid=a.sourceid " +
-            "AND d.categoryoptioncomboid=a.categoryoptioncomboid " +
-            "AND d.lastupdated<a.lastupdated";
-    }
-    
-   public String deleteOldestOverlappingArchiveData()
-   {       
-        return "DELETE a FROM datavaluearchive AS a " +
-            "INNER JOIN datavalue AS d " +
-            "WHERE a.dataelementid=d.dataelementid " +
-            "AND a.periodid=d.periodid " +
-            "AND a.sourceid=d.sourceid " +
-            "AND a.categoryoptioncomboid=d.categoryoptioncomboid " +
-            "AND a.lastupdated<=d.lastupdated";
-   }
-    
+       
    public String archivePatientData ( String startDate, String endDate )
    {
        return "DELETE pdv FROM patientdatavalue AS pdv "

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java	2010-11-24 23:33:43 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java	2010-11-29 14:51:31 +0000
@@ -223,68 +223,7 @@
            "AND ( CAST( dv.value AS " + getDoubleColumnType() + " ) < '" + lowerBound + "' " +
            "OR CAST( dv.value AS " + getDoubleColumnType() + " ) > '" + upperBound + "' )";
     }
-    
-    public String archiveData( String startDate, String endDate )
-    {
-      return "DELETE FROM datavaluearchive AS a " +
-          "USING period AS p " +
-          "WHERE a.periodid=p.periodid " +
-          "AND p.startdate>='" + startDate + "' " +
-          "AND p.enddate<='" + endDate + "'";
-    }
-  
-
-    public String unArchiveData( String startDate, String endDate )
-    {
-      return "DELETE FROM datavaluearchive AS a " +
-          "USING period AS p " +
-          "WHERE a.periodid=p.periodid " +
-          "AND p.startdate>='" + startDate + "' " +
-          "AND p.enddate<='" + endDate + "'";
-    }
-  
-    public String deleteRegularOverlappingData()
-    {
-      return "DELETE FROM datavalue AS d " +
-          "USING datavaluearchive AS a " +
-          "WHERE d.dataelementid=a.dataelementid " +
-          "AND d.periodid=a.periodid " +
-          "AND d.sourceid=a.sourceid " +
-          "AND d.categoryoptioncomboid=a.categoryoptioncomboid";
-    }
-  
-    public String deleteArchivedOverlappingData()
-    {
-      return "DELETE FROM datavaluearchive AS a " +
-          "USING datavalue AS d " +
-          "WHERE a.dataelementid=d.dataelementid " +
-          "AND a.periodid=d.periodid " +
-          "AND a.sourceid=d.sourceid " +
-          "AND a.categoryoptioncomboid=d.categoryoptioncomboid";
-    }
-  
-    public String deleteOldestOverlappingDataValue()
-    {      
-      return "DELETE FROM datavalue AS d " +
-          "USING datavaluearchive AS a " +
-          "WHERE d.dataelementid=a.dataelementid " +
-          "AND d.periodid=a.periodid " +
-          "AND d.sourceid=a.sourceid " +
-          "AND d.categoryoptioncomboid=a.categoryoptioncomboid " +
-          "AND d.lastupdated<a.lastupdated";
-    }
-  
-    public String deleteOldestOverlappingArchiveData()
-    {      
-      return "DELETE FROM datavaluearchive AS a " +
-          "USING datavalue AS d " +
-          "WHERE a.dataelementid=d.dataelementid " +
-          "AND a.periodid=d.periodid " +
-          "AND a.sourceid=d.sourceid " +
-          "AND a.categoryoptioncomboid=d.categoryoptioncomboid " +
-          "AND a.lastupdated<=d.lastupdated";
-    }
-    
+        
     public String archivePatientData ( String startDate, String endDate )
     {
         return "DELETE FROM patientdatavalue AS pdv "