dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15596
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5685: Fixed flaw in ProgramStageDataElementSortOrderComparator
------------------------------------------------------------
revno: 5685
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-01-10 20:34:51 +0100
message:
Fixed flaw in ProgramStageDataElementSortOrderComparator
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/comparator/ProgramStageDataElementSortOrderComparator.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/ProgramStageDataElementSortOrderComparator.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/comparator/ProgramStageDataElementSortOrderComparator.java 2012-01-06 04:56:54 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/comparator/ProgramStageDataElementSortOrderComparator.java 2012-01-10 19:34:51 +0000
@@ -34,25 +34,14 @@
public class ProgramStageDataElementSortOrderComparator
implements Comparator<ProgramStageDataElement>
{
-
@Override
- public int compare( ProgramStageDataElement programStageDataElement0,
- ProgramStageDataElement programStageDataElement1 )
+ public int compare( ProgramStageDataElement object0, ProgramStageDataElement object1 )
{
- if ( programStageDataElement0.getDataElement().getSortOrder() == null
- || programStageDataElement0.getDataElement().getSortOrder() == 0 )
- {
- return programStageDataElement0.getDataElement().getName()
- .compareTo( programStageDataElement1.getDataElement().getName() );
- }
- if ( programStageDataElement1.getDataElement().getSortOrder() == null
- || programStageDataElement1.getDataElement().getSortOrder() == 0 )
- {
- return programStageDataElement0.getDataElement().getName()
- .compareTo( programStageDataElement1.getDataElement().getName() );
- }
- return programStageDataElement0.getDataElement().getSortOrder()
- - programStageDataElement1.getDataElement().getSortOrder();
+ if ( object0.getDataElement().getSortOrder() == null )
+ {
+ return object1.getDataElement().getSortOrder() != null ? -1 : 0;
+ }
+
+ return object0.getDataElement().getSortOrder().compareTo( object1.getDataElement().getSortOrder() );
}
-
}