← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14242: ER, inline caching, optimized requests + GIS, hidden layers included in favorites, layer window s...

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 14242 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-03-17 13:22:48 +0100
message:
  ER, inline caching, optimized requests + GIS, hidden layers included in favorites, layer window size reduced, equal counts default method, 100% default layer opacity + DV, bar chart label rotation removed.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml
  dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/app.js
  dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/core.js
  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/core.js
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.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
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java	2014-03-10 16:40:56 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java	2014-03-14 13:41:45 +0000
@@ -100,6 +100,8 @@
     private OrganisationUnitGroupSet organisationUnitGroupSet;
 
     private Integer areaRadius;
+    
+    private Boolean hidden;
 
     // -------------------------------------------------------------------------
     // Transient properties
@@ -343,6 +345,19 @@
     }
 
     @JsonProperty
+    @JsonView( { DetailedView.class, ExportView.class, DimensionalView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+    public Boolean getHidden()
+    {
+        return hidden;
+    }
+
+    public void setHidden( Boolean hidden )
+    {
+        this.hidden = hidden;
+    }
+
+    @JsonProperty
     @JsonView( { DetailedView.class, ExportView.class } )
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
     public String getParentGraph()
@@ -388,6 +403,7 @@
             opacity = mapView.getOpacity() == null ? opacity : mapView.getOpacity();
             organisationUnitGroupSet = mapView.getOrganisationUnitGroupSet() == null ? organisationUnitGroupSet : mapView.getOrganisationUnitGroupSet();
             areaRadius = mapView.getAreaRadius() == null ? areaRadius : mapView.getAreaRadius();
+            hidden = mapView.getHidden() == null ? hidden : mapView.getHidden();
         }
     }
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java	2014-03-14 11:18:48 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java	2014-03-17 08:37:35 +0000
@@ -357,9 +357,9 @@
         this.displayIncidentDate = displayIncidentDate;
     }
 
