← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16289: Fixed bug for sorting program-stages with the same scheduled-days-from-start.

 

------------------------------------------------------------
revno: 16289
committer: Tran Chau<tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-08-01 14:17:10 +0700
message:
  Fixed bug for sorting program-stages with the same scheduled-days-from-start.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/comparator/ProgramStageMinDaysComparator.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/program/comparator/ProgramStageMinDaysComparator.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/comparator/ProgramStageMinDaysComparator.java	2014-05-23 15:28:46 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/comparator/ProgramStageMinDaysComparator.java	2014-08-01 07:17:10 +0000
@@ -28,10 +28,10 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.Comparator;
+
 import org.hisp.dhis.program.ProgramStage;
 
-import java.util.Comparator;
-
 /**
  * @author Chau Thu Tran
  * @version $ProgramStageMinDaysComparator.java Jun 12, 2012 3:22:20 PM$
@@ -40,6 +40,20 @@
 {
     public int compare( ProgramStage programStage1, ProgramStage programStage2 )
     {
-        return programStage1.getMinDaysFromStart() - programStage2.getMinDaysFromStart();
+        if(  programStage1.getMinDaysFromStart() != programStage2.getMinDaysFromStart() )
+        {
+            return programStage1.getMinDaysFromStart() - programStage2.getMinDaysFromStart();
+        }
+        
+        if ( programStage1.getCreated().before( programStage2.getCreated() ) )
+        {
+            return -1;
+        }
+        else if ( programStage1.getCreated().after( programStage2.getCreated() ) )
+        {
+            return 1;
+        }
+        
+        return 0;
     }
 }