← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17755: Approval, more debug friendly code

 

------------------------------------------------------------
revno: 17755
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-12-19 18:25:26 +0100
message:
  Approval, more debug friendly code
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.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-11-10 11:43:54 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java	2014-12-19 17:25:26 +0000
@@ -37,6 +37,8 @@
 import java.util.Set;
 
 import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.dataelement.CategoryOptionGroupSet;
 import org.hisp.dhis.dataelement.DataElementCategoryOption;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
@@ -62,6 +64,8 @@
 public class DefaultDataApprovalLevelService
     implements DataApprovalLevelService
 {
+    private static final Log log = LogFactory.getLog( DefaultDataApprovalLevelService.class );
+    
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -150,7 +154,9 @@
 
         tracePrint( "getHighestDataApprovalLevel - data approval level count: " + getAllDataApprovalLevels().size() );
 
-        for ( DataApprovalLevel level : getUserDataApprovalLevels() )
+        List<DataApprovalLevel> userApprovalLevels = getUserDataApprovalLevels();
+        
+        for ( DataApprovalLevel level : userApprovalLevels )
         {
             tracePrint( "getHighestDataApprovalLevel - data approval level: " + level.getName() );
 
@@ -189,7 +195,9 @@
 
         int orgUnitLevel = organisationUnitService.getLevelOfOrganisationUnit( orgUnit );
 
-        for ( DataApprovalLevel level : Lists.reverse( getDataApprovalLevelsByOrgUnitLevel( orgUnitLevel ) ) )
+        List<DataApprovalLevel> approvalLevels = getDataApprovalLevelsByOrgUnitLevel( orgUnitLevel );
+        
+        for ( DataApprovalLevel level : Lists.reverse( approvalLevels ) )
         {
             if ( level.getCategoryOptionGroupSet() == null )
             {
@@ -267,7 +275,7 @@
             boolean approvableAtAllLowerLevels = false;
 
             boolean canSeeAllDimensions = CollectionUtils.isEmpty( userService.getCoDimensionConstraints( user.getUserCredentials() ) )
-                    && CollectionUtils.isEmpty( userService.getCogDimensionConstraints( user.getUserCredentials() ) );
+                && CollectionUtils.isEmpty( userService.getCogDimensionConstraints( user.getUserCredentials() ) );
 
             for ( DataApprovalLevel approvalLevel : getAllDataApprovalLevels() )
             {
@@ -276,7 +284,6 @@
                 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.
                 
@@ -541,7 +548,7 @@
 
     private void tracePrint( String s ) // Temporary, for development
     {
-//        System.out.println( s );
+        log.trace( s );
     }
 
     /**