-    @JsonProperty
-    @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    //@JsonProperty
+    //@JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
+    //@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     private Object getValueFromTrackedEntityInstance( String property, TrackedEntityInstance entityInstance )
         throws Exception
     {

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2014-03-11 11:05:18 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2014-03-14 13:27:22 +0000
@@ -174,6 +174,7 @@
         executeSql( "ALTER TABLE maplegend DROP CONSTRAINT maplegend_name_key" );
 
         executeSql( "UPDATE mapview SET layer = 'thematic1' WHERE layer IS NULL" );
+        executeSql( "UPDATE mapview SET hidden = false WHERE hidden IS NULL" );
 
         executeSql( "DELETE FROM systemsetting WHERE name = 'longitude'" );
         executeSql( "DELETE FROM systemsetting WHERE name = 'latitude'" );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml	2013-10-16 08:49:41 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml	2014-03-14 13:27:22 +0000
@@ -113,6 +113,8 @@
       column="orgunitgroupsetid" foreign-key="fk_mapview_orgunitgroupsetid" />
 
     <property name="areaRadius" />
+	  
+	<property name="hidden" />
 
   </class>
 </hibernate-mapping>

=== modified file 'dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/app.js	2014-03-10 19:30:45 +0000
+++ dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/app.js	2014-03-17 12:03:26 +0000
@@ -2500,6 +2500,11 @@
             dataElementsByStageStore,
             organisationUnitGroupStore,
 
+        // cache
+            stageStorage = {},
+            attributeStorage = {},
+            dataElementStorage = {},
+
 		// components
 			program,
             onProgramSelect,
@@ -2575,27 +2580,7 @@
 
 		stagesByProgramStore = Ext.create('Ext.data.Store', {
 			fields: ['id', 'name'],
-			proxy: {
-				type: 'ajax',
-				url: '',
-				reader: {
-					type: 'json',
-					root: 'programStages'
-				}
-			},
 			isLoaded: false,
-			loadFn: function(fn) {
-				if (Ext.isFunction(fn)) {
-					if (this.isLoaded) {
-						fn.call();
-					}
-					else {
-						this.load({
-							callback: fn
-						});
-					}
-				}
-			},
 			listeners: {
 				load: function() {
 					if (!this.isLoaded) {
@@ -2627,7 +2612,7 @@
 			}
 		});
 
-		// components
+        // components
 
             // data element
 		program = Ext.create('Ext.form.field.ComboBox', {
@@ -2659,27 +2644,64 @@
 			}
 		});
 
-		onProgramSelect = function(programId) {
+		onProgramSelect = function(programId, favorite) {
+            var load;
+
+            programId = favorite ? favorite.program.id : programId;
 			stage.clearValue();
 
 			dataElementsByStageStore.removeAll();
 			dataElementSelected.removeAll();
 
-			stagesByProgramStore.proxy.url = ns.core.init.contextPath + '/api/programs/' + programId + '.json?viewClass=withoutOrganisationUnits&links=false&paging=false';
-			stagesByProgramStore.load({
-				callback: function(records) {
-					stage.enable();
-					stage.clearValue();
-					stage.queryMode = 'local';
-
-					if (records.length === 1) {
-						stage.setValue(records[0].data.id);
-
-						onStageSelect(records[0].data.id);
-					}
-				}
-			});
-
+            load = function(stages) {
+                stage.enable();
+                stage.clearValue();
+
+                stagesByProgramStore.removeAll();
+                stagesByProgramStore.loadData(stages);
+
+                stageId = (favorite ? favorite.programStage.id : null) || (stages.length === 1 ? stages[0].id : null);
+
+                if (stageId) {
+                    stage.setValue(stageId);
+                    onStageSelect(stageId, favorite);
+                }
+            };
+
+            if (stageStorage.hasOwnProperty(programId)) {
+                load(stageStorage[programId]);
+            }
+            else {
+                Ext.Ajax.request({
+                    url: ns.core.init.contextPath + '/api/programs/filtered.json?filter=id:eq:' + programId + '&include=programStages[id,name],attributes&paging=false',
+                    success: function(r) {
+                        var objects = Ext.decode(r.responseText).objects,
+                            stages,
+                            attributes,
+                            stageId;
+
+                        if (!objects.length) {
+                            return;
+                        }
+
+                        stages = objects[0].programStages;
+                        attributes = objects[0].attributes;
+
+                        // attributes cache
+                        if (Ext.isArray(attributes) && attributes.length) {
+                            attributeStorage[programId] = attributes;
+                        }
+
+                        if (Ext.isArray(stages) && stages.length) {
+
+                            // stages cache
+                            stageStorage[programId] = stages;
+
+                            load(stages);
+                        }
+                    }
+                });
+            }
 		};
 
 		stage = Ext.create('Ext.form.field.ComboBox', {
@@ -2692,7 +2714,7 @@
 			labelCls: 'ns-form-item-label-top',
 			labelSeparator: '',
 			emptyText: 'Select stage',
-			queryMode: 'remote',
+			queryMode: 'local',
 			forceSelection: true,
 			columnWidth: 0.5,
 			style: 'margin:1px 0 2px 1px',
@@ -2712,65 +2734,54 @@
 			}
 		});
 
-		onStageSelect = function(stageId) {
+		onStageSelect = function(stageId, favorite) {
 			dataElementSelected.removeAll();
 
-			loadDataElements(stageId);
+			loadDataElements(stageId, favorite);
 		};
 
-		loadDataElements = function(item, programId) {
-			var dataElements,
-				load,
-				fn;
-
-			programId = programId || program.getValue() || null;
-
-			load = function(attributes, dataElements) {
-				var data = Ext.Array.clean([].concat(attributes || [], dataElements || []));
+		loadDataElements = function(stageId, favorite) {
+			var programId = program.getValue() || null,
+                load;
+
+			load = function(dataElements) {
+                var attributes = attributeStorage[programId],
+                    data = Ext.Array.clean([].concat(attributes || [], dataElements || []));
+
 				dataElementsByStageStore.loadData(data);
 			};
 
-			fn = function(attributes) {
-
-				// data elements
-				if (Ext.isString(item)) {
-					Ext.Ajax.request({
-						url: ns.core.init.contextPath + '/api/programStages/' + item + '.json?links=false&paging=false',
-						success: function(r) {
-							var dataElements = Ext.Array.pluck(Ext.decode(r.responseText).programStageDataElements, 'dataElement');
-							load(attributes, dataElements);
-						}
-					});
-				}
-				else if (Ext.isArray(item)) {
-					load(attributes, item);
-				}
-			};
-
-			// attributes
-			if (programId) {
-				if (program.storage[programId]) {
-					fn(program.storage[programId]);
-				}
-				else {
-					Ext.Ajax.request({
-						url: ns.core.init.contextPath + '/api/programs/' + programId + '.json?viewClass=withoutOrganisationUnits&links=false',
-						success: function(r) {
-							var attributes = Ext.decode(r.responseText).attributes;
-
-							if (attributes) {
-								for (var i = 0; i < attributes.length; i++) {
-									attributes[i].type = attributes[i].valueType;
-								}
-
-								program.storage[programId] = attributes;
-							}
-
-							fn(attributes);
-						}
-					});
-				}
-			}
+            // favorite
+            if (favorite) {
+                dataElementsByStageStore.loadData(favorite.data); //todo
+                return;
+            }
+
+            // data elements
+            if (dataElementStorage.hasOwnProperty(stageId)) {
+                load(dataElementStorage[stageId]);
+            }
+            else {
+                Ext.Ajax.request({
+                    url: ns.core.init.contextPath + '/api/programStages/filtered.json?filter=id:eq:' + stageId + '&include=programStageDataElements[dataElement[id,name,type,optionSet[id,name]]]',
+                    success: function(r) {
+                        var objects = Ext.decode(r.responseText).objects,
+                            dataElements;
+
+                        if (!objects.length) {
+                            load();
+                            return;
+                        }
+
+                        dataElements = Ext.Array.pluck(objects[0].programStageDataElements, 'dataElement');
+
+                        // data elements cache
+                        dataElementStorage[stageId] = dataElements;
+
+                        load(dataElements);
+                    }
+                });
+            }
 		};
 
 		dataElementAvailable = Ext.create('Ext.ux.form.MultiSelect', {

=== modified file 'dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/core.js	2014-03-10 19:12:59 +0000
+++ dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/core.js	2014-03-13 10:28:05 +0000
@@ -1579,7 +1579,6 @@
 
 					response.idValueMap[id] = row[valueHeaderIndex];
 				}
-console.log("response.idValueMap", response.idValueMap);
 
 				return response;
 			};

=== 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	2014-03-06 11:02:06 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js	2014-03-14 13:41:45 +0000
@@ -176,7 +176,7 @@
 						}
 					}
 
-					if (layout.opacity === 0.8) {
+					if (layout.opacity === 1) {
 						delete layout.opacity;
 					}
 
@@ -692,7 +692,7 @@
 			text: null,
 			height: 22,
 			value: false,
-			opacity: 0.8,
+			opacity: 1,
 			getValue: function() {
 				return this.checkbox.getValue();
 			},
@@ -2493,7 +2493,7 @@
 				text: GIS.i18n.create,
 				handler: function() {
 					var name = nameTextfield.getValue(),
-						layers = gis.util.map.getVisibleVectorLayers(),
+						layers = gis.util.map.getRenderedVectorLayers(),
 						layer,
 						lonlat = gis.olmap.getCenter(),
 						views = [],
@@ -2512,9 +2512,11 @@
 
 					for (var i = 0; i < layers.length; i++) {
 						layer = layers[i];
-						//view = layer.widget.getView();
+
 						view = Ext.clone(layer.core.view);
 
+                        view.hidden = !layer.visibility;
+
 						// Operand
 						if (Ext.isArray(view.columns) && view.columns.length) {
 							for (var j = 0; j < view.columns.length; j++) {
@@ -2756,7 +2758,7 @@
 									message;
 
 								if (record.data.access.update) {
-									layers = gis.util.map.getVisibleVectorLayers();
+									layers = gis.util.map.getRenderedVectorLayers();
 									message = 'Overwrite favorite?\n\n' + record.data.name;
 
 									if (layers.length) {
@@ -2770,6 +2772,7 @@
 
 												// add
 												view.layer = layer.id;
+                                                view.hidden = !layer.visibility;
 
 												// remove
 												delete view.periodType;
@@ -4943,7 +4946,7 @@
 			setLayerGui = function() {
 
 				// Layer item
-				layer.item.setValue(true, view.opacity);
+				layer.item.setValue(!view.hidden, view.opacity);
 
 				// Layer menu
 				layer.menu.enableItems();
@@ -5058,7 +5061,7 @@
 
 		treePanel = Ext.create('Ext.tree.Panel', {
 			cls: 'gis-tree',
-			height: 300,
+			height: 200,
 			style: 'border-top: 1px solid #ddd; padding-top: 1px',
 			displayField: 'name',
 			width: gis.conf.layout.widget.item_width,
@@ -5606,7 +5609,7 @@
 			setLayerGui = function() {
 
 				// Layer item
-				layer.item.setValue(true, view.opacity);
+				layer.item.setValue(!view.hidden, view.opacity);
 
 				// Layer menu
 				layer.menu.enableItems();
@@ -5758,7 +5761,7 @@
 
 		treePanel = Ext.create('Ext.tree.Panel', {
 			cls: 'gis-tree',
-			height: 300,
+			height: 200,
 			style: 'border-top: 1px solid #ddd; padding-top: 1px',
 			displayField: 'name',
 			width: gis.conf.layout.widget.item_width,
@@ -6280,7 +6283,7 @@
 			setLayerGui = function() {
 
 				// Layer item
-				layer.item.setValue(true, view.opacity);
+				layer.item.setValue(!view.hidden, view.opacity);
 
 				// Layer menu
 				layer.menu.enableItems();
@@ -7040,7 +7043,7 @@
 			valueField: 'id',
 			displayField: 'name',
 			queryMode: 'local',
-			value: 2,
+			value: 3,
 			width: 135,
 			store: Ext.create('Ext.data.ArrayStore', {
 				fields: ['id', 'name'],
@@ -7081,7 +7084,7 @@
 
 		treePanel = Ext.create('Ext.tree.Panel', {
 			cls: 'gis-tree',
-			height: 300,
+			height: 200,
 			style: 'border-top: 1px solid #ddd; padding-top: 1px',
 			displayField: 'name',
 			width: gis.conf.layout.widget.item_width,
@@ -7736,7 +7739,7 @@
 			setLayerGui = function() {
 
 				// Layer item
-				layer.item.setValue(true, view.opacity);
+				layer.item.setValue(!view.hidden, view.opacity);
 
 				// Layer menu
 				layer.menu.enableItems();

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js	2014-03-06 11:02:06 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js	2014-03-14 13:27:22 +0000
@@ -143,7 +143,7 @@
 		});
 		layers.openStreetMap.id = 'openStreetMap';
 
-		layers.event = GIS.core.VectorLayer(gis, 'event', GIS.i18n.event_layer, {opacity: 0.8});
+		layers.event = GIS.core.VectorLayer(gis, 'event', GIS.i18n.event_layer, {opacity: 1});
 		layers.event.core = new mapfish.GeoStat.Event(gis.olmap, {
 			layer: layers.event,
 			gis: gis
@@ -155,7 +155,7 @@
 			gis: gis
 		});
 
-		layers.boundary = GIS.core.VectorLayer(gis, 'boundary', GIS.i18n.boundary_layer, {opacity: 0.8});
+		layers.boundary = GIS.core.VectorLayer(gis, 'boundary', GIS.i18n.boundary_layer, {opacity: 1});
 		layers.boundary.core = new mapfish.GeoStat.Boundary(gis.olmap, {
 			layer: layers.boundary,
 			gis: gis
@@ -164,7 +164,7 @@
 		for (var i = 0, number; i < layerNumbers.length; i++) {
 			number = layerNumbers[i];
 
-			layers['thematic' + number] = GIS.core.VectorLayer(gis, 'thematic' + number, GIS.i18n.thematic_layer + ' ' + number, {opacity: 0.8});
+			layers['thematic' + number] = GIS.core.VectorLayer(gis, 'thematic' + number, GIS.i18n.thematic_layer + ' ' + number, {opacity: 1});
 			layers['thematic' + number].layerCategory = gis.conf.finals.layer.category_thematic,
 			layers['thematic' + number].core = new mapfish.GeoStat['Thematic' + number](gis.olmap, {
 				layer: layers['thematic' + number],
@@ -2305,6 +2305,18 @@
 				return layers;
 			};
 
+			util.map.getRenderedVectorLayers = function() {
+				var layers = [];
+
+				for (var i = 0, layer; i < gis.olmap.layers.length; i++) {
+					layer = gis.olmap.layers[i];
+					if (layer.layerType === conf.finals.layer.type_vector && layer.features.length) {
+						layers.push(layer);
+					}
+				}
+				return layers;
+			};
+
 			util.map.getExtendedBounds = function(layers) {
 				var bounds = null;
 				if (layers.length) {
@@ -2551,10 +2563,14 @@
 
 				// radiusHigh: integer (15)
 
-				// opacity: integer (0.8) - 0-1
+				// opacity: integer (1) - 0-1
 
 				// legendSet: object
 
+                // areaRadius: integer
+
+                // hidden: boolean (false)
+
 				getValidatedDimensionArray = function(dimensionArray) {
 					var dimensions = [];
 
@@ -2692,7 +2708,9 @@
 					layout.colorHigh = Ext.isString(config.colorHigh) && !Ext.isEmpty(config.colorHigh) ? config.colorHigh : '00ff00';
 					layout.radiusLow = Ext.isNumber(config.radiusLow) && !Ext.isEmpty(config.radiusLow) ? config.radiusLow : 5;
 					layout.radiusHigh = Ext.isNumber(config.radiusHigh) && !Ext.isEmpty(config.radiusHigh) ? config.radiusHigh : 15;
-					layout.opacity = Ext.isNumber(config.opacity) && !Ext.isEmpty(config.opacity) ? config.opacity : 0.8;
+					layout.opacity = Ext.isNumber(config.opacity) && !Ext.isEmpty(config.opacity) ? config.opacity : 1;
+					layout.areaRadius = config.areaRadius;
+                    layout.hidden = !!config.hidden;
 
 					layout.userOrganisationUnit = isOu;
 					layout.userOrganisationUnitChildren = isOuc;
@@ -2703,7 +2721,6 @@
 					layout.legendSet = config.legendSet;
 
 					layout.organisationUnitGroupSet = config.organisationUnitGroupSet;
-					layout.areaRadius = config.areaRadius;
 
 					return layout;
 				}();

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.js	2014-03-06 11:02:06 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.js	2014-03-14 10:24:17 +0000
@@ -2246,6 +2246,7 @@
                     // Axes
                     numericAxis.position = 'bottom';
                     categoryAxis.position = 'left';
+                    categoryAxis.label.rotate.degrees = 360;
                     axes = [numericAxis, categoryAxis];
 
                     // Series