=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java	2009-08-26 18:57:37 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java	2009-09-01 09:29:11 +0000
@@ -190,6 +190,8 @@
      * @return a generated unique id of the added MapOrganisationUnitRelation.
      */
     int addMapOrganisationUnitRelation( String mapLayerPath, int organisationUnitId, String featureId );
+    
+    void addOrUpdateMapOrganisationUnitRelations( String mapLayerPath, String relations );
 
     /**
      * Adds a MapOrganisationUnitRelation. If it already exists, it will be
@@ -228,15 +230,15 @@
     MapOrganisationUnitRelation getMapOrganisationUnitRelation( int id );
 
     /**
-     * Returns a MapOrganisationUnitRelation.
+     * Returns a Collection <MapOrganisationUnitRelation>.
      * 
      * @param map, the foreign Map in the MapOrganisationUnitRelation.
      * @param map, the foreign OrganisationUnit in the
      *        MapOrganisationUnitRelation.
-     * @return the MapOrganisationUnitRelation which contains the given Map and
+     * @return a Collection<MapOrganisationUnitRelation> which contains the given Map and
      *         OrganisationUnit.
      */
-    MapOrganisationUnitRelation getMapOrganisationUnitRelation( Map map, OrganisationUnit organisationUnit );
+    Collection<MapOrganisationUnitRelation> getMapOrganisationUnitRelation( Map map, OrganisationUnit organisationUnit );
 
     /**
      * Returns a Collection of MapOrganisationUnitRelations.

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingStore.java	2009-08-20 18:52:55 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingStore.java	2009-09-01 09:29:11 +0000
@@ -144,15 +144,15 @@
     MapOrganisationUnitRelation getMapOrganisationUnitRelation( int id );
 
     /**
-     * Returns a MapOrganisationUnitRelation.
+     * Returns a Collection<MapOrganisationUnitRelation>.
      * 
      * @param map, the foreign Map in the MapOrganisationUnitRelation.
      * @param map, the foreign OrganisationUnit in the
      *        MapOrganisationUnitRelation.
-     * @return the MapOrganisationUnitRelation which contains the given Map and
+     * @return a Collection<MapOrganisationUnitRelation> which contains the given Map and
      *         OrganisationUnit.
      */
