← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9283: wip

 

------------------------------------------------------------
revno: 9283
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-12-12 15:41:21 +0100
message:
  wip
modified:
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java
  dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/table/PartitionUtilsTest.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-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java	2012-12-11 20:46:36 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java	2012-12-12 14:41:21 +0000
@@ -37,12 +37,12 @@
 
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.period.QuarterlyPeriodType;
+import org.hisp.dhis.period.YearlyPeriodType;
 import org.hisp.dhis.system.util.ListMap;
 
 public class PartitionUtils
 {
-    private static final QuarterlyPeriodType QUARTERLY = new QuarterlyPeriodType();
+    private static final YearlyPeriodType PERIODTYPE = new YearlyPeriodType();
     
     private static final String SEP = "_";
 
@@ -55,7 +55,7 @@
         
         List<String> tables = new ArrayList<String>();
         
-        Period period = QUARTERLY.createPeriod( earliest );
+        Period period = PERIODTYPE.createPeriod( earliest );
         
         while ( period != null && period.getStartDate().before( latest ) )
         {
@@ -63,7 +63,7 @@
             
             tables.add( table );
             
-            period = QUARTERLY.getNextPeriod( period );
+            period = PERIODTYPE.getNextPeriod( period );
         }
         
         return tables;
@@ -78,7 +78,7 @@
             throw new IllegalArgumentException( "Illegal ISO period: " +  isoPeriod );
         }
         
-        Period quarter = QUARTERLY.createPeriod( period.getStartDate() );
+        Period quarter = PERIODTYPE.createPeriod( period.getStartDate() );
         
         return TABLE_NAME + SEP + quarter.getIsoDate();
     }

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/table/PartitionUtilsTest.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/table/PartitionUtilsTest.java	2012-12-11 20:46:36 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/table/PartitionUtilsTest.java	2012-12-12 14:41:21 +0000
@@ -37,7 +37,7 @@
 
 import org.hisp.dhis.period.Cal;
 import org.hisp.dhis.period.Period;
-import org.hisp.dhis.period.QuarterlyPeriodType;
+import org.hisp.dhis.period.YearlyPeriodType;
 import org.junit.Test;
 
 public class PartitionUtilsTest
@@ -47,25 +47,24 @@
     {
         Cal cal = new Cal();
         Date earliest = cal.set( 2000, 5, 4 ).time();
-        Date latest = cal.set( 2001, 2, 10 ).time();
+        Date latest = cal.set( 2003, 2, 10 ).time();
         
         List<String> tables = PartitionUtils.getTempTableNames( earliest, latest );
         
         assertEquals( 4, tables.size() );
-        assertTrue( tables.contains( TABLE_NAME_TEMP + "_2000Q2" ) );
-        assertTrue( tables.contains( TABLE_NAME_TEMP + "_2000Q3" ) );
-        assertTrue( tables.contains( TABLE_NAME_TEMP + "_2000Q4" ) );
-        assertTrue( tables.contains( TABLE_NAME_TEMP + "_2001Q1" ) );
+        assertTrue( tables.contains( TABLE_NAME_TEMP + "_2000" ) );
+        assertTrue( tables.contains( TABLE_NAME_TEMP + "_2001" ) );
+        assertTrue( tables.contains( TABLE_NAME_TEMP + "_2002" ) );
+        assertTrue( tables.contains( TABLE_NAME_TEMP + "_2003" ) );
     }
     
     @Test
     public void testGetTable()
     {
-        assertEquals( TABLE_NAME + "_2000Q4", PartitionUtils.getTable( "200011" ) );
-        assertEquals( TABLE_NAME + "_2000Q1", PartitionUtils.getTable( "2000W02" ) );
-        assertEquals( TABLE_NAME + "_2000Q2", PartitionUtils.getTable( "2000Q2" ) );
-        assertEquals( TABLE_NAME + "_2000Q3", PartitionUtils.getTable( "2000S2" ) );
-        assertEquals( TABLE_NAME + "_2000Q1", PartitionUtils.getTable( "2000" ) );
+        assertEquals( TABLE_NAME + "_2000", PartitionUtils.getTable( "200011" ) );
+        assertEquals( TABLE_NAME + "_2001", PartitionUtils.getTable( "2001W02" ) );
+        assertEquals( TABLE_NAME + "_2002", PartitionUtils.getTable( "2002Q2" ) );
+        assertEquals( TABLE_NAME + "_2003", PartitionUtils.getTable( "2003S2" ) );
     }
     
     @Test
@@ -73,10 +72,10 @@
     {
         Cal cal = new Cal();
         
-        Period q2 = new QuarterlyPeriodType().createPeriod( cal.set( 2000, 4, 1 ).time() );
-        Period q4 = new QuarterlyPeriodType().createPeriod( cal.set( 2000, 10, 1 ).time() );
+        Period p1 = new YearlyPeriodType().createPeriod( cal.set( 2000, 4, 1 ).time() );
+        Period p2 = new YearlyPeriodType().createPeriod( cal.set( 2001, 10, 1 ).time() );
         
-        assertEquals( q2, PartitionUtils.getPeriod( TABLE_NAME_TEMP + "_2000Q2" ) );
-        assertEquals( q4, PartitionUtils.getPeriod( TABLE_NAME_TEMP + "_2000Q4" ) );
+        assertEquals( p1, PartitionUtils.getPeriod( TABLE_NAME_TEMP + "_2000" ) );
+        assertEquals( p2, PartitionUtils.getPeriod( TABLE_NAME_TEMP + "_2001" ) );
     }
 }