← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3726: updated UserGroup to implement IdentifiableObject

 

------------------------------------------------------------
revno: 3726
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-05-24 12:18:10 +0200
message:
  updated UserGroup to implement IdentifiableObject
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroup.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetUserGroupsAction.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/user/UserGroup.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroup.java	2011-05-05 21:14:56 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroup.java	2011-05-24 10:18:10 +0000
@@ -1,11 +1,13 @@
 package org.hisp.dhis.user;
 
-import java.io.Serializable;
 import java.util.HashSet;
 import java.util.Set;
 
+import org.apache.commons.lang.NotImplementedException;
+import org.hisp.dhis.common.IdentifiableObject;
+
 public class UserGroup
-    implements Serializable
+    implements IdentifiableObject
 {
     /**
      * Determines if a de-serialized file is compatible with this class.
@@ -110,5 +112,10 @@
     {
         this.members = members;
     }
-    
+
+    @Override
+    public String getUuid()
+    {
+        throw new NotImplementedException();
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetUserGroupsAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetUserGroupsAction.java	2011-05-24 08:00:01 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetUserGroupsAction.java	2011-05-24 10:18:10 +0000
@@ -33,6 +33,7 @@
 import java.util.ListIterator;
 
 import org.hisp.dhis.paging.ActionPagingSupport;
+import org.hisp.dhis.system.util.IdentifiableObjectUtils;
 import org.hisp.dhis.user.UserGroup;
 import org.hisp.dhis.user.UserGroupService;
 import org.hisp.dhis.user.comparator.UserGroupComparator;
@@ -84,7 +85,7 @@
 
         if ( key != null )
         {
-            filterByKey( key, true );
+            userGroups = IdentifiableObjectUtils.filterNameByKey( userGroups, key, true );
         }
 
         Collections.sort( userGroups, new UserGroupComparator() );
@@ -98,25 +99,4 @@
 
         return SUCCESS;
     }
-
-    private void filterByKey( String key, boolean ignoreCase )
-    {
-        ListIterator<UserGroup> iterator = userGroups.listIterator();
-
-        if ( ignoreCase )
-        {
-            key = key.toLowerCase();
-        }
-
-        while ( iterator.hasNext() )
-        {
-            UserGroup userGroup = iterator.next();
-            String name = ignoreCase ? userGroup.getName().toLowerCase() : userGroup.getName();
-
-            if ( name.indexOf( key ) == -1 )
-            {
-                iterator.remove();
-            }
-        }
-    }
 }