← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3778: Pushed method to service layer

 

------------------------------------------------------------
revno: 3778
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2011-05-28 23:53:18 +0200
message:
  Pushed method to service layer
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserService.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/DefaultUserService.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/AddDataSetAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/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-api/src/main/java/org/hisp/dhis/user/UserService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserService.java	2011-04-24 13:44:20 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserService.java	2011-05-28 21:53:18 +0000
@@ -2,6 +2,7 @@
 
 import java.util.Collection;
 
+import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 
 /*
@@ -244,6 +245,12 @@
      */
     Collection<UserAuthorityGroup> getUserRolesBetweenByName( String name, int first, int max );
 
+    void assignDataSetToUserRole( DataSet dataSet );
+
+    int getUserRoleCount();
+
+    int getUserRoleCountByName( String name );
+    
     // -------------------------------------------------------------------------
     // UserSettings
     // -------------------------------------------------------------------------
@@ -285,14 +292,5 @@
      * 
      * @param userSetting the UserSetting to delete.
      */
-    void deleteUserSetting( UserSetting userSetting );
-
-    // -------------------------------------------------------------------------
-    // UserRole
-    // -------------------------------------------------------------------------
-
-    int getUserRoleCount();
-
-    int getUserRoleCountByName( String name );
-    
+    void deleteUserSetting( UserSetting userSetting );    
 }

=== 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	2011-04-22 17:02:27 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java	2011-05-28 21:53:18 +0000
@@ -263,7 +263,7 @@
 
         return dataSetListByPeriodType;
     }
-
+    
     public Collection<DataElement> getDistinctDataElements( Collection<Integer> dataSetIdentifiers )
     {
         Collection<DataSet> dataSets = getDataSets( dataSetIdentifiers );
@@ -291,13 +291,15 @@
     public Collection<DataSet> getDataSetsForMobile(){
         return i18n( i18nService, dataSetStore.getDataSetsForMobile() );
     }
-    
-    public Collection<DataSet> getMobileDataSetsFromCategoryOption(int categoryOptionId){
-        return dataSetStore.getMobileDataSetsFromCategoryOption(categoryOptionId);
+
+    public Collection<DataSet> getMobileDataSetsFromCategoryOption( int categoryOptionId )
+    {
+        return dataSetStore.getMobileDataSetsFromCategoryOption( categoryOptionId );
     }
-    
-    public Collection<DataSet> getMobileDataSetsFromCategory(int categoryId){
-        return dataSetStore.getMobileDataSetsFromCategory(categoryId);
+
+    public Collection<DataSet> getMobileDataSetsFromCategory( int categoryId )
+    {
+        return dataSetStore.getMobileDataSetsFromCategory( categoryId );
     }
 
     @Override

=== 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	2011-04-24 13:44:20 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java	2011-05-28 21:53:18 +0000
@@ -4,6 +4,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.system.util.AuditLogUtil;
 
@@ -217,7 +218,7 @@
     {
         return userStore.getUsersWithoutOrganisationUnitCountByName( userName );
     }
-
+    
     // -------------------------------------------------------------------------
     // UserAuthorityGroup
     // -------------------------------------------------------------------------
@@ -262,6 +263,33 @@
         return userStore.getUserRolesBetweenByName( name, first, max );
     }
 
+    public int getUserRoleCount()
+    {
+        return userStore.getUserRoleCount();
+    }
+
+    public int getUserRoleCountByName( String name )
+    {
+        return userStore.getUserRoleCountByName( name );
+    }
+
+    public void assignDataSetToUserRole( DataSet dataSet )
+    {
+        User currentUser = currentUserService.getCurrentUser();
+
+        if ( !currentUserService.currentUserIsSuper() && currentUser != null )
+        {
+            UserCredentials userCredentials = getUserCredentials( currentUser );
+
+            for ( UserAuthorityGroup userAuthorityGroup : userCredentials.getUserAuthorityGroups() )
+            {
+                userAuthorityGroup.getDataSets().add( dataSet );
+
+                updateUserAuthorityGroup( userAuthorityGroup );
+            }
+        }
+    }
+    
     // -------------------------------------------------------------------------
     // UserCredentials
     // -------------------------------------------------------------------------
@@ -349,19 +377,4 @@
     {
         return userStore.getUserSetting( user, name );
     }
-
-    // -------------------------------------------------------------------------
-    // UserRole
-    // -------------------------------------------------------------------------
-
-    public int getUserRoleCount()
-    {
-        return userStore.getUserRoleCount();
-    }
-
-    public int getUserRoleCountByName( String name )
-    {
-        return userStore.getUserRoleCountByName( name );
-    }
-
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/AddDataSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/AddDataSetAction.java	2011-05-19 11:57:47 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/AddDataSetAction.java	2011-05-28 21:53:18 +0000
@@ -39,10 +39,6 @@
 import org.hisp.dhis.indicator.IndicatorService;
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
-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 org.hisp.dhis.user.UserService;
 
 import com.opensymphony.xwork2.Action;
@@ -79,13 +75,6 @@
         this.dataElementService = dataElementService;
     }
 
-    private CurrentUserService currentUserService;
-
-    public void setCurrentUserService( CurrentUserService currentUserService )
-    {
-        this.currentUserService = currentUserService;
-    }
-
     private UserService userService;
 
     public void setUserService( UserService userService )
@@ -199,25 +188,8 @@
 
         dataSetService.addDataSet( dataSet );
 
-        assignDataSetToUserRole( dataSet );
+        userService.assignDataSetToUserRole( dataSet );
 
         return SUCCESS;
     }
-
-    private void assignDataSetToUserRole( DataSet dataSet )
-    {
-        User currentUser = currentUserService.getCurrentUser();
-
-        if ( !currentUserService.currentUserIsSuper() && currentUser != null )
-        {
-            UserCredentials userCredentials = userService.getUserCredentials( currentUser );
-
-            for ( UserAuthorityGroup userAuthorityGroup : userCredentials.getUserAuthorityGroups() )
-            {
-                userAuthorityGroup.getDataSets().add( dataSet );
-
-                userService.updateUserAuthorityGroup( userAuthorityGroup );
-            }
-        }
-    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java	2011-05-19 16:03:22 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java	2011-05-28 21:53:18 +0000
@@ -182,7 +182,7 @@
 
         if ( dataSet.isMobile() )
         {
-            dataSet.setVersion( dataSet.getVersion() + 1 ); // TODO we should check if anything is actually updated before bumping version and push this to service layer
+            dataSet.setVersion( dataSet.getVersion() + 1 ); // TODO hack
         }
 
         dataSetService.updateDataSet( dataSet );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml	2011-05-19 17:07:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml	2011-05-28 21:53:18 +0000
@@ -281,9 +281,6 @@
 		<property name="userService">
 			<ref bean="org.hisp.dhis.user.UserService"/>
 		</property>
-		<property name="currentUserService">
-			<ref bean="org.hisp.dhis.user.CurrentUserService"/>
-		</property>
 	</bean>
 	
 	<bean id="org.hisp.dhis.dataset.action.UpdateDataSetAction"