dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13276
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4203: Made SetSorter (inner class of GetOrganisationUnitTreeAction) generic. Will move out if functiona...
------------------------------------------------------------
revno: 4203
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-07-25 11:32:54 +0200
message:
Made SetSorter (inner class of GetOrganisationUnitTreeAction) generic. Will move out if functionality is needed elsewhere.
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-24 15:07:45 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitTree.vm 2011-07-25 09:32:54 +0000
@@ -6,7 +6,7 @@
"hasChildren": #if( $organisationUnit.children.size() > 0 )true,#{else}false#end
#if( $organisationUnit.children.size() > 0 )
"children": [
- #set( $children = $sorter.sortOrganisationUnitSet( $organisationUnit.children ) )
+ #set( $children = $sorter.sort( $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-24 15:07:45 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitTreeAction.java 2011-07-25 09:32:54 +0000
@@ -88,20 +88,27 @@
return organisationUnits;
}
- public class SetSorter
+ public class SetSorter<T>
{
- public Set<OrganisationUnit> sortOrganisationUnitSet( Set<OrganisationUnit> organisationUnits )
- {
- SortedSet<OrganisationUnit> sortedSet = new TreeSet<OrganisationUnit>( organisationUnitComparator );
- sortedSet.addAll( organisationUnits );
+ private Comparator<T> comparator;
+
+ public SetSorter( Comparator<T> comparator )
+ {
+ this.comparator = comparator;
+ }
+
+ public Set<T> sort( Set<T> unsortedSet )
+ {
+ SortedSet<T> sortedSet = new TreeSet<T>( comparator );
+ sortedSet.addAll( unsortedSet );
return sortedSet;
}
}
- public SetSorter getSorter()
+ public SetSorter<OrganisationUnit> getSorter()
{
- return new SetSorter();
+ return new SetSorter<OrganisationUnit>( organisationUnitComparator );
}
// -------------------------------------------------------------------------