← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17267: Approvals fixes

 

------------------------------------------------------------
revno: 17267
committer: jimgrace@xxxxxxxxx
branch nick: dhis2
timestamp: Fri 2014-10-24 23:22:56 -0400
message:
  Approvals fixes
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DataApprovalSelection.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.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/DataApprovalSelection.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DataApprovalSelection.java	2014-10-23 21:47:57 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DataApprovalSelection.java	2014-10-25 03:22:56 +0000
@@ -382,7 +382,7 @@
     {
         tracePrint( "optionApplies - level " + dal.getLevel() + " COGS "
                 + ( dal.getCategoryOptionGroupSet() == null ? "(none)" : dal.getCategoryOptionGroupSet().getName() )
-                + " combo " + daIn.getAttributeOptionCombo().getName() );
+                + " combo " + ( daIn.getAttributeOptionCombo() == null ? "(null)" : daIn.getAttributeOptionCombo().getName() ) );
 
         tracePrint("optionApplies - option combo group sets " + getOptionComboGroupSets( daIn.getAttributeOptionCombo() ) );
 

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalService.java	2014-10-24 12:29:07 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalService.java	2014-10-25 03:22:56 +0000
@@ -326,6 +326,11 @@
                 + organisationUnit.getName() + ", "
                 + ( attributeOptionCombo == null ? "(null)" : attributeOptionCombo.getName() ) + " )" );
 
+        if ( attributeOptionCombo == null )
+        {
+            attributeOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
+        }
+
         Set<DataElementCategoryOption> attributeCategoryOptions = ( attributeOptionCombo == null || attributeOptionCombo.equals( categoryService.getDefaultDataElementCategoryOptionCombo() ) )
                 ? null : attributeOptionCombo.getCategoryOptions();
 
@@ -390,8 +395,9 @@
 
                 if ( userApprovalLevel != null )
                 {
+                    boolean isApproved = ( da.getDataApprovalLevel() != null );
                     int userLevel = userApprovalLevel.getLevel();
-                    int dataLevel = da.getDataApprovalLevel() == null ? maxApprovalLevel + 1 : da.getDataApprovalLevel().getLevel();
+                    int dataLevel = isApproved ? da.getDataApprovalLevel().getLevel() : maxApprovalLevel;
 
                     boolean mayApprove = ( authorizedToApprove && userLevel == dataLevel && !da.isAccepted() ) ||
                         authorizedToApproveAtLowerLevels && userLevel < dataLevel;
@@ -399,7 +405,7 @@
                     boolean mayAcceptOrUnaccept = authorizedToAcceptAtLowerLevels && dataLevel <= maxApprovalLevel &&
                         ( userLevel == dataLevel + 1 || ( userLevel < dataLevel && authorizedToApproveAtLowerLevels ) );
 
-                    boolean mayUnapprove = mayApprove && ( !da.isAccepted() || mayAcceptOrUnaccept );
+                    boolean mayUnapprove = isApproved && mayApprove && ( !da.isAccepted() || mayAcceptOrUnaccept );
 
                     permissions.setMayApprove( mayApprove );
                     permissions.setMayUnapprove( mayUnapprove );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java	2014-10-24 12:15:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java	2014-10-25 03:22:56 +0000
@@ -278,7 +278,7 @@
     
                 if ( aoc == previousAttributeOptionComboId && pe == previousPeriodId && level > previousLevel )
                 {
-                    continue;
+                    continue; // Skip the lower-level approvals for the same categoryOptionCombo & period.
                 }
     
                 previousAttributeOptionComboId = aoc;
@@ -312,7 +312,7 @@
                 } ) );
     
                 //TODO: currently special cased for PEFPAR's requirements. Can we make it more generic?
-                if ( level > 1 && optionCombo.equals( defaultOptionCombo ) )
+                if ( ( level == null || level != 1 ) && optionCombo.equals( defaultOptionCombo ) )
                 {
                     for ( OrganisationUnit unit : getUserOrgsAtLevel( 3 ) )
                     {