← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 174: deleteMapByMapLayerPath added to webservice. New map, edit map and delete map added to register s...

 

------------------------------------------------------------
revno: 174
committer: Jan Henrik Overland janhenrik.overland@xxxxxxxxx
branch nick: trunk
timestamp: Wed 2009-04-15 17:26:19 +0200
message:
  deleteMapByMapLayerPath added to webservice. New map, edit map and delete map added to register shapefiles window.
modified:
  gis/dhis-gis-geostat/demos/geostat/geostat.js
  gis/dhis-gis-geostat/mfbase/mapfish/core/GeoStat.js
  gis/dhis-gis-geostat/mfbase/mapfish/widgets/geostat/Choropleth.js
  webservice/dhis-webservice-expoze/src/main/java/org/hisp/dhis/webservice/adapter/mapping/DefaultMappingServiceAdapter.java
  webservice/dhis-webservice-expoze/src/main/java/org/hisp/dhis/webservice/adapter/mapping/MappingServiceAdapter.java
  webservice/dhis-webservice-expoze/src/main/resources/dispatcher.xml

=== modified file 'gis/dhis-gis-geostat/demos/geostat/geostat.js'
--- gis/dhis-gis-geostat/demos/geostat/geostat.js	2009-04-14 13:38:36 +0000
+++ gis/dhis-gis-geostat/demos/geostat/geostat.js	2009-04-15 15:26:19 +0000
@@ -97,6 +97,14 @@
         sortInfo: { field: 'name', direction: 'ASC' },
         autoLoad: false
     });
+    
+    existingMapsStore = new Ext.data.JsonStore({
+            url: localhost + '/dhis-webservice/getAllMaps.service',
+            baseParams: { format: 'jsonmin' },
+            root: 'maps',
+            fields: ['id', 'mapLayerPath', 'organisationUnitLevel'],
+            autoLoad: true
+    });
 
 
     var organisationUnitLevelCombo = new Ext.form.ComboBox({
@@ -229,9 +237,9 @@
             data: [[3], [4], [5], [6], [7], [8]]
         })
     });
