← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17812: User management, removed now outdated code

 

Merge authors:
  Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 17812 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-12-28 16:55:07 +0100
message:
  User management, removed now outdated code
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentialsStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserQueryParams.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserCredentialsStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserStore.java
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/user/UserServiceTest.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/UserController.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetUsernameListAction.java
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/messaging/action/FindUserAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/incoming/ReceivingSMSAction.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/UserCredentialsStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentialsStore.java	2014-12-28 14:39:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentialsStore.java	2014-12-28 14:47:38 +0000
@@ -29,7 +29,6 @@
  */
 
 import java.util.Collection;
-import java.util.Date;
 
 /**
  * @author Lars Helge Overland
@@ -97,28 +96,4 @@
     void deleteUserCredentials( UserCredentials userCredentials );
 
     UserCredentials getUserCredentialsByOpenID( String openId );
-    
-    Collection<UserCredentials> searchUsersByName( String key );
-
-    Collection<UserCredentials> searchUsersByName( String key, int first, int max );
-
-    Collection<UserCredentials> getUsersBetween( int first, int max );
-
-    Collection<UserCredentials> getUsersBetweenByName( String name, int first, int max );
-
-    Collection<UserCredentials> getSelfRegisteredUserCredentials( int first, int max );
-
-    int getSelfRegisteredUserCredentialsCount();
-
-    Collection<UserCredentials> getInactiveUsers( Date date );
-
-    Collection<UserCredentials> getInactiveUsers( Date date, int first, int max );
-
-    int getInactiveUsersCount( Date date );
-
-    int getUserCount();
-
-    int getUserCountByName( String name );
-
-    Collection<String> getUsernames( String key, Integer max );
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserQueryParams.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserQueryParams.java	2014-12-28 14:39:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserQueryParams.java	2014-12-28 14:54:14 +0000
@@ -39,6 +39,8 @@
 {
     private String query;
     
+    private String phoneNumber;
+    
     private User user;
     
     private boolean canManage;
@@ -88,6 +90,16 @@
         this.query = query;
     }
 
+    public String getPhoneNumber()
+    {
+        return phoneNumber;
+    }
+
+    public void setPhoneNumber( String phoneNumber )
+    {
+        this.phoneNumber = phoneNumber;
+    }
+
     public User getUser()
     {
         return user;

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserService.java	2014-12-28 14:15:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserService.java	2014-12-28 15:09:23 +0000
@@ -93,30 +93,14 @@
     Collection<User> getUsersByLastUpdated( Date lastUpdated );
 
     /**
-     * Returns a Collection of Users which are having given Phone number.
-     *
-     * @param phoneNumber
-     * @return a Collection of Users.
-     */
-    Collection<User> getUsersByPhoneNumber( String phoneNumber );
-
-    /**
      * Deletes a User.
      *
      * @param user the User to delete.
      */
     void deleteUser( User user );
 
-    int getUserCount();
-
-    int getUserCountByName( String name );
-
     List<User> getUsersByUid( List<String> uids );
 
-    User searchForUser( String query );
-
-    List<User> queryForUsers( String query );
-
     /**
      * Returns a set of CategoryOptionGroups that may be seen by the current
      * user, if the current user has any CategoryOptionGroupSet constraint(s).
@@ -143,10 +127,6 @@
 
     boolean isLastSuperRole( UserAuthorityGroup userAuthorityGroup );
 
-    Collection<User> getUsersByName( String name );
-
-    Collection<String> getUsernames( String query, Integer max );
-
     /**
      * Returns all users which are managed by the given user through its managed
      * groups association.
@@ -181,6 +161,8 @@
      */
     int getUserCount( UserQueryParams params );
     
+    List<User> getUsersByPhoneNumber( String phoneNumber );
+    
     /**
      * Tests whether the current user is allowed to create a user associated
      * with the given user group identifiers. Returns true if current user has 
@@ -279,44 +261,10 @@
      */
     void setLastLogin( String username );
 
