← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2232: Fixed test failed in data archive - Improved the (un)archive query is more visually view.

 

------------------------------------------------------------
revno: 2232
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2010-11-30 11:06:43 +0700
message:
  Fixed test failed in data archive - Improved the (un)archive query is more visually view.
modified:
  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/test/java/org/hisp/dhis/dataarchive/DataArchiveServiceTest.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-29 14:51:31 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataarchive/jdbc/JdbcDataArchiveStore.java	2010-11-30 04:06:43 +0000
@@ -73,24 +73,21 @@
     {
         // 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 ) + "' );";
+        final String criteria = 
+                    "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 ( " + criteria + " );";
+                
 
         log.info( sql );        
         jdbcTemplate.execute( sql );
         
         // Delete data from datavalue
         
-        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 ) + "' )";
+        sql = "DELETE FROM datavalue WHERE EXISTS ( " + criteria + " );";
         
         log.info( sql );        
         jdbcTemplate.execute( sql ); 
@@ -99,25 +96,21 @@
     public void unArchiveData( Date startDate, Date endDate )
     {
         // Move data from datavalue to datavaluearchive
+        final String criteria = 
+                    "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 ) + "'";
         
-        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 ) + "' );";
+        String sql = "INSERT INTO datavalue ( " + criteria + " );";
+                
 
         log.info( sql );        
         jdbcTemplate.execute( sql ); 
         
         // Delete data from datavalue
 
-        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 ) + "' )";
+        sql = "DELETE FROM datavaluearchive WHERE EXISTS ( " + criteria + " );";
         
         log.info( sql );        
         jdbcTemplate.execute( sql ); 

=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/dataarchive/DataArchiveServiceTest.java'
--- dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/dataarchive/DataArchiveServiceTest.java	2010-11-29 15:26:32 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/dataarchive/DataArchiveServiceTest.java	2010-11-30 04:06:43 +0000
@@ -32,7 +32,6 @@
 
 import java.util.Date;
 
-import org.junit.Ignore;
 import org.junit.Test;
 
 /**
@@ -67,7 +66,6 @@
      * operation, DataEliminationStrategy strategy );
      */
     @Test
-    @Ignore
     public void testArchiveData()
     {
         /*
@@ -101,8 +99,8 @@
         archivedValuesNo = dataArchiveService.archiveData( periodD.getStartDate(), periodD.getEndDate(),
             DataArchiveOperation.UNARCHIVE, DataEliminationStrategy.REGULAR );
 
-        assertSame( "6 records from 2005-05-01 to 2005-05-31 have been removed back into datavalue table."
-            + " So now, datavaluearchive contains 48 records only", 48, archivedValuesNo );
+        assertSame( "54 records from 2005-05-01 to 2005-05-31 have been removed back into datavalue table."
+            + " So now, datavaluearchive are empty", 0, archivedValuesNo );
 
         /*
          * STEP 4: Un-archives all datavaluearchive to datavalues from earliest