-    MapOrganisationUnitRelation getMapOrganisationUnitRelation( Map map, OrganisationUnit organisationUnit );
+    Collection<MapOrganisationUnitRelation> getMapOrganisationUnitRelation( Map map, OrganisationUnit organisationUnit );
     
     /**
      * Returns a Collection of MapOrganisationUnitRelations.

=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java	2009-08-26 18:57:37 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java	2009-09-01 09:29:11 +0000
@@ -53,6 +53,10 @@
 public class DefaultMappingService
     implements MappingService
 {
+    private static final String PAIR_SEPARATOR = "-";
+
+    private static final String RELATION_SEPARATOR = ",";
+
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -239,16 +243,30 @@
         return addMapOrganisationUnitRelation( mapOrganisationUnitRelation );
     }
 
+    public void addOrUpdateMapOrganisationUnitRelations( String mapLayerPath, String relations )
+    {
+        String[] rels = relations.split( RELATION_SEPARATOR );
+
+        for ( int i = 0; i < rels.length; i++ )
+        {
+            String[] rel = rels[i].split( PAIR_SEPARATOR );
+
+            addOrUpdateMapOrganisationUnitRelation( mapLayerPath, Integer.parseInt( rel[0] ), rel[1] );
+        }
+    }
+
     public void addOrUpdateMapOrganisationUnitRelation( String mapLayerPath, int organisationUnitId, String featureId )
     {
         Map map = getMapByMapLayerPath( mapLayerPath );
 
         OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
 
-        MapOrganisationUnitRelation mapOrganisationUnitRelation = getMapOrganisationUnitRelation( map, organisationUnit );
-
-        if ( mapOrganisationUnitRelation != null )
+        MapOrganisationUnitRelation mapOrganisationUnitRelation;
+        
+        if ( getMapOrganisationUnitRelation( map, organisationUnit ).iterator().hasNext() )
         {
+            mapOrganisationUnitRelation = getMapOrganisationUnitRelation( map, organisationUnit ).iterator().next();
+            
             mapOrganisationUnitRelation.setFeatureId( featureId );
 
             updateMapOrganisationUnitRelation( mapOrganisationUnitRelation );
@@ -276,7 +294,7 @@
         return mappingStore.getMapOrganisationUnitRelation( id );
     }
 
-    public MapOrganisationUnitRelation getMapOrganisationUnitRelation( Map map, OrganisationUnit organisationUnit )
+    public Collection<MapOrganisationUnitRelation> getMapOrganisationUnitRelation( Map map, OrganisationUnit organisationUnit )
     {
         return mappingStore.getMapOrganisationUnitRelation( map, organisationUnit );
     }
@@ -300,11 +318,18 @@
 
         for ( OrganisationUnit unit : organisationUnits )
         {
-            MapOrganisationUnitRelation relation = getMapOrganisationUnitRelation( map, unit );
-
-            relations.add( relation != null ? relation : new MapOrganisationUnitRelation( map, unit, null ) );
+            Collection<MapOrganisationUnitRelation> relation = getMapOrganisationUnitRelation( map, unit );
+            
+            if ( relation.size() == 0 )
+            {
+                relations.add( new MapOrganisationUnitRelation( map, unit, null ) );
+            }
+            else
+            {
+                relations.addAll( relation );
+            }
         }
-
+        
         return relations;
     }
 
@@ -557,7 +582,8 @@
         mappingStore.updateMapLayer( mapLayer );
     }
 
-    public void addOrUpdateMapLayer( String name, String type, String mapSource, String fillColor, double fillOpacity, String strokeColor, int strokeWidth )
+    public void addOrUpdateMapLayer( String name, String type, String mapSource, String fillColor, double fillOpacity,
+        String strokeColor, int strokeWidth )
     {
         MapLayer mapLayer = mappingStore.getMapLayerByName( name );
 
@@ -570,7 +596,7 @@
             mapLayer.setFillOpacity( fillOpacity );
             mapLayer.setStrokeColor( strokeColor );
             mapLayer.setStrokeWidth( strokeWidth );
-            
+
             updateMapLayer( mapLayer );
         }
         else

=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java	2009-08-29 11:39:42 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java	2009-09-01 09:29:11 +0000
@@ -170,7 +170,8 @@
         return (MapOrganisationUnitRelation) session.get( MapOrganisationUnitRelation.class, id );
     }
 
-    public MapOrganisationUnitRelation getMapOrganisationUnitRelation( Map map, OrganisationUnit organisationUnit )
+    @SuppressWarnings("unchecked")
+    public Collection<MapOrganisationUnitRelation> getMapOrganisationUnitRelation( Map map, OrganisationUnit organisationUnit )
     {
         Session session = sessionFactory.getCurrentSession();
 
@@ -179,7 +180,7 @@
         criteria.add( Restrictions.eq( "map", map ) );
         criteria.add( Restrictions.eq( "organisationUnit", organisationUnit ) );
 
-        return (MapOrganisationUnitRelation) criteria.uniqueResult();
+        return (Collection<MapOrganisationUnitRelation>) criteria.list();
     }
 
     @SuppressWarnings( "unchecked" )

=== modified file 'gis/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/DeleteMapOrganisationUnitRelationAction.java'
--- gis/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/DeleteMapOrganisationUnitRelationAction.java	2009-08-21 08:34:37 +0000
+++ gis/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/DeleteMapOrganisationUnitRelationAction.java	2009-09-01 09:29:11 +0000
@@ -88,10 +88,12 @@
         
         Map map = mappingService.getMapByMapLayerPath( mapLayerPath );
         
-        MapOrganisationUnitRelation relation = mappingService.getMapOrganisationUnitRelation( map, unit );
+        MapOrganisationUnitRelation relation;
         
-        if ( relation != null )
+        if ( mappingService.getMapOrganisationUnitRelation( map, unit ).iterator().hasNext() )
         {
+            relation = mappingService.getMapOrganisationUnitRelation( map, unit ).iterator().next();
+            
             mappingService.deleteMapOrganisationUnitRelation( relation );
         }
             

=== modified file 'gis/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml'
--- gis/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml	2009-08-20 18:52:55 +0000
+++ gis/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml	2009-09-01 09:29:11 +0000
@@ -86,12 +86,26 @@
     
   <!-- MapOrganisationUnitRelation -->
     
+  <bean id="org.hisp.dhis.mapping.action.AddMapOrganisationUnitRelationAction"
+    class="org.hisp.dhis.mapping.action.AddMapOrganisationUnitRelationAction"
+    scope="prototype">
+    <property name="mappingService"
+      ref="org.hisp.dhis.mapping.MappingService"/>
+  </bean>
+	
   <bean id="org.hisp.dhis.mapping.action.AddOrUpdateMapOrganisationUnitRelationAction"
     class="org.hisp.dhis.mapping.action.AddOrUpdateMapOrganisationUnitRelationAction"
     scope="prototype">
     <property name="mappingService"
       ref="org.hisp.dhis.mapping.MappingService"/>
   </bean>
+	
+  <bean id="org.hisp.dhis.mapping.action.AddOrUpdateMapOrganisationUnitRelationsAction"
+    class="org.hisp.dhis.mapping.action.AddOrUpdateMapOrganisationUnitRelationsAction"
+    scope="prototype">
+    <property name="mappingService"
+      ref="org.hisp.dhis.mapping.MappingService"/>
+  </bean>	
   
   <bean id="org.hisp.dhis.mapping.action.GetAvailableMapOrganisationUnitRelationsAction"
     class="org.hisp.dhis.mapping.action.GetAvailableMapOrganisationUnitRelationsAction"

=== modified file 'gis/dhis-web-mapping/src/main/resources/struts.xml'
--- gis/dhis-web-mapping/src/main/resources/struts.xml	2009-08-21 08:34:37 +0000
+++ gis/dhis-web-mapping/src/main/resources/struts.xml	2009-09-01 09:29:11 +0000
@@ -61,7 +61,15 @@
     
     <!-- MapOrganisationUnitRelations -->
     
-    <action name="addOrUpdateMapOrganisationUnitRelation" class="org.hisp.dhis.mapping.action.AddOrUpdateMapOrganisationUnitRelationAction">
+    <action name="addMapOrganisationUnitRelation" class="org.hisp.dhis.mapping.action.AddMapOrganisationUnitRelationAction">
+      <result name="success" type="velocity-json">/dhis-web-mapping/void.vm</result>
+    </action>
+	  
+	<action name="addOrUpdateMapOrganisationUnitRelation" class="org.hisp.dhis.mapping.action.AddOrUpdateMapOrganisationUnitRelationAction">
+      <result name="success" type="velocity-json">/dhis-web-mapping/void.vm</result>
+    </action>
+	  
+	<action name="addOrUpdateMapOrganisationUnitRelations" class="org.hisp.dhis.mapping.action.AddOrUpdateMapOrganisationUnitRelationsAction">
       <result name="success" type="velocity-json">/dhis-web-mapping/void.vm</result>
     </action>
     

=== modified file 'gis/dhis-web-mapping/src/main/webapp/mapping/geostat/geostat.js'
--- gis/dhis-web-mapping/src/main/webapp/mapping/geostat/geostat.js	2009-08-29 11:39:42 +0000
+++ gis/dhis-web-mapping/src/main/webapp/mapping/geostat/geostat.js	2009-09-01 09:29:11 +0000
@@ -1,5 +1,6 @@
 /*reference local blank image*/
 Ext.BLANK_IMAGE_URL = '../../mfbase/ext/resources/images/default/s.gif';