-    Collection<UserCredentials> searchUsersByName( String key );
-
-    Collection<UserCredentials> searchUsersByName( String name, int first, int max );
-
-    Collection<UserCredentials> getUsersBetween( int first, int max );
-
-    Collection<UserCredentials> getUsersBetweenByName( String name, int first, int max );
-
-    Collection<UserCredentials> getSelfRegisteredUserCredentials( int first, int max );
-
-    int getSelfRegisteredUserCredentialsCount();
-
-    Collection<UserCredentials> getInactiveUsers( int months );
-
-    Collection<UserCredentials> getInactiveUsers( int months, int first, int max );
-
-    int getInactiveUsersCount( int months );
-
     int getActiveUsersCount( int days );
 
     int getActiveUsersCount( Date since );
 
-    /**
-     * Filters the given list of users based on whether the current
-     * user is allowed to update.
-     *
-     * @param users the list of users.
-     */
-    void canUpdateUsersFilter( Collection<User> users );
-
-    /**
-     * Filters the given list of user credentials based on whether the current
-     * user is allowed to update.
-     *
-     * @param userCredentials the list of user credentials.
-     */
-    void canUpdateUserCredentialsFilter( Collection<UserCredentials> userCredentials );
-
     boolean credentialsNonExpired( UserCredentials credentials );
     
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserStore.java	2014-12-28 14:15:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserStore.java	2014-12-28 14:54:14 +0000
@@ -28,7 +28,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.Collection;
 import java.util.List;
 
 import org.hisp.dhis.common.GenericIdentifiableObjectStore;
