← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7419: Added method OrganisationUnit.getAncestors

 

------------------------------------------------------------
revno: 7419
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-06-27 09:38:35 +0200
message:
  Added method OrganisationUnit.getAncestors
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.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/OrganisationUnit.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java	2012-05-24 10:33:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java	2012-06-27 07:38:35 +0000
@@ -463,6 +463,22 @@
 
         return builder.toString();
     }
+    
+    public List<OrganisationUnit> getAncestors()
+    {
+        List<OrganisationUnit> units = new ArrayList<OrganisationUnit>();
+        
+        OrganisationUnit unit = parent;
+
+        while ( unit != null )
+        {
+            units.add( unit );
+            unit = unit.getParent();
+        }
+        
+        Collections.reverse( units );
+        return units;
+    }
 
     public Set<DataElement> getDataElementsInDataSets()
     {