← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8789: added realRoot property to organisationUnitTree action

 

------------------------------------------------------------
revno: 8789
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-10-31 10:36:23 +0100
message:
  added realRoot property to organisationUnitTree action
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitTree.vm
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitTreeAction.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-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitTree.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitTree.vm	2012-06-28 09:21:53 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitTree.vm	2012-10-31 09:36:23 +0000
@@ -1,5 +1,6 @@
 {
 "version":"$!encoder.jsonEncode( $version )"
+,"realRoot":$realRoot
 ,"roots": [ #foreach( $root in $rootOrganisationUnits )$root.id#if( $velocityCount < $rootOrganisationUnits.size() ),#end#end ]
 #if( ! $versionOnly )
 ,"organisationUnits": {

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitTreeAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitTreeAction.java	2012-07-24 10:23:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitTreeAction.java	2012-10-31 09:36:23 +0000
@@ -105,7 +105,7 @@
         return version;
     }
 
-    private Boolean versionOnly = false;
+    private boolean versionOnly;
 
     public void setVersionOnly( Boolean versionOnly )
     {
@@ -124,6 +124,13 @@
         this.parentId = parentId;
     }
 
+    private boolean realRoot;
+
+    public boolean isRealRoot()
+    {
+        return realRoot;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -207,6 +214,14 @@
             }
         }
 
+        Collection intersection = org.apache.commons.collections.CollectionUtils.intersection(
+            organisationUnitService.getRootOrganisationUnits(), rootOrganisationUnits );
+
+        if ( intersection.size() > 0 )
+        {
+            realRoot = true;
+        }
+
         Collections.sort( rootOrganisationUnits, IdentifiableObjectNameComparator.INSTANCE );
 
         version = getVersionString();