← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17918: User group listing, membership check, faster implementation as average group size is higher than ...

 

------------------------------------------------------------
revno: 17918
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-01-08 18:25:12 +0100
message:
  User group listing, membership check, faster implementation as average group size is higher than average memberships per user.
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/usergroup/GetUserGroupListAction.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-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/usergroup/GetUserGroupListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/usergroup/GetUserGroupListAction.java	2014-12-18 11:41:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/usergroup/GetUserGroupListAction.java	2015-01-08 17:25:12 +0000
@@ -34,6 +34,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.hisp.dhis.paging.ActionPagingSupport;
 import org.hisp.dhis.user.CurrentUserService;
@@ -133,12 +134,17 @@
     private Map<UserGroup, Boolean> populateMemberShipMap( List<UserGroup> userGroups )
     {
         User currentUser = currentUserService.getCurrentUser();
-
+        
         Map<UserGroup, Boolean> map = new HashMap<>();
-
-        for( UserGroup ug : userGroups )
+        
+        if ( currentUser != null && currentUser.getGroups() != null )
         {
-            map.put( ug, ug.getMembers().contains( currentUser ) );
+            Set<UserGroup> members = currentUser.getGroups();
+            
+            for ( UserGroup ug : userGroups )
+            {
+                map.put( ug, members.contains( ug ) );
+            }
         }
 
         return map;