← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 315: Method and classes now part of MapLegendSet object + Background wfs is now loading entirely on st...

 

------------------------------------------------------------
revno: 315
committer: Jan Henrik Overland janhenrik.overland@xxxxxxxxx
branch nick: trunk
timestamp: Fri 2009-05-22 19:15:35 +0200
message:
  Method and classes now part of MapLegendSet object + Background wfs is now loading entirely on startup.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendSet.java
  dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLegendSet.hbm.xml
  gis/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddMapLegendSetAction.java
  gis/dhis-web-mapping/src/main/webapp/demos/geostat/geostat.js
  gis/dhis-web-mapping/src/main/webapp/demos/geostat/index.html
  gis/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapLegendSet.vm
  gis/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonminMapLegendSets.vm
  gis/dhis-web-mapping/src/main/webapp/mfbase/mapfish/widgets/geostat/Choropleth.js

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendSet.java	2009-04-22 16:19:08 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendSet.java	2009-05-22 17:15:35 +0000
@@ -41,6 +41,10 @@
 
     private String name;
     
+    private int method;
+    
+    private int classes;
+    
     private String colorLow;
     
     private String colorHigh;
@@ -51,9 +55,11 @@
     {
     }
 
-    public MapLegendSet( String name, String colorLow, String colorHigh, Set<Indicator> indicators )
+    public MapLegendSet( String name, int method, int classes, String colorLow, String colorHigh, Set<Indicator> indicators )
     {
         this.name = name;
+        this.method = method;
+        this.classes = classes;
         this.colorLow = colorLow;
         this.colorHigh = colorHigh;
         this.indicators = indicators;
@@ -115,6 +121,26 @@
     {
         this.name = name;
     }
+    
+    public int getMethod()
+    {
+        return method;
+    }
+
+    public void setMethod( int method )
+    {
+        this.method = method;
+    }
+
+    public int getClasses()
+    {
+        return classes;
+    }
+
+    public void setClasses( int classes )
+    {
+        this.classes = classes;
+    }
 
     public String getColorLow()
     {

=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLegendSet.hbm.xml'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLegendSet.hbm.xml	2009-05-11 12:56:56 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLegendSet.hbm.xml	2009-05-22 17:15:35 +0000
@@ -13,6 +13,10 @@
 	
 		<property name="name" column="name" unique="true"/>
 	
+		<property name="method" column="method"/>
+		
+		<property name="classes" column="classes"/>
+		
 		<property name="colorLow" column="colorlow"/>
 			
 		<property name="colorHigh" column="colorhigh"/>	

=== modified file 'gis/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddMapLegendSetAction.java'
--- gis/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddMapLegendSetAction.java	2009-04-22 16:19:08 +0000
+++ gis/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddMapLegendSetAction.java	2009-05-22 17:15:35 +0000
@@ -72,6 +72,20 @@
     {
         this.name = name;
     }
+    
+    private int method;
+    
+    public void setMethod( int method )
+    {
+        this.method = method;
+    }
+    
+    private int classes;
+
+    public void setClasses( int classes )
+    {
+        this.classes = classes;
+    }
 
     private String colorLow;
 
@@ -103,6 +117,8 @@
         MapLegendSet legendSet = new MapLegendSet();
         
         legendSet.setName( name );
+        legendSet.setMethod( method );
+        legendSet.setClasses( classes );
         legendSet.setColorLow( colorLow );
         legendSet.setColorHigh( colorHigh );
         legendSet.setIndicators( new HashSet<Indicator>() );        

=== modified file 'gis/dhis-web-mapping/src/main/webapp/demos/geostat/geostat.js'
--- gis/dhis-web-mapping/src/main/webapp/demos/geostat/geostat.js	2009-05-19 14:11:02 +0000
+++ gis/dhis-web-mapping/src/main/webapp/demos/geostat/geostat.js	2009-05-22 17:15:35 +0000
@@ -548,14 +548,23 @@
         minListWidth: combo_width + 26,
         store: existingMapsStore
     });
