← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17805: Cleaned up unnecessary user service code

 

------------------------------------------------------------
revno: 17805
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2014-12-27 12:19:18 +0100
message:
  Cleaned up unnecessary user service 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/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/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/user/UserStoreTest.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/GetOrgunitUserListAction.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-26 18:56:34 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentialsStore.java	2014-12-27 11:19:18 +0000
@@ -111,10 +111,6 @@
 
     Collection<UserCredentials> getUsersBetweenByName( String name, int first, int max );
 
-    Collection<UserCredentials> getUsersWithoutOrganisationUnitBetween( int first, int max );
-
-    Collection<UserCredentials> getUsersWithoutOrganisationUnitBetweenByName( String name, int first, int max );
-
     Collection<UserCredentials> getUsersByOrganisationUnitBetween( OrganisationUnit orgUnit, int first, int max );
 
     Collection<UserCredentials> getUsersByOrganisationUnitBetweenByName( OrganisationUnit orgUnit, String name,
@@ -136,10 +132,6 @@
 
     int getUserCountByName( String name );
 
-    int getUsersWithoutOrganisationUnitCount();
-
-    int getUsersWithoutOrganisationUnitCountByName( String name );
-
     int getUsersByOrganisationUnitCount( OrganisationUnit orgUnit );
 
     int getUsersByOrganisationUnitCountByName( OrganisationUnit orgUnit, String name );

=== 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-26 22:47:28 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserService.java	2014-12-27 11:19:18 +0000
@@ -94,18 +94,6 @@
     Collection<User> getUsersByLastUpdated( Date lastUpdated );
 
     /**
-     * Returns a Collection of the Users which are not associated with any
-     * OrganisationUnits.
-     *
-     * @return a Collection of Users.
-     */
-    Collection<User> getUsersWithoutOrganisationUnit();
-
-    int getUsersWithoutOrganisationUnitCount();
-
-    int getUsersWithoutOrganisationUnitCountByName( String name );
-
-    /**
      * Returns a Collection of Users which are having given Phone number.
      *
      * @param phoneNumber
@@ -290,10 +278,6 @@
 
     Collection<UserCredentials> getUsersBetweenByName( String name, int first, int max );
 
-    Collection<UserCredentials> getUsersWithoutOrganisationUnitBetween( int first, int max );
-
-    Collection<UserCredentials> getUsersWithoutOrganisationUnitBetweenByName( String name, int first, int max );
-
     Collection<UserCredentials> getUsersByOrganisationUnitBetween( OrganisationUnit orgUnit, int first, int max );
 
     Collection<UserCredentials> getUsersByOrganisationUnitBetweenByName( OrganisationUnit orgUnit, String name, int first, int max );

=== 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-26 22:47:28 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserStore.java	2014-12-27 11:19:18 +0000
@@ -42,14 +42,6 @@
     String ID = UserStore.class.getName();
 
     /**
-     * Returns a Collection of the Users which are not associated with any
-     * OrganisationUnits.
-     * 
-     * @return a Collection of Users.
-     */
-    Collection<User> getUsersWithoutOrganisationUnit();
-
-    /**
      * Returns a Collection of Users which are having given Phone number.
      * 
      * @param phoneNumber

=== 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-26 22:47:28 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java	2014-12-27 11:19:18 +0000
@@ -258,24 +258,6 @@
     }
 
     @Override
-    public Collection<User> getUsersWithoutOrganisationUnit()
-    {
-        return userStore.getUsersWithoutOrganisationUnit();
-    }
-
-    @Override
-    public int getUsersWithoutOrganisationUnitCount()
-    {
-        return userCredentialsStore.getUsersWithoutOrganisationUnitCount();
-    }
-
-    @Override
-    public int getUsersWithoutOrganisationUnitCountByName( String userName )
-    {
-        return userCredentialsStore.getUsersWithoutOrganisationUnitCountByName( userName );
-    }
-
-    @Override
     public User searchForUser( String query )
     {
         User user = userStore.getByUid( query );
@@ -650,18 +632,6 @@
     }
 
     @Override
-    public Collection<UserCredentials> getUsersWithoutOrganisationUnitBetween( int first, int max )
-    {
-        return userCredentialsStore.getUsersWithoutOrganisationUnitBetween( first, max );
-    }
-
-    @Override
-    public Collection<UserCredentials> getUsersWithoutOrganisationUnitBetweenByName( String username, int first, int max )
-    {
-        return userCredentialsStore.getUsersWithoutOrganisationUnitBetweenByName( username, first, max );
-    }
-
-    @Override
     public Collection<UserCredentials> searchUsersByName( String name )
     {
         return userCredentialsStore.searchUsersByName( name );

=== 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-26 18:56:34 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserCredentialsStore.java	2014-12-27 11:19:18 +0000
@@ -46,7 +46,6 @@
 import org.hisp.dhis.user.User;
 import org.hisp.dhis.user.UserCredentials;
 import org.hisp.dhis.user.UserCredentialsStore;
-import org.hisp.dhis.user.UserService;
 
 /**
  * TODO extend BaseIdentifiableObjectStore
@@ -66,13 +65,6 @@
     {
         this.sessionFactory = sessionFactory;
     }
-
-    private UserService userService;
-
-    public void setUserService( UserService userService )
-    {
-        this.userService = userService;
-    }
     
     // -------------------------------------------------------------------------
     // UserCredentials
@@ -294,30 +286,6 @@
     }
 
     @Override
-    public Collection<UserCredentials> getUsersWithoutOrganisationUnitBetween( int first, int max )
-    {
-        return getBlockUser( toUserCredentials( userService.getUsersWithoutOrganisationUnit() ), first, max );
-    }
-
-    @Override
-    public Collection<UserCredentials> getUsersWithoutOrganisationUnitBetweenByName( String name, int first, int max )
-    {
-        return getBlockUser( findByName( toUserCredentials( userService.getUsersWithoutOrganisationUnit() ), name ), first, max );
-    }
-
-    @Override
-    public int getUsersWithoutOrganisationUnitCount()
-    {
-        return userService.getUsersWithoutOrganisationUnit().size();
-    }
-
-    @Override
-    public int getUsersWithoutOrganisationUnitCountByName( String name )
-    {
-        return findByName( toUserCredentials( userService.getUsersWithoutOrganisationUnit() ), name ).size();
-    }
-
-    @Override
     @SuppressWarnings("unchecked")
     public Collection<UserCredentials> getSelfRegisteredUserCredentials( int first, int max )
     {

=== 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-26 22:47:28 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserStore.java	2014-12-27 11:19:18 +0000
@@ -78,15 +78,6 @@
 
     @Override
     @SuppressWarnings("unchecked")
-    public List<User> getUsersWithoutOrganisationUnit()
-    {
-        String hql = "from User u where u.organisationUnits.size = 0";
-        
-        return sessionFactory.getCurrentSession().createQuery( hql ).list();
-    }
-
-    @Override
-    @SuppressWarnings("unchecked")
     public List<User> getUsersByPhoneNumber( String phoneNumber )
     {
         String hql = "from User u where u.phoneNumber = :phoneNumber";

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2014-12-23 10:59:45 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2014-12-27 11:19:18 +0000
@@ -271,7 +271,6 @@
 
   <bean id="org.hisp.dhis.user.UserCredentialsStore" class="org.hisp.dhis.user.hibernate.HibernateUserCredentialsStore">
     <property name="sessionFactory" ref="sessionFactory" />
-    <property name="userService" ref="org.hisp.dhis.user.UserService" />
   </bean>
 
   <bean id="org.hisp.dhis.user.UserGroupStore" class="org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore">

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/user/UserStoreTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/user/UserStoreTest.java	2014-12-26 18:56:34 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/user/UserStoreTest.java	2014-12-27 11:19:18 +0000
@@ -31,9 +31,7 @@
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
 
-import java.util.Collection;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -129,30 +127,4 @@
         assertNull( userStore.get( idA ) );
         assertNotNull( userStore.get( idB ) );
     }
-
-    @Test
-    public void testGetUsersWithoutOrganisationUnit()
-    {
-        User userA = createUser( 'A' );
-        User userB = createUser( 'B' );
-        User userC = createUser( 'C' );
-        User userD = createUser( 'D' );
-
-        userA.getOrganisationUnits().add( unit1 );
-        userA.getOrganisationUnits().add( unit2 );
-
-        userC.getOrganisationUnits().add( unit1 );
-        userC.getOrganisationUnits().add( unit2 );
-        
-        userStore.save( userA );
-        userStore.save( userB );
-        userStore.save( userC );
-        userStore.save( userD );
-        
-        Collection<User> users = userStore.getUsersWithoutOrganisationUnit();
-        
-        assertEquals( 2, users.size() );
-        assertTrue( users.contains( userB ) );
-        assertTrue( users.contains( userD ) );
-    }   
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/GetOrgunitUserListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/GetOrgunitUserListAction.java	2014-12-26 13:22:45 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/GetOrgunitUserListAction.java	2014-12-27 11:19:18 +0000
@@ -102,33 +102,15 @@
 
         if ( isNotBlank( key ) ) // Filter on key only if set
         {
-            if ( organisationUnit == null )
-            {
-                this.paging = createPaging( userService.getUsersWithoutOrganisationUnitCountByName( key ) );
-                
-                userCredentialsList = new ArrayList<>( userService.getUsersWithoutOrganisationUnitBetweenByName( key, paging.getStartPos(), paging.getPageSize() ) );
-            }
-            else 
-            {
-                this.paging = createPaging( userService.getUsersByOrganisationUnitCountByName( organisationUnit, key ) );
-                
-                userCredentialsList = new ArrayList<>( userService.getUsersByOrganisationUnitBetweenByName( organisationUnit, key, paging.getStartPos(), paging.getPageSize() ) );
-            }
+            this.paging = createPaging( userService.getUsersByOrganisationUnitCountByName( organisationUnit, key ) );
+                
+            userCredentialsList = new ArrayList<>( userService.getUsersByOrganisationUnitBetweenByName( organisationUnit, key, paging.getStartPos(), paging.getPageSize() ) );
         }
         else
         {
-            if ( organisationUnit == null )
-            {
-                this.paging = createPaging( userService.getUsersWithoutOrganisationUnitCount(  ) );
-                
-                userCredentialsList = new ArrayList<>( userService.getUsersWithoutOrganisationUnitBetween( paging.getStartPos(), paging.getPageSize() ) );
-            }
-            else 
-            {
-                this.paging = createPaging( userService.getUsersByOrganisationUnitCount( organisationUnit ) );
-                
-                userCredentialsList = new ArrayList<>( userService.getUsersByOrganisationUnitBetween( organisationUnit, paging.getStartPos(), paging.getPageSize() ) );
-            }
+            this.paging = createPaging( userService.getUsersByOrganisationUnitCount( organisationUnit ) );
+                
+            userCredentialsList = new ArrayList<>( userService.getUsersByOrganisationUnitBetween( organisationUnit, paging.getStartPos(), paging.getPageSize() ) );
         }
         
         userService.canUpdateUserCredentialsFilter( userCredentialsList );