dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13270
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4200: implemented sorting for GetOrganisationUnitTreeAction
------------------------------------------------------------
revno: 4200
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2011-07-24 17:07:45 +0200
message:
implemented sorting for GetOrganisationUnitTreeAction
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitTree.vm
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitTreeAction.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-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitTree.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitTree.vm 2011-07-21 15:16:53 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitTree.vm 2011-07-24 15:07:45 +0000
@@ -6,7 +6,8 @@
"hasChildren": #if( $organisationUnit.children.size() > 0 )true,#{else}false#end
#if( $organisationUnit.children.size() > 0 )
"children": [
- #foreach ( $child in $organisationUnit.children )
+ #set( $children = $sorter.sortOrganisationUnitSet( $organisationUnit.children ) )
+ #foreach ( $child in $children )
#expandOrganisationUnit( $child )#if( $velocityCount < $organisationUnit.children.size() ),#end
#end
]
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitTreeAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitTreeAction.java 2011-07-21 15:16:53 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitTreeAction.java 2011-07-24 15:07:45 +0000
@@ -31,6 +31,9 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
@@ -85,6 +88,22 @@
return organisationUnits;
}
+ public class SetSorter
+ {
+ public Set<OrganisationUnit> sortOrganisationUnitSet( Set<OrganisationUnit> organisationUnits )
+ {
+ SortedSet<OrganisationUnit> sortedSet = new TreeSet<OrganisationUnit>( organisationUnitComparator );
+ sortedSet.addAll( organisationUnits );
+
+ return sortedSet;
+ }
+ }
+
+ public SetSorter getSorter()
+ {
+ return new SetSorter();
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------