← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 22165: CurrentUserService, removed circular dependency

 

------------------------------------------------------------
revno: 22165
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2016-03-07 20:55:24 +0100
message:
  CurrentUserService, removed circular dependency
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/CurrentUserService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultCurrentUserService.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/mock/MockCurrentUserService.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.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/dataset/DataSetService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetService.java	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetService.java	2016-03-07 19:55:24 +0000
@@ -220,7 +220,13 @@
     int getDataSetCount();
 
     List<DataSet> getDataSetsBetween( int first, int max );
-
+    
+    /**
+     * Returns the data sets associated with the current user. If the current
+     * user has the ALL authority then all data sets are returned.
+     */
+    List<DataSet> getCurrentUserDataSets();
+    
     // -------------------------------------------------------------------------
     // DataSet LockExceptions
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/CurrentUserService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/CurrentUserService.java	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/CurrentUserService.java	2016-03-07 19:55:24 +0000
@@ -28,10 +28,8 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.List;
 import java.util.Set;
 
-import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 
 /**
@@ -80,10 +78,4 @@
      * Indicates whether the current user has been granted the given authority.
      */
     boolean currenUserIsAuthorized( String auth );
-    
-    /**
-     * Returns the data sets associated with the current user. If the current
-     * user has the ALL authority then all data sets are returned.
-     */
-    List<DataSet> getCurrentUserDataSets();
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java	2016-03-07 19:55:24 +0000
@@ -50,9 +50,11 @@
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.user.CurrentUserService;
+import org.hisp.dhis.user.User;
 import org.joda.time.DateTime;
 import org.springframework.transaction.annotation.Transactional;
 
+import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
 
 /**
@@ -289,6 +291,26 @@
         return getObjectsBetweenByName( i18nService, dataSetStore, name, first, max );
     }
 
+    @Override
+    public List<DataSet> getCurrentUserDataSets()
+    {
+        User user = currentUserService.getCurrentUser();
+        
+        if ( user == null )
+        {
+            return Lists.newArrayList();
+        }
+        
+        if ( user.isSuper() )
+        {
+            return getAllDataSets();
+        }
+        else
+        {
+            return i18n( i18nService, Lists.newArrayList( user.getUserCredentials().getAllDataSets() ) );
+        }
+    }
+    
     // -------------------------------------------------------------------------
     // DataSet LockExceptions
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultCurrentUserService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultCurrentUserService.java	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultCurrentUserService.java	2016-03-07 19:55:24 +0000
@@ -29,20 +29,12 @@
  */
 
 import java.util.HashSet;
-import java.util.List;
 import java.util.Set;
 
-import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.dataset.DataSetService;
-import org.hisp.dhis.i18n.I18nService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.security.spring.AbstractSpringSecurityCurrentUserService;
 import org.springframework.transaction.annotation.Transactional;
 
-import com.google.common.collect.Lists;
-
-import static org.hisp.dhis.i18n.I18nUtils.i18n;
-
 /**
  * @author Torgeir Lorange Ostby
  */
@@ -61,20 +53,6 @@
         this.userService = userService;
     }
 
-    private DataSetService dataSetService;
-
-    public void setDataSetService( DataSetService dataSetService )
-    {
-        this.dataSetService = dataSetService;
-    }
-
-    private I18nService i18nService;
-
-    public void setI18nService( I18nService service )
-    {
-        i18nService = service;
-    }
-
     // -------------------------------------------------------------------------
     // CurrentUserService implementation
     // -------------------------------------------------------------------------
@@ -122,24 +100,4 @@
         
         return user != null && user.getUserCredentials().isAuthorized( auth );
     }
-
-    @Override
-    public List<DataSet> getCurrentUserDataSets()
-    {
-        User user = getCurrentUser();
-        
-        if ( user == null )
-        {
-            return Lists.newArrayList();
-        }
-        
-        if ( user.isSuper() )
-        {
-            return dataSetService.getAllDataSets();
-        }
-        else
-        {
-            return i18n( i18nService, Lists.newArrayList( user.getUserCredentials().getAllDataSets() ) );
-        }
-    }
 }

=== 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	2016-03-07 18:04:27 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2016-03-07 19:55:24 +0000
@@ -830,8 +830,6 @@
 
   <bean id="org.hisp.dhis.user.CurrentUserService" class="org.hisp.dhis.user.DefaultCurrentUserService">
     <property name="userService" ref="org.hisp.dhis.user.UserService" />
-    <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
-    <property name="i18nService" ref="org.hisp.dhis.i18n.I18nService" />
   </bean>
 
   <bean id="org.hisp.dhis.user.UserSettingService" class="org.hisp.dhis.user.DefaultUserSettingService">

=== modified file 'dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/mock/MockCurrentUserService.java'
--- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/mock/MockCurrentUserService.java	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/mock/MockCurrentUserService.java	2016-03-07 19:55:24 +0000
@@ -30,18 +30,14 @@
 
 import java.util.Arrays;
 import java.util.HashSet;
-import java.util.List;
 import java.util.Set;
 
-import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.user.CurrentUserService;
 import org.hisp.dhis.user.User;
 import org.hisp.dhis.user.UserAuthorityGroup;
 import org.hisp.dhis.user.UserCredentials;
 
-import com.google.common.collect.Lists;
-
 /**
  * @author Lars Helge Overland
  */
@@ -116,10 +112,4 @@
     {
         return true;
     }
-
-    @Override
-    public List<DataSet> getCurrentUserDataSets()
-    {
-        return Lists.newArrayList();
-    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java	2016-03-07 19:55:24 +0000
@@ -50,6 +50,7 @@
 import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.expression.ExpressionService;
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.indicator.IndicatorService;
@@ -106,6 +107,9 @@
     {
         this.currentUserService = currentUserService;
     }
+    
+    @Autowired
+    private DataSetService dataSetService;
 
     @Autowired
     private IdentifiableObjectManager identifiableObjectManager;
@@ -231,7 +235,7 @@
 
         expressionService.substituteExpressions( indicators, null );
 
-        dataSets = currentUserService.getCurrentUserDataSets();
+        dataSets = dataSetService.getCurrentUserDataSets();
         
         Set<DataElementCategoryCombo> categoryComboSet = new HashSet<>();
         Set<DataElementCategory> categorySet = new HashSet<>();