@@ -42,23 +41,6 @@
     String ID = UserStore.class.getName();
 
     /**
-     * Returns a Collection of Users which are having given Phone number.
-     * 
-     * @param phoneNumber
-     * @return a Collection of Users.
-     */
-    Collection<User> getUsersByPhoneNumber( String phoneNumber );
-
-    /**
-     * Returns all users with the given name. Matches on the first name and
-     * surname properties of the user.
-     * 
-     * @param name the name.
-     * @return a Collection of Users.
-     */
-    Collection<User> getUsersByName( String name );
-
-    /**
      * Returns a list of users based on the given query parameters.
      * 
      * @param params the user query parameters.

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java	2014-12-28 14:39:07 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java	2014-12-28 15:09:23 +0000
@@ -30,7 +30,6 @@
 
 import static org.hisp.dhis.setting.SystemSettingManager.KEY_CAN_GRANT_OWN_USER_AUTHORITY_GROUPS;
 
-import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Collection;
 import java.util.Date;
@@ -53,7 +52,6 @@
 import org.hisp.dhis.setting.SystemSettingManager;
 import org.hisp.dhis.system.filter.UserAuthorityGroupCanIssueFilter;
 import org.hisp.dhis.system.util.DateUtils;
-import org.hisp.dhis.system.util.Filter;
 import org.hisp.dhis.system.util.FilterUtils;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -261,48 +259,13 @@
     }
     
     @Override
-    public Collection<User> getUsersByPhoneNumber( String phoneNumber )
-    {
-        return userStore.getUsersByPhoneNumber( phoneNumber );
-    }
-
-    @Override
-    public Collection<User> getUsersByName( String name )
-    {
-        return userStore.getUsersByName( name );
-    }
-
-    @Override
-    public User searchForUser( String query )
-    {
-        User user = userStore.getByUid( query );
-
-        if ( user == null )
-        {
-            UserCredentials credentials = userCredentialsStore.getUserCredentialsByUsername( query );
-            user = credentials != null ? credentials.getUser() : null;
-        }
-
-        return user;
-    }
-
-    @Override
-    public List<User> queryForUsers( String query )
-    {
-        List<User> users = new ArrayList<>();
-
-        User uidUser = userStore.getByUid( query );
-
-        if ( uidUser != null )
-        {
-            users.add( uidUser );
-        }
-
-        users.addAll( userStore.getAllLikeName( query, 0, 1000 ) ); //TODO
-
-        return users;
-    }
-
+    public List<User> getUsersByPhoneNumber( String phoneNumber )
+    {
+        UserQueryParams params = new UserQueryParams();
+        params.setPhoneNumber( phoneNumber );
+        return getUsers( params );   
+    }
+    
     @Override
     public Set<CategoryOptionGroup> getCogDimensionConstraints( UserCredentials userCredentials )
     {
@@ -344,12 +307,6 @@
     }
 
     @Override
-    public Collection<String> getUsernames( String query, Integer max )
-    {
-        return userCredentialsStore.getUsernames( query, max );
-    }
-
-    @Override
     public boolean isSuperUser( UserCredentials userCredentials )
     {
         if ( userCredentials == null )
@@ -623,42 +580,6 @@
     }
 
     @Override
-    public Collection<UserCredentials> getUsersBetween( int first, int max )
-    {
-        return userCredentialsStore.getUsersBetween( first, max );
-    }
-
-    @Override
-    public Collection<UserCredentials> getUsersBetweenByName( String username, int first, int max )
-    {
-        return userCredentialsStore.getUsersBetweenByName( username, first, max );
-    }
-
-    @Override
-    public int getUserCount()
-    {
-        return userCredentialsStore.getUserCount();
-    }
-
-    @Override
-    public int getUserCountByName( String userName )
-    {
-        return userCredentialsStore.getUserCountByName( userName );
-    }
-
-    @Override
-    public Collection<UserCredentials> searchUsersByName( String name )
-    {
-        return userCredentialsStore.searchUsersByName( name );
-    }
-
-    @Override
-    public Collection<UserCredentials> searchUsersByName( String name, int first, int max )
-    {
-        return userCredentialsStore.searchUsersByName( name, first, max );
-    }
-
-    @Override
     public void setLastLogin( String username )
     {
         UserCredentials credentials = getUserCredentialsByUsername( username );
@@ -685,79 +606,6 @@
     }
     
     @Override
-    public Collection<UserCredentials> getSelfRegisteredUserCredentials( int first, int max )
-    {
-        return userCredentialsStore.getSelfRegisteredUserCredentials( first, max );
-    }
-
-    @Override
-    public int getSelfRegisteredUserCredentialsCount()
-    {
-        return userCredentialsStore.getSelfRegisteredUserCredentialsCount();
-    }
-
-    @Override
-    public Collection<UserCredentials> getInactiveUsers( int months )
-    {
-        Calendar cal = PeriodType.createCalendarInstance();
-        cal.add( Calendar.MONTH, (months * -1) );
-
-        return userCredentialsStore.getInactiveUsers( cal.getTime() );
-    }
-
-    @Override
-    public Collection<UserCredentials> getInactiveUsers( int months, int first, int max )
-    {
-        Calendar cal = PeriodType.createCalendarInstance();
-        cal.add( Calendar.MONTH, (months * -1) );
-
-        return userCredentialsStore.getInactiveUsers( cal.getTime(), first, max );
-    }
-
-    @Override
-    public int getInactiveUsersCount( int months )
-    {
-        Calendar cal = PeriodType.createCalendarInstance();
-        cal.add( Calendar.MONTH, (months * -1) );
-
-        return userCredentialsStore.getInactiveUsersCount( cal.getTime() );
-    }
-
-    @Override
-    public void canUpdateUsersFilter( Collection<User> users )
-    {
-        final UserCredentials currentUserCredentials = currentUserService.getCurrentUser().getUserCredentials();
-        final boolean canGrantOwnUserAuthorityGroups = (Boolean) systemSettingManager.getSystemSetting( KEY_CAN_GRANT_OWN_USER_AUTHORITY_GROUPS, false );
-
-        FilterUtils.filter( users, new Filter<User>() {
-            @Override
-            public boolean retain( User user )
-            {
-                UserCredentials userCredentials = user.getUserCredentials();
-                
-                return currentUserCredentials != null && userCredentials != null
-                    && currentUserCredentials.canIssueUserRoles( userCredentials.getUserAuthorityGroups(), canGrantOwnUserAuthorityGroups );
-            }
-        } );
-    }
-
-    @Override
-    public void canUpdateUserCredentialsFilter( Collection<UserCredentials> userCredentials )
-    {
-        final UserCredentials currentUserCredentials = currentUserService.getCurrentUser().getUserCredentials();
-        final boolean canGrantOwnUserAuthorityGroups = (Boolean) systemSettingManager.getSystemSetting( KEY_CAN_GRANT_OWN_USER_AUTHORITY_GROUPS, false );
-
-        FilterUtils.filter( userCredentials, new Filter<UserCredentials>() {
-            @Override
-            public boolean retain( UserCredentials userCredentials )
-            {
-                return currentUserCredentials != null && userCredentials != null
-                    && currentUserCredentials.canIssueUserRoles( userCredentials.getUserAuthorityGroups(), canGrantOwnUserAuthorityGroups );
-            }
-        } );
-    }
-
-    @Override
     public boolean credentialsNonExpired( UserCredentials credentials )
     {
         int credentialsExpires = systemSettingManager.credentialsExpires();

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserCredentialsStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserCredentialsStore.java	2014-12-28 14:39:07 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserCredentialsStore.java	2014-12-28 14:47:38 +0000
@@ -29,16 +29,10 @@
  */
 
 import java.util.Collection;