+Ext.BLANK_IMAGE_URL = '../../mfbase/ext/resources/images/default/s.gif';
 
 Ext.onReady(function()
 {
@@ -1716,31 +1717,6 @@
         items:
         [   
             {
-                xtype: 'checkbox',
-                id: 'register_chb',
-                fieldLabel: 'Admin panels',
-                isFormField: true,
-                listeners: {
-                    'check': {
-                        fn: function(checkbox,checked) {
-                            if (checked) {
-                                mapping.show();
-                                shapefilePanel.show();
-                                mapLayerPanel.show();
-                                Ext.getCmp('west').doLayout();
-                            }
-                            else {
-                                mapping.hide();
-                                shapefilePanel.hide();
-                                mapLayerPanel.hide();
-                                Ext.getCmp('west').doLayout();
-                            }
-                        },
-                        scope: this
-                    }
-                }
-            },
-            {
                 xtype: 'combo',
                 fieldLabel: 'Map source',
                 id: 'mapsource_cb',
@@ -1808,6 +1784,31 @@
                         }
                     }
                 }
+            },
+            {
+                xtype: 'checkbox',
+                id: 'register_chb',
+                fieldLabel: 'Admin panels',
+                isFormField: true,
+                listeners: {
+                    'check': {
+                        fn: function(checkbox,checked) {
+                            if (checked) {
+                                mapping.show();
+                                shapefilePanel.show();
+                                mapLayerPanel.show();
+                                Ext.getCmp('west').doLayout();
+                            }
+                            else {
+                                mapping.hide();
+                                shapefilePanel.hide();
+                                mapLayerPanel.hide();
+                                Ext.getCmp('west').doLayout();
+                            }
+                        },
+                        scope: this
+                    }
+                }
             }
         ],
         listeners: {
@@ -1833,8 +1834,8 @@
         map: map,
         layer: choroplethLayer,
         title: '<font style="font-family:tahoma; font-weight:normal; font-size:11px; color:' + MENU_TITLECOLOR + ';">Thematic map</font>',
-        nameAttribute: 'NAME',
-        indicators: [['value', 'Indicator']],
+        //nameAttribute: 'NAME',
+        //indicators: [['value', 'Indicator']],
         url: INIT_URL,
         featureSelection: false,
         loadMask: {msg: 'Loading shapefile...', msgCls: 'x-mask-loading'},
@@ -1857,8 +1858,8 @@
         map: map,
         layer: choroplethLayer,
         title: '<font style="font-family:tahoma; font-weight:normal; font-size:11px; color:' + MENU_TITLECOLOR_ADMIN + ';">Assign organisation units</font>',
-        nameAttribute: 'NAME',
-        indicators: [['value', 'Indicator']],
+        //nameAttribute: 'NAME',
+        //indicators: [['value', 'Indicator']],
         url: INIT_URL,
         featureSelection: false,
         loadMask: {msg: 'Loading shapefile...', msgCls: 'x-mask-loading'},
@@ -1868,6 +1869,7 @@
             expand: {
                 fn: function() {
                     choroplethLayer.setVisibility(false);
+                    mapping.classify(false);
                     
                     ACTIVEPANEL = 'mapping';
                 }
@@ -1901,14 +1903,7 @@
             children: layerTreeConfig
         }
     });
