← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8860: (GIS) Map loader improved + Interpretation direct link.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 8860 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2012-11-04 22:09:21 +0300
message:
  (GIS) Map loader improved + Interpretation direct link.
added:
  dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetOrganisationUnitGroupsByGroupSetAction.java
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonminOrganisationUnitGroups.vm
modified:
  dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-mapping/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/widgets/geostat/Boundary.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/widgets/geostat/Facility.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/widgets/geostat/Thematic1.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/widgets/geostat/Thematic2.js


--
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
=== added file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetOrganisationUnitGroupsByGroupSetAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetOrganisationUnitGroupsByGroupSetAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetOrganisationUnitGroupsByGroupSetAction.java	2012-11-04 14:58:28 +0000
@@ -0,0 +1,94 @@
+package org.hisp.dhis.mapping.action;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.Set;
+
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Jan Henrik Overland
+ * @version $Id$
+ */
+public class GetOrganisationUnitGroupsByGroupSetAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private OrganisationUnitGroupService organisationUnitGroupService;
+
+    public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
+    {
+        this.organisationUnitGroupService = organisationUnitGroupService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private String id;
+
+    public void setId( String id )
+    {
+        this.id = id;
+    }
+
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    private Set<OrganisationUnitGroup> object;
+
+    public Set<OrganisationUnitGroup> getObject()
+    {
+        return object;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        OrganisationUnitGroupSet groupSet = organisationUnitGroupService.getOrganisationUnitGroupSet( id );
+        
+        if ( groupSet != null )
+        {
+            object = groupSet.getOrganisationUnitGroups();
+        }
+        
+        return SUCCESS;
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml	2012-11-01 17:07:12 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml	2012-11-04 14:58:28 +0000
@@ -65,7 +65,14 @@
             ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
     </bean>
 
-    <!-- UserSetting -->
+    <bean id="org.hisp.dhis.mapping.action.GetOrganisationUnitGroupsByGroupSetAction"
+        class="org.hisp.dhis.mapping.action.GetOrganisationUnitGroupsByGroupSetAction"
+        scope="prototype">
+        <property name="organisationUnitGroupService"
+            ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
+    </bean>
+	
+	<!-- UserSetting -->
 
     <bean id="org.hisp.dhis.mapping.action.GetMapUserSettingsAction"
         class="org.hisp.dhis.mapping.action.GetMapUserSettingsAction"

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/resources/struts.xml	2012-11-01 17:07:12 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/resources/struts.xml	2012-11-04 14:58:28 +0000
@@ -84,6 +84,12 @@
 				/dhis-web-mapping/jsonminFacilityInfo.vm</result>
 		</action>
 
+        <action name="getOrganisationUnitGroupsByGroupSet"
+            class="org.hisp.dhis.mapping.action.GetOrganisationUnitGroupsByGroupSetAction">
+            <result name="success" type="velocity-json">/dhis-web-mapping/jsonminOrganisationUnitGroups.vm
+            </result>
+        </action>
+
         <!-- OrganisationUnitLevel -->
 
         <action name="getOrganisationUnitLevels"

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js	2012-11-04 10:23:39 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js	2012-11-04 17:28:17 +0000
@@ -41,9 +41,7 @@
 	url: {
 		path_api: '../../api/',
 		path_gis: '../',
-		path_scripts: 'scripts/',
-		google_terms: 'http://www.google.com/intl/en-US_US/help/terms_maps.html',
-		target_blank: '_blank'
+		path_scripts: 'scripts/'
 	},
 	layout: {
 		widget: {
@@ -197,6 +195,8 @@
 		GIS.init.security = {
 			isAdmin: init.security.isAdmin
 		};
+		
+		GIS.init.contextPath = init.contextPath;
 	};
 	
 	Ext.Ajax.request({
@@ -343,7 +343,7 @@
 	
 	GIS.util.map.zoomToVisibleExtent = function() {
 		var bounds = GIS.util.map.getExtendedBounds(GIS.util.map.getVisibleVectorLayers());
-		if (bounds.length) {
+		if (bounds) {
 			GIS.map.zoomToExtent(bounds);
 		}
 	};
@@ -1087,6 +1087,7 @@
 	
 	GIS.obj.WidgetWindow = function(base) {
 		return Ext.create('Ext.window.Window', {
+			autoShow: true,
 			title: base.name,
 			layout: 'fit',
 			iconCls: 'gis-window-title-icon-' + base.id,
@@ -1094,6 +1095,7 @@
 			closeAction: 'hide',
 			width: GIS.conf.layout.widget.window_width,
 			resizable: false,
+			isRendered: false,
 			items: base.widget,
 			bbar: [
 				'->',
@@ -1108,8 +1110,14 @@
 				}
 			],
 			listeners: {
-				show: function() {					
-					GIS.util.gui.window.setPositionTopLeft(this);
+				show: function() {
+					if (!this.isRendered) {
+						this.isRendered = true;
+						this.hide();
+					}
+					else {
+						GIS.util.gui.window.setPositionTopLeft(this);
+					}
 				}
 			}
 		});
@@ -2070,7 +2078,6 @@
 				alert('Favorite has no layers'); //i18n
 				return;
 			}
-				
 			GIS.util.map.closeAllLayers();
 			
 			for (var i = 0; i < views.length; i++) {
@@ -2837,14 +2844,22 @@
 	GIS.obj.InterpretationWindow = function() {
 		var window,
 			textarea,
+			panel,
 			button;
 			
 		textarea = Ext.create('Ext.form.field.TextArea', {
 			cls: 'gis-textarea',
-			height: 170,
+			height: 130,
+			fieldStyle: 'padding-left: 4px; padding-top: 3px',
 			emptyText: 'Write your interpretation...' //i18n
 		});
 		
+		panel = Ext.create('Ext.panel.Panel', {
+			cls: 'gis-container-inner',
+			html: '<b>Direct link: </b>' + GIS.init.contextPath + '/dhis-web-mapping/app/index.html?id=' + GIS.map.mapLoader.id,
+			style: 'padding-top: 9px; padding-bottom: 2px'
+		});
+		
 		button = Ext.create('Ext.button.Button', {
 			text: 'Share', //i18n
 			handler: function() {
@@ -2869,10 +2884,13 @@
 			layout: 'fit',
 			iconCls: 'gis-window-title-icon-interpretation',
 			cls: 'gis-container-default',
-			width: 450,
+			width: 500,
 			resizable: true,
 			modal: true,
-			items: textarea,
+			items: [
+				textarea,
+				panel
+			],
 			bbar: [
 				'->',
 				button
@@ -2880,10 +2898,18 @@
 			listeners: {
 				show: function() {
 					this.setPosition(325, 37);
+				},
+				destroy: function() {
+					document.body.oncontextmenu = function(){
+						return false;
+					};
 				}
+					
 			}
 		});
 		
+		document.body.oncontextmenu = true; // right click to copy url
+		
 		return window;
 	};
 	

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/widgets/geostat/Boundary.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/widgets/geostat/Boundary.js	2012-11-02 19:46:41 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/widgets/geostat/Boundary.js	2012-11-04 18:50:13 +0000
@@ -78,39 +78,6 @@
 		})
 	},
     
-    setUrl: function(url) {
-        this.url = url;
-        this.coreComp.setUrl(this.url);
-    },
-
-    requestSuccess: function(request) {
-        var doc = request.responseXML,
-			format = new OpenLayers.Format.GeoJSON();
-			
-        if (!doc || !doc.documentElement) {
-            doc = request.responseText;
-        }
-        
-        if (doc.length) {
-            doc = GIS.util.geojson.decode(doc, this);
-        }
-        else {
-			alert('No valid coordinates found'); //todo //i18n
-		}
-        
-        this.layer.removeFeatures(this.layer.features);
-        this.layer.addFeatures(format.read(doc));
-		this.layer.features = GIS.util.vector.getTransformedFeatureArray(this.layer.features);
-        this.features = this.layer.features.slice(0);
-        
-        this.loadData();
-    },
-
-    requestFailure: function(request) {
-        GIS.logg.push(request.status, request.statusText);        
-        console.log(request.status, request.statusText);
-    },
-    
     getColors: function(low, high) {
         var startColor = new mapfish.ColorRgb();
         startColor.setFromHex(low);
@@ -175,28 +142,10 @@
 			multiSelect: false,
 			width: GIS.conf.layout.widget.item_width,
 			height: 300,
-			pathToSelect: null,
-			pathToExpand: null,
 			reset: function() {
 				this.collapseAll();
-				this.expandTreePath(GIS.init.rootNodes[0].path);
-				this.selectTreePath(GIS.init.rootNodes[0].path);
-			},
-			selectTreePath: function(path) {
-				if (this.rendered) {
-					this.selectPath(path);
-				}
-				else {
-					this.pathToSelect = path;
-				}
-			},
-			expandTreePath: function(path) {
-				if (this.rendered) {
-					this.expandPath(path);
-				}
-				else {
-					this.pathToExpand = path;
-				}
+				this.expandPath(GIS.init.rootNodes[0].path);
+				this.selectPath(GIS.init.rootNodes[0].path);
 			},
 			store: Ext.create('Ext.data.TreeStore', {
 				proxy: {
@@ -223,19 +172,8 @@
 						this.config.extended.updateOrganisationUnit = true;
 					}
 				},
-				afterrender: function() {					
-					if (this.pathToSelect) {
-						this.selectPath(this.pathToSelect);
-						this.pathToSelect = null;
-					}
-					else {
-						this.getSelectionModel().select(0);
-					}
-					
-					if (this.pathToExpand) {
-						this.expandPath(this.pathToExpand);
-						this.pathToExpand = null;
-					}
+				afterrender: function() {
+					this.getSelectionModel().select(0);
 				}
 			}
         });
@@ -508,7 +446,7 @@
 			that.cmp.level.setValue(view.organisationUnitLevel.id);
 		});
 		
-		this.cmp.parent.selectTreePath('/root' + view.parentGraph);
+		this.cmp.parent.selectPath('/root' + view.parentGraph);
 	},
     	
 	getView: function() {
@@ -608,18 +546,46 @@
 	},
 	
     loadOrganisationUnits: function() {
-        var url = GIS.conf.url.path_gis + 'getGeoJson.action?' +
-            'parentId=' + this.tmpView.parentOrganisationUnit.id +
-            '&level=' + this.tmpView.organisationUnitLevel.id;
-        this.setUrl(url);
+		Ext.Ajax.request({
+			url: GIS.conf.url.path_gis + 'getGeoJson.action',
+			params: {
+				parentId: this.tmpView.parentOrganisationUnit.id,
+				level: this.tmpView.organisationUnitLevel.id
+			},
+			scope: this,
+			success: function(r) {
+				var geojson = GIS.util.geojson.decode(r.responseText, this),
+					format = new OpenLayers.Format.GeoJSON(),
+					features = format.read(geojson);
+					
+				if (!features.length) {
+					alert('No valid coordinates found'); //todo //i18n
+					GIS.mask.hide();
+					
+					this.config = {
+						extended: {}
+					};
+					return;
+				}
+				
+				this.loadData(features);
+			}
+		});				
     },
     
-    loadData: function() {
-		for (var i = 0; i < this.layer.features.length; i++) {
-			var feature = this.layer.features[i];
+    loadData: function(features) {
+		features = features || this.layer.features;
+		
+		for (var i = 0; i < features.length; i++) {
+			var feature = features[i];
 			feature.attributes.label = feature.attributes.name;
 			feature.attributes.value = 0;
 		}
+				
+		this.layer.removeFeatures(this.layer.features);
+		this.layer.addFeatures(features);
+		this.layer.features = GIS.util.vector.getTransformedFeatureArray(this.layer.features);
+		this.features = this.layer.features.slice(0);
 		
 		this.loadLegend();
 	},
@@ -664,10 +630,6 @@
 		GIS.mask.msg = GIS.i18n.loading;
 		GIS.mask.show();
 		
-		if (this.tmpView.extended.updateGui) {
-			this.setGui();
-		}
-		
 		if (this.tmpView.extended.updateOrganisationUnit) {
 			this.loadOrganisationUnits();
 		}
@@ -679,7 +641,11 @@
 		}
 	},
 	
-	afterLoad: function() {
+	afterLoad: function() {		
+		if (this.tmpView.extended.updateGui) {
+			this.setGui();
+		}
+		
 		this.view = this.tmpView;
 		this.config = {
 			extended: {}

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/widgets/geostat/Facility.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/widgets/geostat/Facility.js	2012-11-02 19:46:41 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/widgets/geostat/Facility.js	2012-11-04 18:50:13 +0000
@@ -139,38 +139,6 @@
         return geojson;
     },
     
-    setUrl: function(url) {
-        this.url = url;
-        this.coreComp.setUrl(this.url);
-    },
-
-    requestSuccess: function(request) {
-        var doc = request.responseXML,
-			format = new OpenLayers.Format.GeoJSON();
-			
-        if (!doc || !doc.documentElement) {
-            doc = request.responseText;
-        }
-        if (doc.length) {
-            doc = this.decode(doc);
-        }
-        else {
-			alert('No valid coordinates found'); //todo //i18n
-		}
-        
-        this.layer.removeFeatures(this.layer.features);
-        this.layer.addFeatures(format.read(doc));
-		this.layer.features = GIS.util.vector.getTransformedFeatureArray(this.layer.features);
-        this.features = this.layer.features.slice(0);
-        
-        this.loadData();
-    },
-
-    requestFailure: function(request) {
-        GIS.logg.push(request.status, request.statusText);        
-        console.log(request.status, request.statusText);
-    },
-    
     getColors: function(low, high) {
         var startColor = new mapfish.ColorRgb();
         startColor.setFromHex(low || this.cmp.colorLow.getValue());
@@ -214,27 +182,34 @@
             width: GIS.conf.layout.widget.item_width,
             labelWidth: GIS.conf.layout.widget.itemlabel_width,
             currentValue: false,
-            scope: this,
             store: GIS.store.groupSets, //todo
             listeners: {
-                select: function() {
-					var store = GIS.store.groupsByGroupSet,
-						value = this.getValue();
-					
-					store.proxy.url = GIS.conf.url.path_api +  'organisationUnitGroupSets/' + value + '.json?links=false&paging=false';
-					store.load({
-						scope: this.scope,
-						callback: function() {
-							if (this.config.extended.updateGui) { // If favorite, load store and continue execution
-								if (this.config.extended.updateOrganisationUnit) {
-									this.loadOrganisationUnits();
-								}
-								else {
-									this.loadLegend();
-								}
-							}	
-						}
-					});
+                select: {
+					scope: this,
+					fn: function(cb) {
+						var store = GIS.store.groupsByGroupSet,
+							value = cb.getValue();
+							
+						this.config.extended.updateLegend = true;
+						
+						store.proxy.url = GIS.conf.url.path_gis + 'getOrganisationUnitGroupsByGroupSet.action?id=' + value;
+						store.load(); //{
+							//scope: this.scope,
+							//callback: function() {
+								//if (this.config.extended.updateGui) { // If favorite, wait for callback and continue execution
+									//if (this.config.extended.updateOrganisationUnit) {
+										//this.loadOrganisationUnits();
+									//}
+									//else {
+										//this.loadLegend();
+									//}
+								//}
+								//else {
+									//this.config.extended.updateLegend = true;
+								//}
+							//}
+						//});
+					}
                 }
             }
         });
@@ -272,28 +247,10 @@
 			multiSelect: false,
 			width: GIS.conf.layout.widget.item_width,
 			height: 248,
-			pathToSelect: null,
-			pathToExpand: null,
 			reset: function() {
-				//this.collapseAll();
-				this.expandTreePath(GIS.init.rootNodes[0].path);
-				this.selectTreePath(GIS.init.rootNodes[0].path);
-			},
-			selectTreePath: function(path) {
-				if (this.rendered) {
-					this.selectPath(path);
-				}
-				else {
-					this.pathToSelect = path;
-				}
-			},
-			expandTreePath: function(path) {
-				if (this.rendered) {
-					this.expandPath(path);
-				}
-				else {
-					this.pathToExpand = path;
-				}
+				this.collapseAll();
+				this.expandPath(GIS.init.rootNodes[0].path);
+				this.selectPath(GIS.init.rootNodes[0].path);
 			},
 			store: Ext.create('Ext.data.TreeStore', {
 				proxy: {
@@ -320,19 +277,8 @@
 						this.config.extended.updateOrganisationUnit = true;
 					}
 				},
-				afterrender: function() {					
-					if (this.pathToSelect) {
-						this.selectPath(this.pathToSelect);
-						this.pathToSelect = null;
-					}
-					else {
-						this.getSelectionModel().select(0);
-					}
-					
-					if (this.pathToExpand) {
-						this.expandPath(this.pathToExpand);
-						this.pathToExpand = null;
-					}
+				afterrender: function() {
+					this.getSelectionModel().select(0);
 				}
 			}
         });
@@ -757,19 +703,15 @@
 		GIS.store.groupSets.load({
 			callback: function() {
 				that.cmp.groupSet.setValue(view.organisationUnitGroupSet.id);
-				that.cmp.groupSet.fireEvent('select');
 			}
 		});
-
-		this.cmp.groupSet.setValue(view.organisationUnitGroupSet.id);
-		this.cmp.groupSet.fireEvent('select');
 		
 		// Level and parent
 		GIS.store.organisationUnitLevels.loadFn( function() {
 			that.cmp.level.setValue(view.organisationUnitLevel.id);
 		});
 		
-		this.cmp.parent.selectTreePath('/root' + view.parentGraph);
+		this.cmp.parent.selectPath('/root' + view.parentGraph);
 	},
     	
 	getView: function() {
@@ -880,30 +822,67 @@
 	},
 	
     loadOrganisationUnits: function() {
-        var url = GIS.conf.url.path_gis + 'getGeoJsonFacilities.action?' +
-            'parentId=' + this.tmpView.parentOrganisationUnit.id +
-            '&level=' + this.tmpView.organisationUnitLevel.id;
-        this.setUrl(url);
+		Ext.Ajax.request({
+			url: GIS.conf.url.path_gis + 'getGeoJsonFacilities.action',
+			params: {
+				parentId: this.tmpView.parentOrganisationUnit.id,
+				level: this.tmpView.organisationUnitLevel.id
+			},
+			scope: this,
+			success: function(r) {
+				var geojson = this.decode(r.responseText),
+					format = new OpenLayers.Format.GeoJSON(),
+					features = format.read(geojson);
+					
+				if (!features.length) {
+					alert('No valid coordinates found'); //todo //i18n
+					GIS.mask.hide();
+					
+					this.config = {
+						extended: {}
+					};
+					return;
+				}
+				
+				this.loadData(features);
+			}
+		});
     },
     
-    loadData: function() {
-		for (var i = 0; i < this.layer.features.length; i++) {
-			var feature = this.layer.features[i];
+    loadData: function(features) {
+		features = features || this.layer.features;
+		
+		for (var i = 0; i < features.length; i++) {
+			var feature = features[i];
 			feature.attributes.label = feature.attributes.name;
 		}
+				
+		this.layer.removeFeatures(this.layer.features);
+		this.layer.addFeatures(features);
+		this.layer.features = GIS.util.vector.getTransformedFeatureArray(this.layer.features);
+		this.features = this.layer.features.slice(0);
 		
 		this.loadLegend();
 	},
 	
 	loadLegend: function() {
-		var options = {
-            indicator: this.tmpView.organisationUnitGroupSet.name
-		};
+		var store = GIS.store.groupsByGroupSet,
+			options;
+			
+		store.proxy.url = GIS.conf.url.path_gis + 'getOrganisationUnitGroupsByGroupSet.action?id=' + this.tmpView.organisationUnitGroupSet.id;
+		store.load({
+			scope: this,
+			callback: function() {
+				options = {
+					indicator: this.tmpView.organisationUnitGroupSet.name
+				};
 
-        this.coreComp.applyClassification(options);
-        this.classificationApplied = true;
-        
-        this.afterLoad();
+				this.coreComp.applyClassification(options);
+				this.classificationApplied = true;
+				
+				this.afterLoad();
+			}
+		});
 	},	
 	
     execute: function(view) {
@@ -924,20 +903,24 @@
 		GIS.mask.msg = GIS.i18n.loading;
 		GIS.mask.show();
 		
-		if (this.tmpView.extended.updateGui) { // If favorite, wait for groups store callback 
-			this.setGui();
-		}
-		else {
+		//if (this.tmpView.extended.updateGui) { // If favorite, wait for groups store callback 
+			//this.setGui();
+		//}
+		//else {
 			if (this.tmpView.extended.updateOrganisationUnit) {
 				this.loadOrganisationUnits();
 			}
 			else {
 				this.loadLegend();
 			}
-		}
+		//}
 	},
 	
 	afterLoad: function() {
+		if (this.tmpView.extended.updateGui) {
+			this.setGui();
+		}
+		
 		this.view = this.tmpView;
 		this.config = {
 			extended: {}

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/widgets/geostat/Thematic1.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/widgets/geostat/Thematic1.js	2012-11-02 19:46:41 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/widgets/geostat/Thematic1.js	2012-11-04 18:50:13 +0000
@@ -41,7 +41,6 @@
     labelGenerator: null,
     
     // Properties
-    
     config: {
 		extended: {}
 	},
@@ -202,39 +201,6 @@
 		})
 	},
     
-    setUrl: function(url) {
-        this.url = url;
-        this.coreComp.setUrl(this.url);
-    },
-
-    requestSuccess: function(request) {
-        var doc = request.responseXML,
-			format = new OpenLayers.Format.GeoJSON();
-			
-        if (!doc || !doc.documentElement) {
-            doc = request.responseText;
-        }
-        
-        if (doc.length) {
-            doc = GIS.util.geojson.decode(doc, this);
-        }
-        else {
-			alert('No valid coordinates found'); //todo //i18n
-		}
-        
-        this.layer.removeFeatures(this.layer.features);
-        this.layer.addFeatures(format.read(doc));
-		this.layer.features = GIS.util.vector.getTransformedFeatureArray(this.layer.features);
-        this.features = this.layer.features.slice(0);
-        
-        this.loadData();
-    },
-
-    requestFailure: function(request) {
-        GIS.logg.push(request.status, request.statusText);        
-        console.log(request.status, request.statusText);
-    },
-    
     getColors: function(low, high) {
         var startColor = new mapfish.ColorRgb();
         startColor.setFromHex(low || this.cmp.colorLow.getValue());
@@ -709,28 +675,10 @@
 			multiSelect: false,
 			width: GIS.conf.layout.widget.item_width,
 			height: 210,
-			pathToSelect: null,
-			pathToExpand: null,
 			reset: function() {
 				this.collapseAll();
-				this.expandTreePath(GIS.init.rootNodes[0].path);
-				this.selectTreePath(GIS.init.rootNodes[0].path);
-			},
-			selectTreePath: function(path) {
-				if (this.rendered) {
-					this.selectPath(path);
-				}
-				else {
-					this.pathToSelect = path;
-				}
-			},
-			expandTreePath: function(path) {
-				if (this.rendered) {
-					this.expandPath(path);
-				}
-				else {
-					this.pathToExpand = path;
-				}
+				this.expandPath(GIS.init.rootNodes[0].path);
+				this.selectPath(GIS.init.rootNodes[0].path);
 			},
 			store: Ext.create('Ext.data.TreeStore', {
 				proxy: {
@@ -757,19 +705,8 @@
 						this.config.extended.updateOrganisationUnit = true;
 					}
 				},
-				afterrender: function() {					
-					if (this.pathToSelect) {
-						this.selectPath(this.pathToSelect);
-						this.pathToSelect = null;
-					}
-					else {
-						this.getSelectionModel().select(0);
-					}
-					
-					if (this.pathToExpand) {
-						this.expandPath(this.pathToExpand);
-						this.pathToExpand = null;
-					}
+				afterrender: function() {
+					this.getSelectionModel().select(0);
 				}
 			}
         });
@@ -1357,7 +1294,7 @@
 		this.cmp.colorHigh.reset();
 		this.cmp.radiusLow.reset();
 		this.cmp.radiusHigh.reset();
-		this.cmp.level.clearValue();
+		this.cmp.level.clearValue();		
 		this.cmp.parent.reset();
 		
 		// Layer options
@@ -1444,7 +1381,7 @@
 			that.cmp.level.setValue(view.organisationUnitLevel.id);
 		});
 		
-		this.cmp.parent.selectTreePath('/root' + view.parentGraph);
+		this.cmp.parent.selectPath('/root' + view.parentGraph);
 	},
     	
 	getView: function() {
@@ -1668,13 +1605,34 @@
 	},
 	
     loadOrganisationUnits: function() {
-        var url = GIS.conf.url.path_gis + 'getGeoJson.action?' +
-            'parentId=' + this.tmpView.parentOrganisationUnit.id +
-            '&level=' + this.tmpView.organisationUnitLevel.id;
-        this.setUrl(url);
+		Ext.Ajax.request({
+			url: GIS.conf.url.path_gis + 'getGeoJson.action',
+			params: {
+				parentId: this.tmpView.parentOrganisationUnit.id,
+				level: this.tmpView.organisationUnitLevel.id
+			},
+			scope: this,
+			success: function(r) {
+				var geojson = GIS.util.geojson.decode(r.responseText, this),
+					format = new OpenLayers.Format.GeoJSON(),
+					features = format.read(geojson);
+					
+				if (!features.length) {
+					alert('No valid coordinates found'); //todo //i18n
+					GIS.mask.hide();
+					
+					this.config = {
+						extended: {}
+					};
+					return;
+				}
+				
+				this.loadData(features);
+			}
+		});				
     },
     
-    loadData: function() {
+    loadData: function(features) {
 		var type = this.tmpView.valueType,
 			dataUrl = 'mapValues/' + GIS.conf.finals.dimension[type].param + '.json',
 			indicator = GIS.conf.finals.dimension.indicator,
@@ -1682,6 +1640,8 @@
 			period = GIS.conf.finals.dimension.period,
 			organisationUnit = GIS.conf.finals.dimension.organisationUnit,
 			params = {};
+			
+		features = features || this.layer.features;
 		
 		params[type === indicator.id ? indicator.param : dataElement.param] = this.tmpView[type].id;
 		params[period.param] = this.tmpView.period.id;
@@ -1697,16 +1657,20 @@
 				var values = Ext.decode(r.responseText),
 					featureMap = {},
 					valueMap = {},
-					features = [];
+					newFeatures = [];
 					
 				if (values.length === 0) {
-					alert('No aggregated data values found'); //todo
+					alert('No aggregated data values found'); //todo //i18n
 					GIS.mask.hide();
+					
+					this.config = {
+						extended: {}
+					};
 					return;
 				}
 				
-				for (var i = 0; i < this.layer.features.length; i++) {
-					var iid = this.layer.features[i].attributes.internalId;
+				for (var i = 0; i < features.length; i++) {
+					var iid = features[i].attributes.internalId;
 					featureMap[iid] = true;
 				}
 				for (var i = 0; i < values.length; i++) {
@@ -1715,17 +1679,20 @@
 					valueMap[iid] = value;
 				}
 				
-				for (var i = 0; i < this.layer.features.length; i++) {
-					var feature = this.layer.features[i],
+				for (var i = 0; i < features.length; i++) {
+					var feature = features[i],
 						iid = feature.attributes.internalId;						
 					if (featureMap.hasOwnProperty(iid) && valueMap.hasOwnProperty(iid)) {
 						feature.attributes.value = valueMap[iid];
 						feature.attributes.label = feature.attributes.name + ' (' + feature.attributes.value + ')';
-						features.push(feature);
+						newFeatures.push(feature);
 					}
 				}
 				
-				this.layer.features = features;
+				this.layer.removeFeatures(this.layer.features);
+				this.layer.addFeatures(newFeatures);
+				this.layer.features = GIS.util.vector.getTransformedFeatureArray(this.layer.features);
+				this.features = this.layer.features.slice(0);
 				
 				this.loadLegend();
 			}
@@ -1784,10 +1751,6 @@
 		GIS.mask.msg = GIS.i18n.loading;
 		GIS.mask.show();
 		
-		if (this.tmpView.extended.updateGui) {
-			this.setGui();
-		}
-		
 		if (this.tmpView.extended.updateOrganisationUnit) {
 			this.loadOrganisationUnits();
 		}
@@ -1799,7 +1762,11 @@
 		}
 	},
 	
-	afterLoad: function() {
+	afterLoad: function() {		
+		if (this.tmpView.extended.updateGui) {
+			this.setGui();
+		}
+		
 		this.view = this.tmpView;
 		this.config = {
 			extended: {}

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/widgets/geostat/Thematic2.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/widgets/geostat/Thematic2.js	2012-11-02 19:46:41 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/widgets/geostat/Thematic2.js	2012-11-04 18:50:13 +0000
@@ -41,7 +41,6 @@
     labelGenerator: null,
     
     // Properties
-    
     config: {
 		extended: {}
 	},
@@ -709,28 +708,10 @@
 			multiSelect: false,
 			width: GIS.conf.layout.widget.item_width,
 			height: 210,
-			pathToSelect: null,
-			pathToExpand: null,
 			reset: function() {
-				//this.collapseAll();
-				this.expandTreePath(GIS.init.rootNodes[0].path);
-				this.selectTreePath(GIS.init.rootNodes[0].path);
-			},
-			selectTreePath: function(path) {
-				if (this.rendered) {
-					this.selectPath(path);
-				}
-				else {
-					this.pathToSelect = path;
-				}
-			},
-			expandTreePath: function(path) {
-				if (this.rendered) {
-					this.expandPath(path);
-				}
-				else {
-					this.pathToExpand = path;
-				}
+				this.collapseAll();
+				this.expandPath(GIS.init.rootNodes[0].path);
+				this.selectPath(GIS.init.rootNodes[0].path);
 			},
 			store: Ext.create('Ext.data.TreeStore', {
 				proxy: {
@@ -757,19 +738,8 @@
 						this.config.extended.updateOrganisationUnit = true;
 					}
 				},
-				afterrender: function() {					
-					if (this.pathToSelect) {
-						this.selectPath(this.pathToSelect);
-						this.pathToSelect = null;
-					}
-					else {
-						this.getSelectionModel().select(0);
-					}
-					
-					if (this.pathToExpand) {
-						this.expandPath(this.pathToExpand);
-						this.pathToExpand = null;
-					}
+				afterrender: function() {
+					this.getSelectionModel().select(0);
 				}
 			}
         });
@@ -1357,7 +1327,7 @@
 		this.cmp.colorHigh.reset();
 		this.cmp.radiusLow.reset();
 		this.cmp.radiusHigh.reset();
-		this.cmp.level.clearValue();
+		this.cmp.level.clearValue();		
 		this.cmp.parent.reset();
 		
 		// Layer options
@@ -1444,7 +1414,7 @@
 			that.cmp.level.setValue(view.organisationUnitLevel.id);
 		});
 		
-		this.cmp.parent.selectTreePath('/root' + view.parentGraph);
+		this.cmp.parent.selectPath('/root' + view.parentGraph);
 	},
     	
 	getView: function() {
@@ -1668,13 +1638,29 @@
 	},
 	
     loadOrganisationUnits: function() {
-        var url = GIS.conf.url.path_gis + 'getGeoJson.action?' +
-            'parentId=' + this.tmpView.parentOrganisationUnit.id +
-            '&level=' + this.tmpView.organisationUnitLevel.id;
-        this.setUrl(url);
+		Ext.Ajax.request({
+			url: GIS.conf.url.path_gis + 'getGeoJson.action',
+			params: {
+				parentId: this.tmpView.parentOrganisationUnit.id,
+				level: this.tmpView.organisationUnitLevel.id
+			},
+			scope: this,
+			success: function(r) {
+				var geojson = GIS.util.geojson.decode(r.responseText, this),
+					format = new OpenLayers.Format.GeoJSON(),
+					features = format.read(geojson);
+					
+				if (!features.length) {
+					alert('No valid coordinates found'); //todo //i18n
+					return;
+				}
+				
+				this.loadData(features);
+			}
+		});				
     },
     
-    loadData: function() {
+    loadData: function(features) {
 		var type = this.tmpView.valueType,
 			dataUrl = 'mapValues/' + GIS.conf.finals.dimension[type].param + '.json',
 			indicator = GIS.conf.finals.dimension.indicator,
@@ -1682,6 +1668,8 @@
 			period = GIS.conf.finals.dimension.period,
 			organisationUnit = GIS.conf.finals.dimension.organisationUnit,
 			params = {};
+			
+		features = features || this.layer.features;
 		
 		params[type === indicator.id ? indicator.param : dataElement.param] = this.tmpView[type].id;
 		params[period.param] = this.tmpView.period.id;
@@ -1697,16 +1685,20 @@
 				var values = Ext.decode(r.responseText),
 					featureMap = {},
 					valueMap = {},
-					features = [];
+					newFeatures = [];
 					
 				if (values.length === 0) {
-					alert('No aggregated data values found'); //todo
+					alert('No aggregated data values found'); //todo //i18n
 					GIS.mask.hide();
+					
+					this.config = {
+						extended: {}
+					};
 					return;
 				}
 				
-				for (var i = 0; i < this.layer.features.length; i++) {
-					var iid = this.layer.features[i].attributes.internalId;
+				for (var i = 0; i < features.length; i++) {
+					var iid = features[i].attributes.internalId;
 					featureMap[iid] = true;
 				}
 				for (var i = 0; i < values.length; i++) {
@@ -1715,17 +1707,20 @@
 					valueMap[iid] = value;
 				}
 				
-				for (var i = 0; i < this.layer.features.length; i++) {
-					var feature = this.layer.features[i],
+				for (var i = 0; i < features.length; i++) {
+					var feature = features[i],
 						iid = feature.attributes.internalId;						
 					if (featureMap.hasOwnProperty(iid) && valueMap.hasOwnProperty(iid)) {
 						feature.attributes.value = valueMap[iid];
 						feature.attributes.label = feature.attributes.name + ' (' + feature.attributes.value + ')';
-						features.push(feature);
+						newFeatures.push(feature);
 					}
 				}
 				
-				this.layer.features = features;
+				this.layer.removeFeatures(this.layer.features);
+				this.layer.addFeatures(newFeatures);
+				this.layer.features = GIS.util.vector.getTransformedFeatureArray(this.layer.features);
+				this.features = this.layer.features.slice(0);
 				
 				this.loadLegend();
 			}
@@ -1784,10 +1779,6 @@
 		GIS.mask.msg = GIS.i18n.loading;
 		GIS.mask.show();
 		
-		if (this.tmpView.extended.updateGui) {
-			this.setGui();
-		}
-		
 		if (this.tmpView.extended.updateOrganisationUnit) {
 			this.loadOrganisationUnits();
 		}
@@ -1799,7 +1790,11 @@
 		}
 	},
 	
-	afterLoad: function() {
+	afterLoad: function() {		
+		if (this.tmpView.extended.updateGui) {
+			this.setGui();
+		}
+		
 		this.view = this.tmpView;
 		this.config = {
 			extended: {}

=== added file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonminOrganisationUnitGroups.vm'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonminOrganisationUnitGroups.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonminOrganisationUnitGroups.vm	2012-11-04 18:50:13 +0000
@@ -0,0 +1,1 @@
+#set( $size = $object.size() ){"organisationUnitGroups":[#foreach ( $group in $object ){"id":"$!{group.uid}","name":"$!encoder.jsonEncode( ${group.name} )","symbol":"$!encoder.jsonEncode( ${group.symbol} )"}#if( $velocityCount < $size ),#end#end]}
\ No newline at end of file