← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19728: Analytics, setting level of org units

 

------------------------------------------------------------
revno: 19728
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-08-06 15:12:50 +0200
message:
  Analytics, setting level of org units
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.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-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java	2015-07-07 14:54:50 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java	2015-08-06 13:12:50 +0000
@@ -482,6 +482,14 @@
      * @return true if the organisation unit with the given uid is part of the hierarchy.
      */
     boolean isInUserHierarchy( String uid, Set<OrganisationUnit> organisationUnits );
+    
+    /**
+     * Sets the transient level property of each organisation unit in the given
+     * list. Fetches the organisation unit from the database.
+     * 
+     * @param organisationUnits the collection of organisation units.
+     */
+    void setOrganisationUnitLevel( Collection<OrganisationUnit> organisationUnits );
 
     // -------------------------------------------------------------------------
     // OrganisationUnitHierarchy

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java	2015-08-05 15:46:59 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java	2015-08-06 13:12:50 +0000
@@ -1273,6 +1273,13 @@
                 }
             }
 
+            // -----------------------------------------------------------------
+            // Set level property
+            // -----------------------------------------------------------------
+
+            Collection<OrganisationUnit> typedOus = NameableObjectUtils.asTypedList( ous );
+            organisationUnitService.setOrganisationUnitLevel( typedOus );
+            
             List<NameableObject> orgUnits = new UniqueArrayList<>();
             List<OrganisationUnit> ousList = NameableObjectUtils.asTypedList( ous );
 

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java	2015-07-08 09:56:56 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java	2015-08-06 13:12:50 +0000
@@ -813,6 +813,18 @@
         return organisationUnit != null ? organisationUnit.isDescendant( organisationUnits ) : false;
     }
 
+    @Override
+    public void setOrganisationUnitLevel( Collection<OrganisationUnit> organisationUnits )
+    {
+        for ( OrganisationUnit unit : organisationUnits )
+        {
+            if ( unit != null && !unit.hasLevel() )
+            {
+                unit.setLevel( getLevelOfOrganisationUnit( unit.getId() ) );
+            }
+        }
+    }
+
     // -------------------------------------------------------------------------
     // OrganisationUnitHierarchy
     // -------------------------------------------------------------------------