← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17399: GIS option sets, work in progress.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 17399 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-11-10 14:41:40 +0100
message:
  GIS option sets, work in progress.
modified:
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/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-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java	2014-10-16 06:17:19 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java	2014-11-10 13:40:20 +0000
@@ -250,7 +250,7 @@
         SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
 
         log.debug( "Analytics event query SQL: " + sql );
-        
+z        
         while ( rowSet.next() )
         {
             grid.addRow();

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/core.js	2014-10-29 00:56:31 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/core.js	2014-11-10 13:40:20 +0000
@@ -1054,19 +1054,67 @@
                     rows = [],
                     lonIndex,
                     latIndex,
-                    map = Ext.clone(r.metaData.names);
-
-                // name-column map, lonIndex, latIndex
-                for (var i = 0; i < r.headers.length; i++) {
-                    map[r.headers[i].name] = r.headers[i].column;
-
-                    if (r.headers[i].name === 'longitude') {
+                    optionSetIndex,
+                    optionSet,
+                    map = Ext.clone(r.metaData.names),
+                    updateFeatures;
+
+                updateFeatures = function(map) {
+                    for (var i = 0, header; i < r.headers.length; i++) {
+                        header = r.headers[i];
+                        map[header.name] = header.column;
+                    }
+
+                    // events
+                    for (var i = 0, row, obj; i < rows.length; i++) {
+                        row = rows[i];
+                        obj = {};
+
+                        for (var j = 0; j < row.length; j++) {
+                            obj[r.headers[j].name] = j === optionSetIndex ? map[row[j]] : row[j];
+                        }
+
+                        obj[gis.conf.finals.widget.value] = 0;
+                        obj.label = obj.ouname;
+                        obj.popupText = obj.ouname;
+                        obj.nameColumnMap = map;
+
+                        events.push(obj);
+                    }
+
+                    // features
+                    for (var i = 0, event, point; i < events.length; i++) {
+                        event = events[i];
+
+                        point = gis.util.map.getTransformedPointByXY(event.longitude, event.latitude);
+
+                        features.push(new OpenLayers.Feature.Vector(point, event));
+                    }
+
+                    layer.removeFeatures(layer.features);
+                    layer.addFeatures(features);
+
+                    loadLegend(view);
+                };
+
+                // name-column map, lonIndex, latIndex, optionSet
+                for (var i = 0, header; i < r.headers.length; i++) {
+                    header = r.headers[i];
+
+                    map[header.name] = header.column;
+
+                    if (header.name === 'longitude') {
                         lonIndex = i;
                     }
 
-                    if (r.headers[i].name === 'latitude') {
+                    if (header.name === 'latitude') {
                         latIndex = i;
                     }
+
+                    if (Ext.isString(header.optionSet) && header.optionSet.length) {
+                        optionSetIndex = i;
+                        optionSet = header.optionSet;
+                    }
                 }
 
                 // get events with coordinates
@@ -1086,43 +1134,14 @@
                     return;
                 }
 
-                // name-column map
-                map = r.metaData.names;
-
-                for (var i = 0; i < r.headers.length; i++) {
-                    map[r.headers[i].name] = r.headers[i].column;
-                }
-
-                // events
-                for (var i = 0, row, obj; i < rows.length; i++) {
-                    row = rows[i];
-                    obj = {};
-
-                    for (var j = 0; j < row.length; j++) {
-                        obj[r.headers[j].name] = row[j];
-                    }
-
-                    obj[gis.conf.finals.widget.value] = 0;
-                    obj.label = obj.ouname;
-                    obj.popupText = obj.ouname;
-                    obj.nameColumnMap = map;
-
-                    events.push(obj);
-                }
-
-                // features
-                for (var i = 0, event, point; i < events.length; i++) {
-                    event = events[i];
-
-                    point = gis.util.map.getTransformedPointByXY(event.longitude, event.latitude);
-
-                    features.push(new OpenLayers.Feature.Vector(point, event));
-                }
-
-                layer.removeFeatures(layer.features);
-                layer.addFeatures(features);
-
-                loadLegend(view);
+                // option set
+                if (optionSet) {
+                    updateFeatures(r.metaData.names);
+                }
+                else {
+                    updateFeatures(r.metaData.names);
+                }
+
             };
 
 			if (Ext.isObject(GIS.app)) {