-import java.util.Date;
 
-import org.hibernate.Criteria;
 import org.hibernate.Query;
 import org.hibernate.Session;
 import org.hibernate.SessionFactory;
-import org.hibernate.criterion.Disjunction;
-import org.hibernate.criterion.Order;
-import org.hibernate.criterion.Projections;
-import org.hibernate.criterion.Restrictions;
 import org.hisp.dhis.user.User;
 import org.hisp.dhis.user.UserCredentials;
 import org.hisp.dhis.user.UserCredentialsStore;
@@ -139,183 +133,4 @@
 
         session.delete( userCredentials );
     }
-
-    @Override
-    public int getUserCount()
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Query query = session.createQuery( "select count(*) from UserCredentials" );
-
-        Number rs = (Number) query.uniqueResult();
-
-        return rs != null ? rs.intValue() : 0;
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public Collection<UserCredentials> searchUsersByName( String key )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( UserCredentials.class );
-        criteria.createAlias( "user", "user" );
-
-        Disjunction disjunction = Restrictions.disjunction();
-        disjunction.add( Restrictions.ilike( "user.surname", "%" + key + "%" ) );
-        disjunction.add( Restrictions.ilike( "user.firstName", "%" + key + "%" ) );
-        disjunction.add( Restrictions.ilike( "username", "%" + key + "%" ) );
-
-        criteria.add( disjunction );
-        criteria.addOrder( Order.asc( "username" ) );
-
-        return criteria.list();
-    }
-
-    @Override
-    @SuppressWarnings("unchecked")
-    public Collection<UserCredentials> searchUsersByName( String key, int first, int max )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( UserCredentials.class );
-        criteria.createAlias( "user", "user" );
-
-        Disjunction disjunction = Restrictions.disjunction();
-        disjunction.add( Restrictions.ilike( "user.surname", "%" + key + "%" ) );
-        disjunction.add( Restrictions.ilike( "user.firstName", "%" + key + "%" ) );
-        disjunction.add( Restrictions.ilike( "username", "%" + key + "%" ) );
-
-        criteria.add( disjunction );
-        criteria.addOrder( Order.asc( "username" ) );
-
-        criteria.setFirstResult( first );
-        criteria.setMaxResults( max );
-
-        return criteria.list();
-    }
-
-    @Override
-    public int getUserCountByName( String name )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( UserCredentials.class );
-
-        criteria.add( Restrictions.ilike( "username", "%" + name + "%" ) );
-
-        criteria.setProjection( Projections.rowCount() );
-
-        Number rs = (Number) criteria.uniqueResult();
-
-        return rs != null ? rs.intValue() : 0;
-    }
-
-    @Override
-    @SuppressWarnings("unchecked")
-    public Collection<UserCredentials> getUsersBetween( int first, int max )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        return session.createQuery( "from UserCredentials order by username" ).setFirstResult( first )
-            .setMaxResults( max ).list();
-    }
-
-    @Override
-    @SuppressWarnings("unchecked")
-    public Collection<UserCredentials> getUsersBetweenByName( String name, int first, int max )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( UserCredentials.class );
-
-        criteria.add( Restrictions.ilike( "username", "%" + name + "%" ) );
-        criteria.addOrder( Order.asc( "username" ) );
-        criteria.setFirstResult( first );
-        criteria.setMaxResults( max );
-
-        return criteria.list();
-    }
-
-    @Override
-    @SuppressWarnings("unchecked")
-    public Collection<UserCredentials> getSelfRegisteredUserCredentials( int first, int max )
-    {
-        Criteria criteria = sessionFactory.getCurrentSession().createCriteria( UserCredentials.class );
-        criteria.add( Restrictions.eq( "selfRegistered", true ) );
-        criteria.addOrder( Order.desc( "created" ) );
-        criteria.setFirstResult( first );
-        criteria.setMaxResults( max );
-
-        return criteria.list();
-    }
-
-    @Override
-    public int getSelfRegisteredUserCredentialsCount()
-    {
-        Criteria criteria = sessionFactory.getCurrentSession().createCriteria( UserCredentials.class );
-        criteria.add( Restrictions.eq( "selfRegistered", true ) );
-        criteria.setProjection( Projections.rowCount() );
-
-        Number rs = (Number) criteria.uniqueResult();
-
-        return rs != null ? rs.intValue() : 0;
-    }
-
-    @Override
-    @SuppressWarnings("unchecked")
-    public Collection<UserCredentials> getInactiveUsers( Date date )
-    {
-        Criteria criteria = sessionFactory.getCurrentSession().createCriteria( UserCredentials.class );
-        criteria.add( Restrictions.lt( "lastLogin", date ) );
-
-        return criteria.list();
-    }
-
-    @Override
-    @SuppressWarnings("unchecked")
-    public Collection<UserCredentials> getInactiveUsers( Date date, int first, int max )
-    {
-        Criteria criteria = sessionFactory.getCurrentSession().createCriteria( UserCredentials.class );
-        criteria.add( Restrictions.lt( "lastLogin", date ) );
-        criteria.setFirstResult( first );
-        criteria.setMaxResults( max );
-
-        return criteria.list();
-    }
-
-    @Override
-    public int getInactiveUsersCount( Date date )
-    {
-        Criteria criteria = sessionFactory.getCurrentSession().createCriteria( UserCredentials.class );
-        criteria.add( Restrictions.lt( "lastLogin", date ) );
-        criteria.setProjection( Projections.rowCount() );
-
-        Number rs = (Number) criteria.uniqueResult();
-
-        return rs != null ? rs.intValue() : 0;
-    }
-
-    @Override
-    @SuppressWarnings("unchecked")
-    public Collection<String> getUsernames( String key, Integer max )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        String hql = "select username from UserCredentials ";
-
-        if ( key != null )
-        {
-            hql += "where lower(username) like lower('%" + key + "%') ";
-        }
-
-        Query query = session.createQuery( hql );
-
-        if ( max != null )
-        {
-            query.setMaxResults( max );
-        }
-
-        return query.list();
-    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserStore.java	2014-12-28 14:39:07 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserStore.java	2014-12-28 15:55:07 +0000
@@ -32,10 +32,7 @@
 import java.util.List;
 import java.util.Set;
 