-    
-    //layerTree.on({
-    //    'checkchange': function(node,checked) {
-    //        if (checked) {
-    //            MASK.show();
-    //        }   
-    //    }
-    //});
+
     
     map.events.on({
         changelayer: function(e) {
@@ -2184,7 +2179,7 @@
             dataReceivedChoropleth( responseObject.responseText );
         },
         failure: function() {
-            alert( 'Status', 'Error while retrieving data' );
+            alert( 'Error: getMapValues' );
         } 
     });
 }
@@ -2442,6 +2437,7 @@
     var count_features = 0;
     var count_orgunits = 0;
     var count_match = 0;
+    var relations = '';
 
     for ( var j=0; j < features.length; j++ ) {
         count_features++;
@@ -2450,30 +2446,32 @@
             count_orgunits++;
             
             if (features[j].attributes[uniqueColumn] == organisationUnits[i].name) {
+            
+                count_match++;
                 var organisationUnitId = organisationUnits[i].id;
                 var organisationUnit = organisationUnits[i].name;
                 var featureId = features[j].attributes[uniqueColumn];
                 var featureName = features[j].attributes[nameColumn];
-                count_match++;
-                
-                Ext.Ajax.request({
-                    url: path + 'addOrUpdateMapOrganisationUnitRelation' + type,
-                    method: 'GET',
-                    params: { mapLayerPath: mlp, organisationUnitId: organisationUnitId, featureId: featureId },
-
-                    success: function( responseObject ) {
-
-                    },
-                    failure: function() {
-                        alert( 'Status', 'Error while retrieving data: dataReceivedAutoAssignOrganisationUnit' );
-                    } 
-                });
+
+                relations += organisationUnitId + '-' + featureId + ',';
             }
         }
     }
     
