← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8850: DV, added contextPath property in initialize response

 

------------------------------------------------------------
revno: 8850
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2012-11-04 10:58:03 +0300
message:
  DV, added contextPath property in initialize response
modified:
  dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/InitializeAction.java
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/jsonInitialize.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-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/InitializeAction.java'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/InitializeAction.java	2012-07-24 04:04:14 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/InitializeAction.java	2012-11-04 07:58:03 +0000
@@ -31,6 +31,8 @@
 import java.util.Collection;
 import java.util.List;
 
+import org.apache.struts2.ServletActionContext;
+import org.hisp.dhis.api.utils.ContextUtils;
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
@@ -85,6 +87,13 @@
     // Output
     // -------------------------------------------------------------------------
 
+    private String contextPath;
+
+    public String getContextPath()
+    {
+        return contextPath;
+    }
+
     private Collection<OrganisationUnit> rootNodes;
 
     public Collection<OrganisationUnit> getRootNodes()
@@ -168,7 +177,7 @@
     {
         return last5Years;
     }
-
+    
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -176,6 +185,8 @@
     public String execute()
         throws Exception
     {
+        contextPath = ContextUtils.getContextPath( ServletActionContext.getRequest() );
+        
         rootNodes = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitsAtLevel( 1 ) );
 
         if ( rootNodes.size() < 1 )

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/jsonInitialize.vm'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/jsonInitialize.vm	2012-07-10 17:15:05 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/jsonInitialize.vm	2012-11-04 07:58:03 +0000
@@ -1,2 +1,8 @@
-#set($oucSize = $currentUser.getOrganisationUnit().getSortedChildren().size()){"user":{"id":"$!currentUser.id","isAdmin":$auth.hasAccess( "dhis-web-visualizer", "addOrUpdateSystemChart" ),"ou":{"id":"$currentUser.getOrganisationUnit().uid","name":"$currentUser.getOrganisationUnit().name"},"ouc":[#foreach($ou in $currentUser.getOrganisationUnit().getSortedChildren()){"id":"$ou.uid","name":"$ou.name"}#if($velocityCount < $oucSize),#end#end]},"system":{"rn":[#foreach($rn in $rootNodes)["$!{rn.uid}","$!encoder.jsonEncode(${rn.name})"]#if($velocityCount<$rootNodes.size()),#end#end],"ougs":{#foreach($ougs in $organisationUnitGroupSets)"$!{ougs.uid}":[#foreach($oug in $ougs.getSortedGroups()){"id":"$!{oug.uid}","name":"$!encoder.jsonEncode($!{oug.name})"}#if($velocityCount<$ougs.getSortedGroups().size()),#end#end]#if($velocityCount<$organisationUnitGroupSets.size()),#end#end}}}
-
+#set($oucSize = $currentUser.getOrganisationUnit().getSortedChildren().size()){
+"contextPath":"$!{contextPath}",
+"user":{"id":"$!currentUser.id","isAdmin":$auth.hasAccess( "dhis-web-visualizer", "addOrUpdateSystemChart" ),
+"ou":{"id":"$currentUser.getOrganisationUnit().uid","name":"$currentUser.getOrganisationUnit().name"},
+"ouc":[#foreach($ou in $currentUser.getOrganisationUnit().getSortedChildren()){"id":"$ou.uid","name":"$ou.name"}#if($velocityCount < $oucSize),#end#end]},
+"system":{"rn":[#foreach($rn in $rootNodes)["$!{rn.uid}","$!encoder.jsonEncode(${rn.name})"]#if($velocityCount<$rootNodes.size()),#end#end],
+"ougs":{#foreach($ougs in $organisationUnitGroupSets)"$!{ougs.uid}":[#foreach($oug in $ougs.getSortedGroups()){"id":"$!{oug.uid}","name":"$!encoder.jsonEncode($!{oug.name})"}#if($velocityCount<$ougs.getSortedGroups().size()),#end#end]#if($velocityCount<$organisationUnitGroupSets.size()),#end#end}}
+}