-import org.hibernate.Criteria;
 import org.hibernate.Query;
-import org.hibernate.criterion.Order;
-import org.hibernate.criterion.Restrictions;
 import org.hisp.dhis.common.IdentifiableObjectUtils;
 import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
 import org.hisp.dhis.system.util.SqlHelper;
@@ -50,58 +47,6 @@
     extends HibernateIdentifiableObjectStore<User>
     implements UserStore
 {
-    // -------------------------------------------------------------------------
-    // UserStore implementation
-    // -------------------------------------------------------------------------
-
-    @Override
-    @SuppressWarnings("unchecked")
-    public List<User> getAllOrderedName( int first, int max )
-    {
-        Criteria criteria = getCriteria();
-        criteria.addOrder( Order.asc( "surname" ) ).addOrder( Order.asc( "firstName" ) );
-        criteria.setFirstResult( first );
-        criteria.setMaxResults( max );
-        return criteria.list();
-    }
-
-    @Override
-    @SuppressWarnings("unchecked")
-    public List<User> getAllLikeName( String name, int first, int max )
-    {
-        Criteria criteria = getCriteria();
-        criteria.add( Restrictions.or( Restrictions.ilike( "surname", "%" + name + "%" ),
-            Restrictions.ilike( "firstName", "%" + name + "%" ) ) );
-        criteria.addOrder( Order.asc( "surname" ) ).addOrder( Order.asc( "firstName" ) );
-        criteria.setFirstResult( first );
-        criteria.setMaxResults( max );
-        return criteria.list();
-    }
-
-    @Override
-    @SuppressWarnings("unchecked")
-    public List<User> getUsersByPhoneNumber( String phoneNumber )
-    {
-        String hql = "from User u where u.phoneNumber = :phoneNumber";
-
-        Query query = sessionFactory.getCurrentSession().createQuery( hql );
-        query.setString( "phoneNumber", phoneNumber );
-
-        return query.list();
-    }
-
-    @Override
-    @SuppressWarnings("unchecked")
-    public List<User> getUsersByName( String name )
-    {
-        Criteria criteria = getCriteria();
-        criteria.add( Restrictions.or( Restrictions.ilike( "surname", "%" + name + "%" ),
-            Restrictions.ilike( "firstName", "%" + name + "%" ) ) );
-        criteria.addOrder( Order.asc( "surname" ) ).addOrder( Order.asc( "firstName" ) );
-
-        return criteria.list();
-    }
-    
     @Override
     @SuppressWarnings("unchecked")
     public List<User> getUsers( UserQueryParams params )
@@ -132,11 +77,15 @@
             hql += hlp.whereAnd() + " (" +
                 "lower(u.firstName) like :key " +
                 "or lower(u.email) like :key " +
-                "or lower(u.phoneNumber) like :key " +
                 "or lower(u.surname) like :key " +
                 "or lower(uc.username) like :key) ";
         }
         
