← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10395: Analytics, fixed bug related to period sorting

 

------------------------------------------------------------
revno: 10395
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-03-22 08:57:02 +0100
message:
  Analytics, fixed bug related to period sorting
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/comparator/AscendingPeriodComparator.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/comparator/PeriodComparator.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.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-api/src/main/java/org/hisp/dhis/period/comparator/AscendingPeriodComparator.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/comparator/AscendingPeriodComparator.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/comparator/AscendingPeriodComparator.java	2013-03-22 07:57:02 +0000
@@ -35,11 +35,12 @@
  * Sorts periods ascending based on the start date, then the end date.
  * 
  * @author Lars Helge Overland
- * @version $Id$
  */
 public class AscendingPeriodComparator
     implements Comparator<Period>
 {
+    public static final AscendingPeriodComparator INSTANCE = new AscendingPeriodComparator();
+    
     public int compare( Period period1, Period period2 )
     {
         if ( period1.getStartDate() == null )

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/comparator/PeriodComparator.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/comparator/PeriodComparator.java	2013-02-01 11:45:27 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/comparator/PeriodComparator.java	2013-03-22 07:57:02 +0000
@@ -35,7 +35,6 @@
  * Sorts periods descending based on the start date, then the end date.
  * 
  * @author Lars Helge Overland
- * @version $Id$
  */
 public class PeriodComparator
     implements Comparator<Period>

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java	2013-03-21 15:07:48 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java	2013-03-22 07:57:02 +0000
@@ -35,8 +35,8 @@
 import static org.hisp.dhis.analytics.DataQueryParams.DATASET_DIM_ID;
 import static org.hisp.dhis.analytics.DataQueryParams.DATA_X_DIM_ID;
 import static org.hisp.dhis.analytics.DataQueryParams.DIMENSION_SEP;
+import static org.hisp.dhis.analytics.DataQueryParams.DISPLAY_NAME_CATEGORYOPTIONCOMBO;
 import static org.hisp.dhis.analytics.DataQueryParams.DISPLAY_NAME_DATA_X;
-import static org.hisp.dhis.analytics.DataQueryParams.DISPLAY_NAME_CATEGORYOPTIONCOMBO;
 import static org.hisp.dhis.analytics.DataQueryParams.DISPLAY_NAME_ORGUNIT;
 import static org.hisp.dhis.analytics.DataQueryParams.DISPLAY_NAME_PERIOD;
 import static org.hisp.dhis.analytics.DataQueryParams.FIXED_DIMS;
@@ -98,7 +98,7 @@
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.period.RelativePeriodEnum;
 import org.hisp.dhis.period.RelativePeriods;
-import org.hisp.dhis.period.comparator.PeriodComparator;
+import org.hisp.dhis.period.comparator.AscendingPeriodComparator;
 import org.hisp.dhis.system.grid.ListGrid;
 import org.hisp.dhis.system.util.ConversionUtils;
 import org.hisp.dhis.system.util.DebugUtils;
@@ -573,7 +573,7 @@
         
         if ( PERIOD_DIM_ID.equals( dimension ) )
         {
-            List<Period> periods = new ArrayList<Period>();
+            Set<Period> periods = new HashSet<Period>();
             
             for ( String isoPeriod : options )
             {
@@ -604,7 +604,7 @@
             }
 
             List<Period> periodList = new ArrayList<Period>( periods );
-            Collections.sort( periodList, PeriodComparator.INSTANCE );
+            Collections.sort( periodList, AscendingPeriodComparator.INSTANCE );
             
             return Arrays.asList( new Dimension( dimension, DimensionType.PERIOD, null, DISPLAY_NAME_PERIOD, asList( periodList ) ) );
         }