-    Ext.messageBlack.msg('Assign organisation units', + msg_highlight_start + count_match + msg_highlight_end + ' organisation units assigned.<br><br>Database: ' + msg_highlight_start + count_orgunits/count_features + msg_highlight_end + '<br>Shapefile: ' + msg_highlight_start + count_features + msg_highlight_end);
-    
-    Ext.getCmp('grid_gp').getStore().reload();
-    loadMapData('assignment');
+    Ext.Ajax.request({
+        url: path + 'addOrUpdateMapOrganisationUnitRelations' + type,
+        method: 'POST',
+        params: { mapLayerPath: mlp, relations: relations },
+
+        success: function( responseObject ) {
+            Ext.messageBlack.msg('Assign organisation units', '' + msg_highlight_start + count_match + msg_highlight_end + ' organisation units assigned.<br><br>Database: ' + msg_highlight_start + count_orgunits/count_features + msg_highlight_end + '<br>Shapefile: ' + msg_highlight_start + count_features + msg_highlight_end);
+            
+            Ext.getCmp('grid_gp').getStore().reload();
+            loadMapData('assignment');
+        },
+        failure: function() {
+            alert( 'Error: addOrUpdateMapOrganisationUnitRelations' );
+        } 
+    });
+                
 }
\ No newline at end of file

=== modified file 'gis/dhis-web-mapping/src/main/webapp/mfbase/mapfish/widgets/geostat/Mapping.js'
--- gis/dhis-web-mapping/src/main/webapp/mfbase/mapfish/widgets/geostat/Mapping.js	2009-08-08 17:45:41 +0000
+++ gis/dhis-web-mapping/src/main/webapp/mfbase/mapfish/widgets/geostat/Mapping.js	2009-09-01 09:29:11 +0000
@@ -144,6 +144,8 @@
      
     newUrl : false,
     
+    organisationUnits: [],
+    
     /**
      * Method: initComponent
      *    Inits the component
@@ -169,18 +171,20 @@
         gridView = new Ext.grid.GridView({ 
             forceFit: true,
             sortClasses: ['sort-asc'],
-            getRowClass: function (row, index){
+            getRowClass: function(row,index) {
                 var cls = ''; 
-                var data = row.data;
-
-                switch (data.featureId) { 
+                switch (row.data.featureId) {
                     case '': 
                         cls = 'not-assigned-row';
                         break;
                     default:
                         cls = 'assigned-row';
                 }
-                return cls;
+                
+                return cls;                    
+            },
+            getCell: function(row,col) {
+                return '<div></div>';
             }
         });
     