+        if ( params.getPhoneNumber() != null )
+        {
+            hql += hlp.whereAnd() + " u.phoneNumber = :phoneNumber ";
+        }
+        
         if ( params.isCanManage() )
         {
             hql += hlp.whereAnd() + " g.id in (:ids) ";
@@ -193,6 +142,11 @@
             query.setString( "key", "%" + params.getQuery().toLowerCase() + "%" );
         }
         
+        if ( params.getPhoneNumber() != null )
+        {
+            query.setString( "phoneNumber", params.getPhoneNumber() );
+        }
+        
         if ( params.isCanManage() && params.getUser() != null )
         {
             Collection<Integer> managedGroups = IdentifiableObjectUtils.getIdentifiers( params.getUser().getManagedGroups() );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/user/UserServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/user/UserServiceTest.java	2014-12-28 14:15:49 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/user/UserServiceTest.java	2014-12-28 15:09:23 +0000
@@ -28,15 +28,15 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_CAN_GRANT_OWN_USER_AUTHORITY_GROUPS;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_CAN_GRANT_OWN_USER_AUTHORITY_GROUPS;
 
-import java.util.Collection;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 
 import org.hisp.dhis.DhisSpringTest;
@@ -220,6 +220,35 @@
     }
 
     @Test
+    public void testGetByPhoneNumber()
+    {
+        User userA = createUser( 'A' );
+        User userB = createUser( 'B' );
+        User userC = createUser( 'C' );
+        
+        userA.setPhoneNumber( "73647271" );
+        userB.setPhoneNumber( "23452134" );
+        userC.setPhoneNumber( "14543232" );
+
+        UserCredentials credentialsA = createUserCredentials( 'A', userA );
+        UserCredentials credentialsB = createUserCredentials( 'B', userB );
+        UserCredentials credentialsC = createUserCredentials( 'C', userC );
+        
+        userService.addUser( userA );
+        userService.addUser( userB );
+        userService.addUser( userC );
+        
+        userService.addUserCredentials( credentialsA );
+        userService.addUserCredentials( credentialsB );
+        userService.addUserCredentials( credentialsC );
+               
+        List<User> users = userService.getUsersByPhoneNumber( "23452134" );
+        
+        assertEquals( 1, users.size() );
+        assertEquals( userB, users.get( 0 ) );
+    }
+
+    @Test
     public void testGetManagedGroups()
     {
         User userA = createUser( 'A' );
@@ -265,7 +294,7 @@
         userGroupService.addUserGroup( userGroup1 );
         userGroupService.addUserGroup( userGroup2 );
         
-        Collection<User> users = userService.getManagedUsers( userA );
+        List<User> users = userService.getManagedUsers( userA );
         
         assertEquals( 4, users.size() );
         assertTrue( users.contains( userC ) );
@@ -364,7 +393,7 @@
         userGroupService.addUserGroup( userGroup1 );
         userGroupService.addUserGroup( userGroup2 );
         
-        Collection<User> users = userService.getManagedUsers( userA );
+        List<User> users = userService.getManagedUsers( userA );
         
         assertEquals( 4, users.size() );
         assertTrue( users.contains( userC ) );
@@ -452,7 +481,7 @@
         params.setAuthSubset( true );
         params.setUser( userA );
         
-        Collection<User> users = userService.getUsers( params );
+        List<User> users = userService.getUsers( params );
         
         assertEquals( 2, users.size() );
         assertTrue( users.contains( userD ) );
@@ -511,7 +540,7 @@
         UserQueryParams params = new UserQueryParams();
         params.setQuery( "rstnameA" );
         
-        Collection<User> users = userService.getUsers( params );
+        List<User> users = userService.getUsers( params );
         
         assertEquals( 1, users.size() );
         assertTrue( users.contains( userA ) );
@@ -548,7 +577,7 @@
         UserQueryParams params = new UserQueryParams();
         params.setSelfRegistered( true );
         
-        Collection<User> users = userService.getUsers( params );
+        List<User> users = userService.getUsers( params );
         
         assertEquals( 2, users.size() );
         assertTrue( users.contains( userA ) );
@@ -589,7 +618,7 @@
         UserQueryParams params = new UserQueryParams();
         params.setOrganisationUnit( unit1 );
         
-        Collection<User> users = userService.getUsers( params );
+        List<User> users = userService.getUsers( params );
         
         assertEquals( 2, users.size() );
         assertTrue( users.contains( userA ) );

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2014-11-12 17:27:29 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2014-12-28 14:54:14 +0000
@@ -114,6 +114,7 @@
 import org.hisp.dhis.trackedentitydatavalue.TrackedEntityDataValueService;
 import org.hisp.dhis.user.CurrentUserService;
 import org.hisp.dhis.user.User;
+import org.hisp.dhis.user.UserQueryParams;
 import org.hisp.dhis.user.UserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Required;
@@ -1935,7 +1936,9 @@
             }
         }
 
