← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17598: Approval, accepting ou query parameter

 

------------------------------------------------------------
revno: 17598
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-11-26 16:21:02 +0100
message:
  Approval, accepting ou query parameter
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataApprovalController.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/hibernate/HibernateDataApprovalStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java	2014-11-25 19:23:03 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java	2014-11-26 15:21:02 +0000
@@ -198,7 +198,7 @@
         if ( CollectionUtils.isEmpty( dataSets ) )
         {
             log.warn( " No data sets specified for getting approvals, period " + period.getName()
-                    + " user " + ( user == null ? "(null)" : user.getUsername() ) );
+                + " user " + ( user == null ? "(null)" : user.getUsername() ) );
 
             return new ArrayList<>();
         }
@@ -214,13 +214,13 @@
         else if ( period.getPeriodType().getFrequencyOrder() > dataSetPeriodType.getFrequencyOrder() )
         {
             periods = new ArrayList<>( periodService.getPeriodsBetweenDates( dataSetPeriodType,
-                    period.getStartDate(), period.getEndDate() ) );
+                period.getStartDate(), period.getEndDate() ) );
         }
         else
         {
             log.warn( "Selected period type " + period.getPeriodType().getName() + " is incompatible with data set '"
-                    + dataSets.iterator().next().getName() + "' period type " + dataSetPeriodType.getName()
-                    + " user " + ( user == null ? "(null)" : user.getUsername() ) );
+                + dataSets.iterator().next().getName() + "' period type " + dataSetPeriodType.getName()
+                + " user " + ( user == null ? "(null)" : user.getUsername() ) );
 
             return new ArrayList<>();
         }
@@ -229,8 +229,8 @@
         final String maxDate = DateUtils.getMediumDateString( period.getEndDate() );
 
         boolean maySeeDefaultCategoryCombo = user == null || user.getUserCredentials() == null ||
-                ( CollectionUtils.isEmpty( user.getUserCredentials().getCogsDimensionConstraints() )
-                && CollectionUtils.isEmpty( user.getUserCredentials().getCatDimensionConstraints() ) );
+            ( CollectionUtils.isEmpty( user.getUserCredentials().getCogsDimensionConstraints() )
+            && CollectionUtils.isEmpty( user.getUserCredentials().getCatDimensionConstraints() ) );
 
         DataElementCategoryCombo defaultCategoryCombo = categoryService.getDefaultDataElementCategoryCombo();
 
@@ -281,8 +281,8 @@
 
         DataApprovalLevel lowestApprovalLevelForOrgUnit = null;
 
-        String joinAncestors = "";
-        String testAncestors = "";
+        String joinAncestors = StringUtils.EMPTY;
+        String testAncestors = StringUtils.EMPTY;
 
         for ( int i = 1; i < orgUnitLevel; i++ )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataApprovalController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataApprovalController.java	2014-11-21 16:45:43 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataApprovalController.java	2014-11-26 15:21:02 +0000
@@ -255,6 +255,7 @@
     public void getApprovalByCategoryOptionCombos( 
         @RequestParam Set<String> ds, 
         @RequestParam String pe,
+        @RequestParam(required = false) String ou,
         HttpServletResponse response ) throws IOException
     {
         Set<DataSet> dataSets = new HashSet<>( objectManager.getByUid( DataSet.class, ds ) );
@@ -266,8 +267,10 @@
             ContextUtils.conflictResponse( response, "Illegal period identifier: " + pe );
             return;
         }
+        
+        OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( ou );
 
-        List<DataApprovalStatus> statusList = dataApprovalService.getUserDataApprovalsAndPermissions( dataSets, period, null );
+        List<DataApprovalStatus> statusList = dataApprovalService.getUserDataApprovalsAndPermissions( dataSets, period, orgUnit );
 
         List<Map<String, Object>> list = new ArrayList<>();