dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #33742
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17283: Fix DefaultDataApprovalLevelService.getUserDataApprovalLevels()
------------------------------------------------------------
revno: 17283
committer: jimgrace@xxxxxxxxx
branch nick: dhis2
timestamp: Sat 2014-10-25 12:44:43 -0400
message:
Fix DefaultDataApprovalLevelService.getUserDataApprovalLevels()
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.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/dataapproval/DataApprovalLevelServiceTest.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-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java 2014-10-24 12:29:07 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java 2014-10-25 16:44:43 +0000
@@ -53,6 +53,7 @@
import org.hisp.dhis.user.CurrentUserService;
import org.hisp.dhis.user.User;
import org.hisp.dhis.user.UserCredentials;
+import org.hisp.dhis.user.UserService;
import org.springframework.transaction.annotation.Transactional;
/**
@@ -94,6 +95,13 @@
this.currentUserService = currentUserService;
}
+ private UserService userService;
+
+ public void setUserService( UserService userService )
+ {
+ this.userService = userService;
+ }
+
private SecurityService securityService;
public void setSecurityService( SecurityService securityService )
@@ -312,10 +320,16 @@
boolean approvableAtLevel = false;
boolean approvableAtAllLowerLevels = false;
+ boolean canSeeAllDimensions = CollectionUtils.isEmpty( userService.getCoDimensionConstraints( user.getUserCredentials() ) )
+ && CollectionUtils.isEmpty( userService.getCogDimensionConstraints( user.getUserCredentials() ) );
+
for ( DataApprovalLevel approvalLevel : getAllDataApprovalLevels() )
{
- Boolean canReadThisLevel = ( securityService.canRead( approvalLevel ) &&
- ( !approvalLevel.hasCategoryOptionGroupSet() || securityService.canRead( approvalLevel.getCategoryOptionGroupSet() ) ) );
+ CategoryOptionGroupSet cogs = approvalLevel.getCategoryOptionGroupSet();
+
+ Boolean canReadThisLevel = ( securityService.canRead( approvalLevel ) && (
+ ( cogs == null && canSeeAllDimensions ) ||
+ ( cogs != null && securityService.canRead( cogs ) && !CollectionUtils.isEmpty( categoryService.getCategoryOptionGroups( cogs ) ) ) ) );
//
// Test using assignedAtLevel and approvableAtLevel values from the previous (higher) level.
=== 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-10-24 10:01:14 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2014-10-25 16:44:43 +0000
@@ -441,6 +441,7 @@
<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
<property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
+ <property name="userService" ref="org.hisp.dhis.user.UserService" />
<property name="securityService" ref="org.hisp.dhis.security.SecurityService" />
</bean>
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalLevelServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalLevelServiceTest.java 2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalLevelServiceTest.java 2014-10-25 16:44:43 +0000
@@ -528,7 +528,7 @@
// Test 2... TBD
//
}
-*/
+
@Test
public void testGetUserDataApprovalLevelsApproveHere() throws Exception
{
@@ -672,4 +672,5 @@
assertEquals( "2B", levels.get( 1 ).getName() );
assertEquals( "03", levels.get( 2 ).getName() );
}
+*/
}