-        users = userService.getUsersByName( keyword );
+        UserQueryParams params = new UserQueryParams();
+        params.setQuery( keyword );        
+        users = userService.getUsers( params );
 
         for ( User userCore : users )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/UserController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/UserController.java	2014-12-28 14:15:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/UserController.java	2014-12-28 15:55:07 +0000
@@ -107,12 +107,13 @@
     {
         UserQueryParams params = new UserQueryParams();
         params.setQuery( options.get( "query" ) );
+        params.setPhoneNumber( options.get( "phoneNumber" ) );
         params.setCanManage( options.isTrue( "canManage" ) );
         params.setAuthSubset( options.isTrue( "authSubset" ) );
+        params.setLastLogin( options.getDate( "lastLogin" ) );
         params.setInactiveMonths( options.getInt( "inactiveMonths" ) );
+        params.setInactiveSince( options.getDate( "inactiveSince" ) );
         params.setSelfRegistered( options.isTrue( "selfRegistered" ) );
-        params.setFirst( options.getInt( "first" ) );
-        params.setMax( options.getInt( "max" ) );
         
         String ou = options.get( "ou" );
         

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetUsernameListAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetUsernameListAction.java	2014-10-16 06:17:19 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetUsernameListAction.java	2014-12-28 14:47:38 +0000
@@ -28,8 +28,12 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.List;
 
+import org.hisp.dhis.user.User;
+import org.hisp.dhis.user.UserQueryParams;
 import org.hisp.dhis.user.UserService;
 
 import com.opensymphony.xwork2.Action;
@@ -70,7 +74,7 @@
     // Output
     // -------------------------------------------------------------------------
 
-    private Collection<String> usernames;
+    private Collection<String> usernames = new ArrayList<>();
 
     public Collection<String> getUsernames()
     {
@@ -84,7 +88,16 @@
     @Override
     public String execute()
     {
-        usernames = userService.getUsernames( query, MAX_USER_DISPLAYED );
+        UserQueryParams params = new UserQueryParams();
+        params.setQuery( query );
+        params.setMax( MAX_USER_DISPLAYED );
+        
+        List<User> users = userService.getUsers( params );
+        
+        for ( User user : users )
+        {
+            usernames.add( user.getUsername() );
+        }
 
         return SUCCESS;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/messaging/action/FindUserAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/messaging/action/FindUserAction.java	2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/messaging/action/FindUserAction.java	2014-12-28 14:54:14 +0000
@@ -33,6 +33,7 @@
 import java.util.Set;
 
 import org.hisp.dhis.user.User;
+import org.hisp.dhis.user.UserQueryParams;
 import org.hisp.dhis.user.UserService;
 
 import com.opensymphony.xwork2.Action;
@@ -157,7 +158,9 @@
             }
         }
 
-        users = userService.getUsersByName( keyword );
+        UserQueryParams params = new UserQueryParams();
+        params.setQuery( keyword );        
+        users = userService.getUsers( params );
 
         if ( users.size() == 1 )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/incoming/ReceivingSMSAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/incoming/ReceivingSMSAction.java	2014-11-11 12:58:17 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/incoming/ReceivingSMSAction.java	2014-12-28 14:54:14 +0000
@@ -29,7 +29,6 @@
  */
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 
@@ -42,6 +41,7 @@
 import org.hisp.dhis.sms.incoming.SmsMessageStatus;
 import org.hisp.dhis.user.CurrentUserService;
 import org.hisp.dhis.user.User;
+import org.hisp.dhis.user.UserQueryParams;
 import org.hisp.dhis.user.UserService;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -234,7 +234,10 @@
             String phoneNumber = incomingSms.getOriginator();
             if ( !phoneNumber.isEmpty() )
             {
-                Collection<User> users = userService.getUsersByPhoneNumber( phoneNumber );
+                UserQueryParams params = new UserQueryParams();
+                params.setPhoneNumber( phoneNumber );                
+                List<User> users = userService.getUsers( params );
+                
                 if ( users == null || users.size() == 0 )
                 {
                     tempString += "[unknown]";