-
-    var submitButton = new Ext.Button({
-        id: 'submit_b',
+    
+    var newMapButton = new Ext.Button({
+        id: 'newmap_b',
         text: 'Register map',
         handler: function()
         {
@@ -261,7 +269,96 @@
                 {
                     Ext.Msg.show({
                         title:'Register shapefiles',
-                        msg: '<p style="padding-top:8px"><b>The map </b>' + mlp + '<b> was successfully stored!</b></p>',
+                        msg: '<p style="padding-top:8px">The map <b>' + mlp + '</b> was successfully registered!</b></p>',
+                        buttons: Ext.Msg.OK,
+                        animEl: 'elId',
+                        minWidth: 400,
+                        icon: Ext.MessageBox.INFO
+                    });
+                    
+                    Ext.getCmp('map_cb').getStore().reload();
+                    Ext.getCmp('maps_cb').getStore().reload();
+                },
+                failure: function()
+                {
+                    alert( 'Status', 'Error while saving data' );
+                }
+            });
+        }
+    });
+    
+    var editMapButton = new Ext.Button({
+        id: 'editmap_b',
+        text: 'Save changes',
+        handler: function()
+        {
+            var em = Ext.getCmp('editmap_cb').getValue();
+            var uc = Ext.getCmp('uniquecolumn_tf').getValue();
+            var nc = Ext.getCmp('namecolumn_tf').getValue();
+            var lon = Ext.getCmp('longitude_tf').getValue();
+            var lat = Ext.getCmp('latitude_tf').getValue();
+            var zoom = Ext.getCmp('zoom_cb').getValue();
+            
+            if (!em || !uc || !nc || !lon || !lat)
+            {
+                Ext.MessageBox.alert('Error', 'Form is not complete');
+                return;
+            }
+            
+            Ext.Ajax.request(
+            {
+                url: localhost + '/dhis-webservice/addOrUpdateMap.service',
+                method: 'GET',
+                params: { mapLayerPath: mlp, organisationUnitId: oui, organisationUnitLevelId: ouli, uniqueColumn: uc, nameColumn: nc,
+                          longitude: lon, latitude: lat, zoom: zoom},
+
+                success: function( responseObject )
+                {
+                    Ext.Msg.show({
+                        title:'Register shapefiles',
+                        msg: '<p style="padding-top:8px">The map <b>' + mlp + '</b> was successfully updated!</b></p>',
+                        buttons: Ext.Msg.OK,
+                        animEl: 'elId',
+                        minWidth: 400,
+                        icon: Ext.MessageBox.INFO
+                    });
+                    
+                    Ext.getCmp('map_cb').getStore().reload();
+                    Ext.getCmp('maps_cb').getStore().reload();
+                },
+                failure: function()
+                {
+                    alert( 'Status', 'Error while saving data' );
+                }
+            });
+        }
+    });
+    
+    var deleteMapButton = new Ext.Button({
+        id: 'deletemap_b',
+        text: 'Delete map',
+        handler: function()
+        {
+            var mlp = Ext.getCmp('deletemap_cb').getValue();
+            
+alert(mlp);            
+            if (!mlp)
+            {
+                Ext.MessageBox.alert('Error', 'Choose a map');
+                return;
+            }
+            
+            Ext.Ajax.request(
+            {
+                url: localhost + '/dhis-webservice/deleteMapByMapLayerPath.service',
+                method: 'GET',
+                params: { mapLayerPath: mlp },
+
+                success: function( responseObject )
+                {
+                    Ext.Msg.show({
+                        title:'Register shapefiles',
+                        msg: '<p style="padding-top:8px">The map <b>' + mlp + '</b> was successfully deleted!</b></p>',
                         buttons: Ext.Msg.OK,
                         animEl: 'elId',
                         minWidth: 400,
@@ -282,16 +379,191 @@
     rootmap = new Ext.Panel({
         id: 'rootmap',
         title: 'Register shapefiles',
-        items: [ { html: '<p style="padding-bottom:4px">Load organisation units from level:</p>' }, organisationUnitLevelCombo, { html: '<br><br><br>' },
-                 { html: '<p style="padding-bottom:4px">Register map for this organisation unit:</p>' }, organisationUnitCombo, { html: '<br>' },
-                 { html: '<p style="padding-bottom:4px">Organisation unit level:</p>' }, organisationUnitLevelCombo2, { html: '<br>' },
-                 { html: '<p style="padding-bottom:4px">Geoserver map layer path:</p>' }, mapLayerPathTextField, { html: '<br>' },
-                 { html: '<p style="padding-bottom:4px">Unique column:</p>' }, uniqueColumnTextField, { html: '<br>' },
-                 { html: '<p style="padding-bottom:4px">Name column:</p>' }, nameColumnTextField, { html: '<br>' },
-                 { html: '<p style="padding-bottom:4px">Longitude:</p>' }, longitudeTextField, { html: '<br>' },
-                 { html: '<p style="padding-bottom:4px">Latitude:</p>' }, latitudeTextField, { html: '<br>' },
-                 { html: '<p style="padding-bottom:4px">Zoom:</p>' }, zoomComboBox, { html: '<br>' },
-                 submitButton ]
+        items:
+        [
+            {
+                xtype: 'tabpanel',
+                activeTab: 0,
+                deferredRender: false,
+                plain: true,
+                defaults: {layout: 'fit', bodyStyle: 'padding:8px'},
+                listeners: {
+                    tabchange: function(panel, tab) {
+                        if (tab.id == 0)
+                        {
+                            Ext.getCmp('panel1_p').setVisible(true);
+                            Ext.getCmp('panel2_p').setVisible(true);
+                            Ext.getCmp('newmap_b').setVisible(true);
+                            Ext.getCmp('editmap_b').setVisible(false);
+                            Ext.getCmp('deletemap_b').setVisible(false);
+                        }
+                        
+                        if (tab.id == 1)
+                        {
+                            Ext.getCmp('panel1_p').setVisible(false);
+                            Ext.getCmp('panel2_p').setVisible(true);
+                            Ext.getCmp('newmap_b').setVisible(false);
+                            Ext.getCmp('editmap_b').setVisible(true);
+                            Ext.getCmp('deletemap_b').setVisible(false);
+                        }
+                        
+                        if (tab.id == 2)
+                        {
+                            Ext.getCmp('panel1_p').setVisible(false);
+                            Ext.getCmp('panel2_p').setVisible(false);
+                            Ext.getCmp('newmap_b').setVisible(false);
+                            Ext.getCmp('editmap_b').setVisible(false);
+                            Ext.getCmp('deletemap_b').setVisible(true);
+                        }
+                    }
+                },
+                items:[
+                {
+                    title:'New map',
+                    id: '0',
+                    defaults:{layout: 'fit', border: false, bodyStyle: 'padding:10px'},
+                    items:
+                    [
+                        {
+                            xtype: 'combo',
+                            id: 'newmap_cb',
+                            typeAhead: true,
+                            editable: false,
+                            valueField: 'level',
+                            displayField: 'name',
+                            emptyText: 'Select organisation unit level',
+                            mode: 'remote',
+                            forceSelection: true,
+                            triggerAction: 'all',
+                            selectOnFocus: true,
+                            width: combo_width,
+                            store: organisationUnitLevelStore,
+                            listeners: {
+                                'select': {
+                                    fn: function() {
+                                        var level = Ext.getCmp('newmap_cb').getValue();
+                                        organisationUnitStore.baseParams = { level: level, format: 'json' };
+                                        organisationUnitStore.reload();
+                                    },
+                                    scope: this
+                                }
+                            }
+                        }
+                    ]
+                },
+                {
+                    title:'Edit map',
+                    id: '1',
+                    defaults:{layout: 'fit', border: false, bodyStyle: 'padding:8px'},
+                    items:
+                    [
+                        {
+                            xtype: 'combo',
+                            id: 'editmap_cb',
+                            typeAhead: true,
+                            editable: false,
+                            valueField: 'mapLayerPath',
+                            displayField: 'mapLayerPath',
+                            emptyText: 'Select map',
+                            mode: 'remote',
+                            forceSelection: true,
+                            triggerAction: 'all',
+                            selectOnFocus: true,
+                            width: combo_width,
+                            store: existingMapsStore,
+                            listeners:
+                            {
+                                'select':
+                                {
+                                    fn: function()
+                                    {
+                                        var mlp = Ext.getCmp('editmap_cb').getValue();
+                                        
+                                        Ext.Ajax.request( 
+                                        {
+                                            url: localhost + '/dhis-webservice/getMapByMapLayerPath.service',
+                                            method: 'GET',
+                                            params: { mapLayerPath: mlp, format: 'json' },
+
+                                            success: function( responseObject )
+                                            {
+                                                var map = Ext.util.JSON.decode( responseObject.responseText ).map;
+                                                
+                                                Ext.getCmp('uniquecolumn_tf').setValue(map.uniqueColumn);
+                                                Ext.getCmp('namecolumn_tf').setValue(map.nameColumn);
+                                                Ext.getCmp('longitude_tf').setValue(map.longitude);
+                                                Ext.getCmp('latitude_tf').setValue(map.latitude);
+                                                Ext.getCmp('zoom_cb').setValue(map.zoom);
+                                                
+                                            },
+                                            failure: function()
+                                            {
+                                                alert( 'Error while retrieving data: getAssignOrganisationUnitData' );
+                                            } 
+                                        });
+                                                                            
+                                        
+                                        
+                                    },
+                                    scope: this
+                                }
+                            }
+                        }
+                    ]
+                },
+                {
+                    title:'Delete map',
+                    id: '2',
+                    defaults:{layout: 'fit', border: false, bodyStyle: 'padding:8px'},
+                    items:
+                    [
+                        {
+                            xtype: 'combo',
+                            id: 'deletemap_cb',
+                            typeAhead: true,
+                            editable: false,
+                            valueField: 'mapLayerPath',
+                            displayField: 'mapLayerPath',
+                            emptyText: 'Select map',
+                            mode: 'remote',
+                            forceSelection: true,
+                            triggerAction: 'all',
+                            selectOnFocus: true,
+                            width: combo_width,
+                            store: existingMapsStore
+                        }
+                    ]
+                },]
+            },
+            
+            { html: '<br>' },
+            
+            {
+                xtype: 'panel',
+                id: 'panel1_p',
+                items:
+                [
+                    { html: '<p style="padding-bottom:4px">Register map for this organisation unit:</p>' }, organisationUnitCombo, { html: '<br>' },
+                    { html: '<p style="padding-bottom:4px">Organisation unit level:</p>' }, organisationUnitLevelCombo2, { html: '<br>' },
+                    { html: '<p style="padding-bottom:4px">Geoserver map layer path:</p>' }, mapLayerPathTextField, { html: '<br>' }
+                ]
+            },
+            
+            {
+                xtype: 'panel',
+                id: 'panel2_p',
+                items:
+                [
+                    { html: '<p style="padding-bottom:4px">Unique column:</p>' }, uniqueColumnTextField, { html: '<br>' },
+                    { html: '<p style="padding-bottom:4px">Name column:</p>' }, nameColumnTextField, { html: '<br>' },
+                    { html: '<p style="padding-bottom:4px">Longitude:</p>' }, longitudeTextField, { html: '<br>' },
+                    { html: '<p style="padding-bottom:4px">Latitude:</p>' }, latitudeTextField, { html: '<br>' },
+                    { html: '<p style="padding-bottom:4px">Zoom:</p>' }, zoomComboBox, { html: '<br>' }
+                ]
+            },
+
+            newMapButton, editMapButton, deleteMapButton
+        ]
     });
     
     
@@ -300,7 +572,7 @@
         id: 'choropleth',
         map: map,
         layer: choroplethLayer,
-        title: 'Choropleth',
+        title: 'Thematic map',
         nameAttribute: "NAME",
         indicators: [['value', 'Indicator']],
 //        url: '../../../geoserver/wfs?request=GetFeature&typename=who:sl_init&outputformat=json&version=1.0.0',

=== modified file 'gis/dhis-gis-geostat/mfbase/mapfish/core/GeoStat.js'
--- gis/dhis-gis-geostat/mfbase/mapfish/core/GeoStat.js	2009-04-14 12:17:30 +0000
+++ gis/dhis-gis-geostat/mfbase/mapfish/core/GeoStat.js	2009-04-15 15:26:19 +0000
@@ -275,7 +275,6 @@
      * options - {Object}
      */
     applyClassification: function(options) {
-//    alert("applyClassification");
         this.layer.renderer.clear();
         this.layer.redraw();
         this.updateLegend();

=== modified file 'gis/dhis-gis-geostat/mfbase/mapfish/widgets/geostat/Choropleth.js'
--- gis/dhis-gis-geostat/mfbase/mapfish/widgets/geostat/Choropleth.js	2009-04-14 13:21:16 +0000
+++ gis/dhis-gis-geostat/mfbase/mapfish/widgets/geostat/Choropleth.js	2009-04-15 15:26:19 +0000
@@ -291,6 +291,8 @@
                         var iId = Ext.getCmp('indicator_cb').getValue();
                         legendStore.baseParams = { indicatorId: iId, format: 'json' };
                         legendStore.reload();
+                        
+                        classify(false);
                     }
                 }
             }
@@ -338,7 +340,15 @@
             emptyText: 'Select period',
             selectOnFocus: true,
             width: combo_width,
-            store: periodStore
+            store: periodStore,
+            listeners: {
+                'select': {
+                    fn: function()
+                    {
+                        classify(false);
+                    }
+                }
+            }
         },
         
         {
@@ -363,12 +373,6 @@
                                      
                             this.newUrl = mlp;
                             this.classify(false);
-/*                    
-                        var level = this.form.findField('level_cb').getValue();
-                        this.selectedLevel = level;
-                        this.newUrl = shapefiles[level];
-                        this.classify(false);
-*/                        
                     },
                     scope: this
                 }

=== modified file 'webservice/dhis-webservice-expoze/src/main/java/org/hisp/dhis/webservice/adapter/mapping/DefaultMappingServiceAdapter.java'
--- webservice/dhis-webservice-expoze/src/main/java/org/hisp/dhis/webservice/adapter/mapping/DefaultMappingServiceAdapter.java	2009-04-14 12:17:30 +0000
+++ webservice/dhis-webservice-expoze/src/main/java/org/hisp/dhis/webservice/adapter/mapping/DefaultMappingServiceAdapter.java	2009-04-15 15:26:19 +0000
@@ -83,6 +83,13 @@
             mappingService.addMap( map );
         }
     }
+    
+    public void deleteMapByMapLayerPath( String mapLayerPath )
+    {
+        Map map = mappingService.getMapByMapLayerPath( mapLayerPath );
+        
+        mappingService.deleteMap( map );
+    }
 
     // -------------------------------------------------------------------------
     // MapOrganisationUnitRelation

=== modified file 'webservice/dhis-webservice-expoze/src/main/java/org/hisp/dhis/webservice/adapter/mapping/MappingServiceAdapter.java'
--- webservice/dhis-webservice-expoze/src/main/java/org/hisp/dhis/webservice/adapter/mapping/MappingServiceAdapter.java	2009-04-14 12:17:30 +0000
+++ webservice/dhis-webservice-expoze/src/main/java/org/hisp/dhis/webservice/adapter/mapping/MappingServiceAdapter.java	2009-04-15 15:26:19 +0000
@@ -15,6 +15,8 @@
 
     void addOrUpdateMap( String mapLayerPath, int organisationUnitId, int organisationUnitLevelId, String uniqueColumn,
         String nameColumn, String longitude, String latitude, int zoom );
+    
+    void deleteMapByMapLayerPath( String mapLayerPath );
 
     // -------------------------------------------------------------------------
     // MapOrganisationUnitRelation

=== modified file 'webservice/dhis-webservice-expoze/src/main/resources/dispatcher.xml'
--- webservice/dhis-webservice-expoze/src/main/resources/dispatcher.xml	2009-04-14 12:17:30 +0000
+++ webservice/dhis-webservice-expoze/src/main/resources/dispatcher.xml	2009-04-15 15:26:19 +0000
@@ -1090,6 +1090,19 @@
     </request>
 	  
 	<request>
+      <name>deleteMapByMapLayerPath</name>
+	  <type>void</type>
+      <bean>org.hisp.dhis.webservice.adapter.mapping.MappingServiceAdapter</bean>
+      <method>deleteMapByMapLayerPath</method>
+      <parameters>
+		<parameter>
+          <type>java.lang.String</type>
+          <name>mapLayerPath</name>
+        </parameter>
+      </parameters>
+    </request>
+	  
+	<request>
       <name>addOrUpdateMapOrganisationUnitRelation</name>
 	  <type>void</type>
       <bean>org.hisp.dhis.webservice.adapter.mapping.MappingServiceAdapter</bean>



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