← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16864: OrganisationUnitService, addded methods

 

------------------------------------------------------------
revno: 16864
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-09-29 21:04:09 +0200
message:
  OrganisationUnitService, addded methods
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitGroupService.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	2014-09-29 18:38:31 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java	2014-09-29 19:04:09 +0000
@@ -240,6 +240,28 @@
     /**
      * Returns an OrganisationUnit and all its children.
      *
+     * @param uid the uid of the parent OrganisationUnit in the subtree.
+     * @param maxLevels the max number of levels to return relative to 
+     *        the given root, inclusive.
+     * @return a collection containing the OrganisationUnit with the given id
+     *         and all its children, or an empty collection if no
+     *         OrganisationUnits match.
+     */
+    Collection<OrganisationUnit> getOrganisationUnitWithChildren( String uid, Integer maxLevels );
+
+    /**
+     * Returns an OrganisationUnit and all its children.
+     *
+     * @param id the id of the parent OrganisationUnit in the subtree.
+     * @return a collection containing the OrganisationUnit with the given id
+     *         and all its children, or an empty collection if no
+     *         OrganisationUnits match.
+     */
+    Collection<OrganisationUnit> getOrganisationUnitWithChildren( int id );
+
+    /**
+     * Returns an OrganisationUnit and all its children.
+     *
      * @param id the id of the parent OrganisationUnit in the subtree.
      * @param maxLevels the max number of levels to return relative to 
      *        the given root, inclusive.
@@ -258,17 +280,19 @@
      *         OrganisationUnits match.
      */
     Collection<OrganisationUnit> getOrganisationUnitsWithChildren( Collection<String> uids );
-    
+
     /**
-     * Returns an OrganisationUnit and all its children.
+     * Returns the OrganisationUnits and all their children.
      *
-     * @param id the id of the parent OrganisationUnit in the subtree.
+     * @param uids the uids of the parent OrganisationUnits.
+     * @param maxLevels the max number of levels to return relative to 
+     *        the given root, inclusive.
      * @return a collection containing the OrganisationUnit with the given id
      *         and all its children, or an empty collection if no
      *         OrganisationUnits match.
      */
-    Collection<OrganisationUnit> getOrganisationUnitWithChildren( int id );
-
+    Collection<OrganisationUnit> getOrganisationUnitsWithChildren( Collection<String> uids, Integer maxLevels );
+    
     /**
      * Returns the branch of OrganisationUnits from a root to a given
      * OrganisationUnit. Both root and target OrganisationUnits are included in

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitGroupService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitGroupService.java	2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitGroupService.java	2014-09-29 19:04:09 +0000
@@ -355,7 +355,7 @@
 
         for ( OrganisationUnit organisationUnit : currentUserService.getCurrentUser().getOrganisationUnits() )
         {
-            userOrganisationUnits.addAll( organisationUnitService.getOrganisationUnitsWithChildren( organisationUnit.getUid() ) );
+            userOrganisationUnits.addAll( organisationUnitService.getOrganisationUnitWithChildren( organisationUnit.getUid() ) );
         }
 
         organisationUnits.removeAll( userOrganisationUnits );

=== 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	2014-09-29 18:40:33 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java	2014-09-29 19:04:09 +0000
@@ -278,11 +278,16 @@
 
     public Collection<OrganisationUnit> getOrganisationUnitsWithChildren( Collection<String> parentUids )
     {
+        return getOrganisationUnitsWithChildren( parentUids, null );
+    }
+
+    public Collection<OrganisationUnit> getOrganisationUnitsWithChildren( Collection<String> parentUids, Integer maxLevels )
+    {
         Set<OrganisationUnit> units = new HashSet<>();
 
         for ( String uid : parentUids )
         {
-            units.addAll( getOrganisationUnitWithChildren( uid ) );
+            units.addAll( getOrganisationUnitWithChildren( uid, maxLevels ) );
         }
 
         return units;
@@ -290,11 +295,16 @@
 
     public Collection<OrganisationUnit> getOrganisationUnitWithChildren( String uid )
     {
+        return getOrganisationUnitWithChildren( uid, null );
+    }
+
+    public Collection<OrganisationUnit> getOrganisationUnitWithChildren( String uid, Integer maxLevels )
+    {
         OrganisationUnit unit = getOrganisationUnit( uid );
         
         int id = unit != null ? unit.getId() : -1;
         
-        return getOrganisationUnitWithChildren( id );
+        return getOrganisationUnitWithChildren( id, maxLevels );
     }
 
     public Collection<OrganisationUnit> getOrganisationUnitWithChildren( int id )