← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13178: Convenience method for getting all org units assigned to data set

 

------------------------------------------------------------
revno: 13178
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-12-09 15:33:53 +0100
message:
  Convenience method for getting all org units assigned to data set
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.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/dataset/DataSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java	2013-11-28 20:52:27 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java	2013-12-09 14:33:53 +0000
@@ -378,6 +378,24 @@
         compulsoryDataElementOperands.remove( dataElementOperand );
     }
 
+    /**
+     * Returns all organisation units assigned to this data set, including 
+     * org units assigned directly and organisation units assigned through groups.
+     */
+    public Set<OrganisationUnit> getAllOrganisationUnits()
+    {
+        Set<OrganisationUnit> units = new HashSet<OrganisationUnit>();
+        
+        units.addAll( sources );
+        
+        for ( OrganisationUnitGroup group : organisationUnitGroups )
+        {
+            units.addAll( group.getMembers() );
+        }
+        
+        return units;
+    }
+    
     public boolean hasDataEntryForm()
     {
         return dataEntryForm != null;