← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9675: Added org unit hierarchy info for html standard reports

 

------------------------------------------------------------
revno: 9675
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-01-31 16:48:30 +0200
message:
  Added org unit hierarchy info for html standard reports
modified:
  dhis-2/dhis-support/dhis-support-system/src/main/resources/html-report-template.html
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportAndParamsAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderHtmlReport.vm


--
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-support/dhis-support-system/src/main/resources/html-report-template.html'
--- dhis-2/dhis-support/dhis-support-system/src/main/resources/html-report-template.html	2013-01-27 11:43:58 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/resources/html-report-template.html	2013-01-31 14:48:30 +0000
@@ -53,6 +53,10 @@
 var shortName = orgUnit.shortName;<br>
 var code = orgUnit.code;<br><br>
 
+var orgUnitHierarchy = dhis2.report.organisationUnitHierarchy; // An array with org unit objects for the hierarchy (current org unit first)<br><br>
+
+var name = orgUnitHierarchy[0].name;<br><br>
+
 var periods = dhis2.report.periods; // An array with period identifiers<br><br>
 
 var period = periods[0];

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportAndParamsAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportAndParamsAction.java	2013-01-25 15:24:37 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportAndParamsAction.java	2013-01-31 14:48:30 +0000
@@ -27,6 +27,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -100,6 +101,13 @@
         return organisationUnit;
     }
 
+    private List<OrganisationUnit> organisationUnitHierarchy = new ArrayList<OrganisationUnit>();
+    
+    public List<OrganisationUnit> getOrganisationUnitHierarchy()
+    {
+        return organisationUnitHierarchy;
+    }
+
     private List<Period> periods;
     
     public List<Period> getPeriods()
@@ -118,6 +126,19 @@
         if ( ou != null )
         {
             organisationUnit = organisationUnitService.getOrganisationUnit( ou );
+            
+            if ( organisationUnit != null )
+            {
+                organisationUnitHierarchy.add( organisationUnit );
+                
+                OrganisationUnit parent = organisationUnit;
+                
+                while ( parent.getParent() != null )
+                {
+                    parent = parent.getParent();
+                    organisationUnitHierarchy.add( parent );
+                }
+            }
         }
         
         Date date = new Date();

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderHtmlReport.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderHtmlReport.vm	2013-01-30 08:53:54 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderHtmlReport.vm	2013-01-31 14:48:30 +0000
@@ -3,7 +3,7 @@
 dhis2.util.namespace( 'dhis2.report' );
 
 dhis2.report.organisationUnit = {
-#if ( $organisationUnit )
+#if( $organisationUnit )
     "id": "$!{organisationUnit.uid}",
     "name": "$!{organisationUnit.name}",
     "shortName": "$!{organisationUnit.shortName}",
@@ -11,8 +11,22 @@
 #end
 };
 
+dhis2.report.organisationUnitHierarchy = [
+#if( $organisationUnitHierarchy )
+#set( $size = $organisationUnitHierarchy.size() )
+#foreach( $ou in $organisationUnitHierarchy )
+{
+    "id": "${ou.uid}",
+    "name": "${ou.name}",
+    "shortName": "${ou.shortName}",
+    "code": "${ou.code}"
+}#if( $velocityCount < $size ),#end
+#end
+#end
+];
+
 dhis2.report.periods = [
-#if ( $periods )
+#if( $periods )
 #set( $size = $periods.size() )
 #foreach( $period in $periods )
 "$period.getIsoDate()"#if( $velocityCount < $size ),#end