← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15120: Simplification in GetDataSetsAction

 

------------------------------------------------------------
revno: 15120
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-04-30 10:46:25 +0200
message:
  Simplification in GetDataSetsAction
modified:
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataSetsAction.java
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml


--
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-commons/src/main/java/org/hisp/dhis/commons/action/GetDataSetsAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataSetsAction.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataSetsAction.java	2014-04-30 08:46:25 +0000
@@ -30,9 +30,7 @@
 
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
 
 import org.apache.struts2.ServletActionContext;
 import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
@@ -42,8 +40,6 @@
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.user.CurrentUserService;
 import org.hisp.dhis.user.User;
-import org.hisp.dhis.user.UserAuthorityGroup;
-import org.hisp.dhis.user.UserService;
 import org.hisp.dhis.util.ContextUtils;
 
 /**
@@ -77,13 +73,6 @@
         this.currentUserService = currentUserService;
     }
 
-    private UserService userService;
-
-    public void setUserService( UserService userService )
-    {
-        this.userService = userService;
-    }
-
     // -------------------------------------------------------------------------
     // Output
     // -------------------------------------------------------------------------
@@ -139,18 +128,11 @@
 
         if ( !currentUserService.currentUserIsSuper() )
         {
-            Set<DataSet> accessibleDataSets = new HashSet<DataSet>();
-
             User user = currentUserService.getCurrentUser();
             
-            if ( user != null )
+            if ( user != null && user.getUserCredentials() != null )
             {
-                for ( UserAuthorityGroup u : userService.getUserCredentials( user ).getUserAuthorityGroups() )
-                {
-                    accessibleDataSets.addAll( u.getDataSets() );
-                }
-                
-                dataSets.retainAll( accessibleDataSets );
+                dataSets.retainAll( user.getUserCredentials().getAllDataSets() );
             }            
         }
 

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml	2014-04-05 20:24:59 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml	2014-04-30 08:46:25 +0000
@@ -396,7 +396,6 @@
     <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
     <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
     <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
-    <property name="userService" ref="org.hisp.dhis.user.UserService" />
   </bean>
 
   <bean id="org.hisp.dhis.commons.action.GetExpressionTextAction" class="org.hisp.dhis.commons.action.GetExpressionTextAction"