dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13970
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4588: Fixed Bug <847529> orgunit-orgunitgroupsetmembers-not-ordered. Sort by name.
------------------------------------------------------------
revno: 4588
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-09-15 10:25:07 +0700
message:
Fixed Bug <847529> orgunit-orgunitgroupsetmembers-not-ordered. Sort by name.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSet.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.vm
--
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/organisationunit/OrganisationUnitGroupSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSet.java 2011-05-05 21:14:56 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSet.java 2011-09-15 03:25:07 +0000
@@ -29,15 +29,19 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.hisp.dhis.common.AbstractIdentifiableObject;
+import org.hisp.dhis.organisationunit.comparator.OrganisationUnitGroupNameComparator;
/**
* @author Kristian Nordal
- * @version $Id: OrganisationUnitGroupSet.java 1905 2006-09-23 14:34:55Z torgeilo $
+ * @version $Id: OrganisationUnitGroupSet.java 1905 2006-09-23 14:34:55Z
+ * torgeilo $
*/
public class OrganisationUnitGroupSet
extends AbstractIdentifiableObject
@@ -47,10 +51,12 @@
*/
private static final long serialVersionUID = -221220579471558683L;
+ private static final Comparator<OrganisationUnitGroup> COMPARATOR = new OrganisationUnitGroupNameComparator();
+
+ private Set<OrganisationUnitGroup> organisationUnitGroups = new HashSet<OrganisationUnitGroup>();
+
private String description;
- private Set<OrganisationUnitGroup> organisationUnitGroups = new HashSet<OrganisationUnitGroup>();
-
private boolean compulsory;
// -------------------------------------------------------------------------
@@ -67,7 +73,7 @@
this.description = description;
this.compulsory = compulsory;
}
-
+
// -------------------------------------------------------------------------
// Logic
// -------------------------------------------------------------------------
@@ -75,15 +81,15 @@
public Collection<OrganisationUnit> getOrganisationUnits()
{
List<OrganisationUnit> units = new ArrayList<OrganisationUnit>();
-
+
for ( OrganisationUnitGroup group : organisationUnitGroups )
{
units.addAll( group.getMembers() );
}
-
+
return units;
}
-
+
public boolean isMemberOfOrganisationUnitGroups( OrganisationUnit organisationUnit )
{
for ( OrganisationUnitGroup group : organisationUnitGroups )
@@ -93,7 +99,7 @@
return true;
}
}
-
+
return false;
}
@@ -111,10 +117,19 @@
return group;
}
}
-
+
return null;
}
-
+
+ public List<OrganisationUnitGroup> getSortedGroups()
+ {
+ List<OrganisationUnitGroup> sortedGroups = new ArrayList<OrganisationUnitGroup>( organisationUnitGroups );
+
+ Collections.sort( sortedGroups, COMPARATOR );
+
+ return sortedGroups;
+ }
+
// -------------------------------------------------------------------------
// hashCode and equals
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitForm.vm 2011-08-18 15:12:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitForm.vm 2011-09-15 03:25:07 +0000
@@ -110,7 +110,7 @@
<td>
<select id="selectedGroups" name="selectedGroups">
<option value="-1">[ $i18n.getString( "select_group" ) ]</option>
- #foreach ( $group in $groupSet.organisationUnitGroups )
+ #foreach ( $group in $groupSet.getSortedGroups() )
<option value="$group.id">$group.name</option>
#end
</select>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.vm 2011-08-18 15:12:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.vm 2011-09-15 03:25:07 +0000
@@ -150,7 +150,7 @@
<td>
<select id="orgUnitGroups" name="orgUnitGroups">
<option value="-1">[ $i18n.getString( "select_group" ) ]</option>
- #foreach ( $group in $groupSet.organisationUnitGroups )
+ #foreach ( $group in $groupSet.getSortedGroups() )
<option value="$group.id" #if( $group.members.contains( $organisationUnit ) ) selected="selected" #end>$group.name</option>
#end
</select>