-    
+    /*
+    var temptest = new Ext.ux.Multiselect(
+    {
+        store: existingMapsStore,
+        valueField: 'mapLayerPath',
+        displayField: 'name',
+        mode: 'remote',
+        id: 'testtemp'
+    });
+    */
     var newMapPanel = new Ext.Panel(
     {   
         id: 'newmap_p',
         items:
         [   
             { html: '<p style="padding-bottom:4px">Map type:</p>' }, typeComboBox, { html: '<br>' },
-//            { html: '<p style="padding-bottom:4px">Organisation unit level:</p>' }, newMapComboBox, { html: '<br>' },
+//            { html: '<p style="padding-bottom:4px">Organisation unit level:</p>' }, temptest, { html: '<br>' },
 //            { html: '<p style="padding-bottom:4px">Organisation unit:</p>' }, organisationUnitComboBox, { html: '<br>' },
             { html: '<p style="padding-bottom:4px">Organisation unit level:</p>' }, organisationUnitLevelComboBox, { html: '<br>' },
             { html: '<p style="padding-bottom:4px">Map name:</p>' }, newNameTextField, { html: '<br>' },
@@ -681,6 +690,38 @@
         width: combo_width
     });
     
+    var legendSetMethodComboBox = new Ext.form.ComboBox({
+        id: 'legendsetmethod_cb',
+        editable: false,
+        valueField: 'value',
+        displayField: 'text',
+        mode: 'local',
+        emptyText: 'Required',
+        triggerAction: 'all',
+        width: combo_width,
+        minListWidth: combo_width + 26,
+        store: new Ext.data.SimpleStore({
+            fields: ['value', 'text'],
+            data: [[2, 'Distributed values'], [1, 'Equal intervals']]
+        })
+    });
+    
+    var legendSetClassesComboBox = new Ext.form.ComboBox({
+        id: 'legendsetclasses_cb',
+        editable: false,
+        valueField: 'value',
+        displayField: 'value',
+        mode: 'local',
+        emptyText: 'Required',
+        triggerAction: 'all',
+        width: combo_width,
+        minListWidth: combo_width + 26,
+        store: new Ext.data.SimpleStore({
+            fields: ['value'],
+            data: [[1], [2], [3], [4], [5], [6], [7], [8]]
+        })
+    });
+    
     var legendSetLowColorColorPalette = new Ext.ux.ColorField({
         id: 'legendsetlowcolor_cp',
         allowBlank: false,
@@ -788,11 +829,13 @@
         handler: function()
         {
             var ln = Ext.getCmp('legendsetname_tf').getValue();
+//            var lm = Ext.getCmp('legendsetmethod_cb').getValue();
+            var lc = Ext.getCmp('legendsetclasses_cb').getValue();            
             var llc = Ext.getCmp('legendsetlowcolor_cp').getValue();
             var lhc = Ext.getCmp('legendsethighcolor_cp').getValue();
             var li = Ext.getCmp('legendsetindicator_cb').getValue();
             
-            if (!ln || !li)
+            if (!lc || !ln || !li)
             {
                 Ext.MessageBox.alert('Error', 'Form is not complete');
                 return;
@@ -802,7 +845,7 @@
             {
                 url: path + 'addMapLegendSet' + type,
                 method: 'GET',
-                params: { name: ln, colorLow: llc, colorHigh: lhc, indicators: li },
+                params: { name: ln, method: 2, classes: lc, colorLow: llc, colorHigh: lhc, indicators: li },
 
                 success: function( responseObject )
                 {
@@ -872,6 +915,8 @@
         items:
         [   
             { html: '<p style="padding-bottom:4px">Name:</p>' }, legendSetNameTextField, { html: '<br>' },
+//            { html: '<p style="padding-bottom:4px">Method:</p>' }, legendSetMethodComboBox, { html: '<br>' },
+            { html: '<p style="padding-bottom:4px">Classes:</p>' }, legendSetClassesComboBox, { html: '<br>' },
             { html: '<p style="padding-bottom:4px">Lowest value color:</p>' }, legendSetLowColorColorPalette, { html: '<br>' },
             { html: '<p style="padding-bottom:4px">Highest value color:</p>' }, legendSetHighColorColorPalette, { html: '<br>' },
             { html: '<p style="padding-bottom:4px">Indicator group:</p>' }, legendSetIndicatorGroupComboBox, { html: '<br>' },
@@ -1138,7 +1183,9 @@
                 id: 'center',
                 title: 'Map',
                 xtype: 'mapcomponent',
-                map: map
+                map: map,
+                width: 1000,
+                height: 1000
             }
         ]
     });
@@ -1271,7 +1318,6 @@
 
 function loadMapData(redirect)
 {
-                                                 if (url == null) {url = 'who:clinics';}
     Ext.Ajax.request( 
     {
         url: path + 'getMapByMapLayerPath' + type,

=== modified file 'gis/dhis-web-mapping/src/main/webapp/demos/geostat/index.html'
--- gis/dhis-web-mapping/src/main/webapp/demos/geostat/index.html	2009-04-17 23:00:32 +0000
+++ gis/dhis-web-mapping/src/main/webapp/demos/geostat/index.html	2009-05-22 17:15:35 +0000
@@ -24,7 +24,10 @@
     
     <!-- EXT colorField Extent -->
     <script type="text/javascript" src="../../mfbase/ext-community-extensions/color-field.js"></script>
-
+    <!--
+    <script type="text/javascript" src="../../mfbase/ext-community-extensions/Multiselect.js"></script>
+    <script type="text/javascript" src="../../mfbase/ext-community-extensions/DDView.js"></script>
+    -->
     <!-- Div script -->
     
     <script type="text/javascript" src="config.js"></script>

=== modified file 'gis/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapLegendSet.vm'
--- gis/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapLegendSet.vm	2009-04-28 14:23:39 +0000
+++ gis/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapLegendSet.vm	2009-05-22 17:15:35 +0000
@@ -1,7 +1,9 @@
 { "mapLegendSet":
   [{
-    "id": $!{object.id},
+    "id": "$!{object.id}",
     "name": "$!encoder.jsEncode( ${object.name} )",
+    "method": "$!{object.method}",
+    "classes": "$!{object.classes}",
     "colorLow": "$!encoder.jsEncode( ${object.colorLow} )",
     "colorHigh": "$!encoder.jsEncode( ${object.colorHigh} )"
   }]

=== modified file 'gis/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonminMapLegendSets.vm'
--- gis/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonminMapLegendSets.vm	2009-04-23 17:07:39 +0000
+++ gis/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonminMapLegendSets.vm	2009-05-22 17:15:35 +0000
@@ -2,7 +2,7 @@
 { "mapLegendSets": [
 #foreach( $legendSet in $object )
   {
-    "id": $!{legendSet.id},
+    "id": "$!{legendSet.id}",
     "name": "$!encoder.jsEncode( ${legendSet.name} )"
   }#if( $velocityCount < $size ),#end
 #end

=== modified file 'gis/dhis-web-mapping/src/main/webapp/mfbase/mapfish/widgets/geostat/Choropleth.js'
--- gis/dhis-web-mapping/src/main/webapp/mfbase/mapfish/widgets/geostat/Choropleth.js	2009-05-19 13:57:43 +0000
+++ gis/dhis-web-mapping/src/main/webapp/mfbase/mapfish/widgets/geostat/Choropleth.js	2009-05-22 17:15:35 +0000
@@ -24,6 +24,7 @@
 
 Ext.namespace('mapfish.widgets', 'mapfish.widgets.geostat');
 
+     
 /**
  * Class: mapfish.widgets.geostat.Choropleth
  * Use this class to create a widget allowing to display choropleths
@@ -139,8 +140,6 @@
      
     newUrl : false,
     
-    currentUrl : false,
-    
     initComponent : function() {
     
         indicatorGroupStore = new Ext.data.JsonStore({
@@ -250,13 +249,36 @@
                 'select': {
                     fn: function()
                     {
-                        var legend_cb = Ext.getCmp('maplegend_cb');
                         var iId = Ext.getCmp('indicator_cb').getValue();
                         
-                        legend_cb.reset();
-                        legend_cb.getStore().baseParams = { indicatorId: iId, format: 'json' };
-                        legend_cb.getStore().reload();
-                    }
+                        Ext.Ajax.request(
+                        {
+                            url: path + 'getMapLegendSet' + type,
+                            method: 'GET',
+                            params: { indicatorId: iId, format: 'json' },
+
+                            success: function( responseObject )
+                            {
+                                var data = Ext.util.JSON.decode(responseObject.responseText);
+                                
+                                if (data.mapLegendSet[0].id != '')
+                                {
+//                                    Ext.getCmp('method').setValue(data.mapLegendSet[0].method);
+                                    Ext.getCmp('numClasses').setValue(data.mapLegendSet[0].classes);
+
+                                    Ext.getCmp('colorA_cf').setValue(data.mapLegendSet[0].colorLow);
+                                    Ext.getCmp('colorB_cf').setValue(data.mapLegendSet[0].colorHigh);
+                                }
+                                
+                                choropleth.classify(false);
+                            },
+                            failure: function()
+                            {
+                              alert( 'Status', 'Error while retrieving data' );
+                            } 
+                        });
+                    },
+                    scope: this
                 }
             }
         },
@@ -303,7 +325,16 @@
             emptyText: 'Required',
             selectOnFocus: true,
             width: combo_width,
-            store: periodStore
+            store: periodStore,
+            listeners: {
+                'select': {
+                    fn: function()
+                    {
+                        this.classify(false);
+                    },
+                    scope: this
+                }
+            }
         },
         
         {
@@ -335,7 +366,7 @@
         },
         
         { html: '<br>' },
-        
+
         {
             xtype: 'combo',
             fieldLabel: 'Method',
@@ -351,9 +382,18 @@
             store: new Ext.data.SimpleStore({
                 fields: ['value', 'text'],
                 data: [[2, 'Distributed values'], [1, 'Equal intervals']]
-            })
-        },   
-        
+            }),
+            listeners: {
+                'select': {
+                    fn: function()
+                    {
+                        this.classify(false);
+                    },
+                    scope: this
+                }
+            }
+        },
+
         {
             xtype: 'combo',
             fieldLabel: 'Classes',
@@ -368,9 +408,18 @@
             store: new Ext.data.SimpleStore({
                 fields: ['value'],
                 data: [[1], [2], [3], [4], [5], [6], [7], [8]]
-            })
+            }),
+            listeners: {
+                'select': {
+                    fn: function()
+                    {
+                        this.classify(false);
+                    },
+                    scope: this
+                }
+            }
         },
-        
+/*        
         {
             xtype: 'combo',
             id: 'maplegend_cb',
@@ -412,36 +461,41 @@
                               alert( 'Status', 'Error while retrieving data' );
                             } 
                         });
+                        
+                        this.classify(false);
                     },
                     scope: this
                 }
             }
 
         },
+ */
  
         {
             xtype: 'colorfield',
-            fieldLabel: 'Color',
+            fieldLabel: 'Low color',
             id: 'colorA_cf',
             allowBlank: false,
+            isFormField: true,
             width: combo_width,
             value: "#FFFF00"
         },
         
         {
             xtype: 'colorfield',
-            fieldLabel: 'Color',
+            fieldLabel: 'High color',
             id: 'colorB_cf',
             allowBlank: false,
+            isFormField: true,
             width: combo_width,
             value: "#FF0000"
         },
         
-        { html: '<br>' },
-        
-        {
+        { html: '<br>' }
+
+        ,{
             xtype: 'button',
-            text: 'Refresh map',
+            text: 'Refresh colors',
             handler: function()
             {
                 this.layer.setVisibility(true);
@@ -449,7 +503,7 @@
             },
             scope: this
         }
-        
+
         ];
 
         mapfish.widgets.geostat.Choropleth.superclass.initComponent.apply(this);
@@ -484,7 +538,7 @@
     requestFailure: function(request) {
         OpenLayers.Console.error('Ajax request failed');
     },
-
+    
     /**
      * Method: getColors
      *    Retrieves the colors from form elements
@@ -515,12 +569,14 @@
             return;
         }
         
+//        this.layer.setVisibility(true);
+        
         if (this.newUrl) {
             url = this.newUrl;
             this.newUrl = false;
             this.setUrl('../../../geoserver/wfs?request=GetFeature&typename=' + url + '&outputformat=json&version=1.0.0');
         }
-        
+                
         if (!Ext.getCmp('indicator_cb').getValue() ||
             !Ext.getCmp('period_cb').getValue() ||
             !Ext.getCmp('map_cb').getValue()) {



--
Trunk
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.