← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2089: (GIS) Legend sets can now be assigned to data elements as well as indicators.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 2089 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: trunk
timestamp: Thu 2010-09-09 21:33:01 +0200
message:
  (GIS) Legend sets can now be assigned to data elements as well as indicators.
removed:
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapLegendSetIndicators.vm
added:
  dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AssignDataElementsToMapLegendSetAction.java
  dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetMapLegendSetByDataElementAction.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendSet.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java
  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/resources/org/hisp/dhis/mapping/hibernate/MapLegendSet.hbm.xml
  dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-mapping/src/main/resources/org/hisp/dhis/mapping/i18n_module.properties
  dhis-2/dhis-web/dhis-web-mapping/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/i18n.vm
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapLegendSet.vm
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.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/MapLegendSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendSet.java	2010-08-30 13:58:52 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendSet.java	2010-09-09 19:19:51 +0000
@@ -30,6 +30,7 @@
 import java.util.HashSet;
 import java.util.Set;
 
+import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.indicator.Indicator;
 
 /**
@@ -55,13 +56,15 @@
     private Set<MapLegend> mapLegends = new HashSet<MapLegend>();
 
     private Set<Indicator> indicators = new HashSet<Indicator>();
+    
+    private Set<DataElement> dataElements = new HashSet<DataElement>();
 
     public MapLegendSet()
     {
     }
 
     public MapLegendSet( String name, String type, int method, int classes, String colorLow, String colorHigh,
-        Set<MapLegend> mapLegends, Set<Indicator> indicators )
+        Set<MapLegend> mapLegends, Set<Indicator> indicators, Set<DataElement> dataElements )
     {
         this.name = name;
         this.type = type;
@@ -71,6 +74,7 @@
         this.colorHigh = colorHigh;
         this.mapLegends = mapLegends;
         this.indicators = indicators;
+        this.dataElements = dataElements;
     }
 
     // -------------------------------------------------------------------------
@@ -199,4 +203,14 @@
     {
         this.indicators = indicators;
     }
+
+    public Set<DataElement> getDataElements()
+    {
+        return dataElements;
+    }
+
+    public void setDataElements( Set<DataElement> dataElements )
+    {
+        this.dataElements = dataElements;
+    }
 }
\ No newline at end of file

=== 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	2010-09-01 09:02:32 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java	2010-09-09 19:19:51 +0000
@@ -380,6 +380,8 @@
     Collection<MapLegendSet> getMapLegendSetsByType( String type );
 
     MapLegendSet getMapLegendSetByIndicator( int indicatorId );
+    
+    MapLegendSet getMapLegendSetByDataElement( int dataElementId );
 
     Collection<MapLegendSet> getAllMapLegendSets();
 

=== 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	2010-09-01 09:02:32 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java	2010-09-09 19:19:51 +0000
@@ -660,6 +660,8 @@
         MapLegendSet mapLegendSet = getMapLegendSetByName( name );
 
         Set<Indicator> indicators = new HashSet<Indicator>();
+        
+        Set<DataElement> dataElements = new HashSet<DataElement>();
 
         if ( mapLegendSet != null )
         {
@@ -670,12 +672,13 @@
             mapLegendSet.setColorHigh( colorHigh );
             mapLegendSet.setMapLegends( mapLegends );
             mapLegendSet.setIndicators( indicators );
+            mapLegendSet.setDataElements( dataElements );
 
             this.mappingStore.updateMapLegendSet( mapLegendSet );
         }
         else
         {
-            mapLegendSet = new MapLegendSet( name, type, method, classes, colorLow, colorHigh, mapLegends, indicators );
+            mapLegendSet = new MapLegendSet( name, type, method, classes, colorLow, colorHigh, mapLegends, indicators, dataElements );
 
             this.mappingStore.addMapLegendSet( mapLegendSet );
         }
@@ -718,6 +721,23 @@
         return null;
     }
 
+    public MapLegendSet getMapLegendSetByDataElement( int dataElementId )
+    {
+        DataElement dataElement = dataElementService.getDataElement( dataElementId );
+
+        Collection<MapLegendSet> mapLegendSets = mappingStore.getAllMapLegendSets();
+
+        for ( MapLegendSet mapLegendSet : mapLegendSets )
+        {
+            if ( mapLegendSet.getDataElements().contains( dataElement ) )
+            {
+                return mapLegendSet;
+            }
+        }
+
+        return null;
+    }
+
     public Collection<MapLegendSet> getAllMapLegendSets()
     {
         return mappingStore.getAllMapLegendSets();

=== 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	2010-04-07 10:19:08 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLegendSet.hbm.xml	2010-09-09 19:19:51 +0000
@@ -34,6 +34,12 @@
             <many-to-many column="indicatorid" 
 				class="org.hisp.dhis.indicator.Indicator" foreign-key="fk_maplegendset_indicator"/>
         </set>
+		
+		<set name="dataElements" table="maplegendsetdataelement">
+            <key column="legendsetid"/>
+            <many-to-many column="dataelementid" 
+                class="org.hisp.dhis.dataelement.DataElement" foreign-key="fk_maplegendset_dataelement"/>
+        </set>
       
     </class>
     

=== added file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AssignDataElementsToMapLegendSetAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AssignDataElementsToMapLegendSetAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AssignDataElementsToMapLegendSetAction.java	2010-09-09 19:19:51 +0000
@@ -0,0 +1,76 @@
+package org.hisp.dhis.mapping.action;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.indicator.Indicator;
+import org.hisp.dhis.indicator.IndicatorService;
+import org.hisp.dhis.mapping.MapLegendSet;
+import org.hisp.dhis.mapping.MappingService;
+
+import com.opensymphony.xwork2.Action;
+
+public class AssignDataElementsToMapLegendSetAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private MappingService mappingService;
+
+    public void setMappingService( MappingService mappingService )
+    {
+        this.mappingService = mappingService;
+    }
+    
+    private DataElementService dataElementService;
+    
+    public void setDataElementService( DataElementService dataElementService )
+    {
+        this.dataElementService = dataElementService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+    
+    private Integer id;
+    
+    public void setId( Integer id )
+    {
+        this.id = id;
+    }
+
+    private Collection<String> dataElements;
+    
+    public void setDataElements( Collection<String> dataElements )
+    {
+        this.dataElements = dataElements;
+    }
+    
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+    {
+        MapLegendSet mapLegendSet = mappingService.getMapLegendSet( id );
+        
+        Set<DataElement> dataElementSet = new HashSet<DataElement>();
+
+        for ( String dataElement : dataElements )
+        {
+            dataElementSet.add( dataElementService.getDataElement( Integer.parseInt( dataElement ) ) );
+        }
+        
+        mapLegendSet.setDataElements( dataElementSet );
+        
+        mappingService.updateMapLegendSet( mapLegendSet );
+        
+        return SUCCESS;
+    }
+}

=== added file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetMapLegendSetByDataElementAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetMapLegendSetByDataElementAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetMapLegendSetByDataElementAction.java	2010-09-09 19:19:51 +0000
@@ -0,0 +1,86 @@
+package org.hisp.dhis.mapping.action;
+
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.mapping.MapLegendSet;
+import org.hisp.dhis.mapping.MappingService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Lars Helge Overland
+ * @version $Id$
+ */
+public class GetMapLegendSetByDataElementAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private MappingService mappingService;
+
+    public void setMappingService( MappingService mappingService )
+    {
+        this.mappingService = mappingService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private int dataElementId;
+
+    public void setDataElementId( int dataElementId )
+    {
+        this.dataElementId = dataElementId;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private MapLegendSet object;
+
+    public MapLegendSet getObject()
+    {
+        return object;
+    }
+    
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        object = mappingService.getMapLegendSetByDataElement( dataElementId );
+        
+        return SUCCESS;
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml	2010-08-31 10:40:24 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml	2010-09-09 19:19:51 +0000
@@ -210,6 +210,12 @@
 		scope="prototype">
 		<property name="mappingService" ref="org.hisp.dhis.mapping.MappingService" />
 	</bean>
+	
+	<bean id="org.hisp.dhis.mapping.action.GetMapLegendSetByDataElementAction"
+        class="org.hisp.dhis.mapping.action.GetMapLegendSetByDataElementAction"
+        scope="prototype">
+        <property name="mappingService" ref="org.hisp.dhis.mapping.MappingService" />
+    </bean>
 
 	<bean id="org.hisp.dhis.mapping.action.GetMapLegendSetsByTypeAction"
 		class="org.hisp.dhis.mapping.action.GetMapLegendSetsByTypeAction"
@@ -225,6 +231,14 @@
 		<property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
 	</bean>
 
+    <bean
+        id="org.hisp.dhis.mapping.action.AssignDataElementsToMapLegendSetAction"
+        class="org.hisp.dhis.mapping.action.AssignDataElementsToMapLegendSetAction"
+        scope="prototype">
+        <property name="mappingService" ref="org.hisp.dhis.mapping.MappingService" />
+        <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
+    </bean>
+
 	<!-- MapView -->
 
 	<bean id="org.hisp.dhis.mapping.action.AddOrUpdateMapViewAction"

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/resources/org/hisp/dhis/mapping/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/resources/org/hisp/dhis/mapping/i18n_module.properties	2010-09-06 10:17:56 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/resources/org/hisp/dhis/mapping/i18n_module.properties	2010-09-09 19:19:51 +0000
@@ -153,6 +153,7 @@
 already_exists						= already exists.
 a_legend_set_called					= A legend set called
 assign_to_indicator					= Assign to indicators
+assign_to_dataelement				= Assign to data elements
 please_select_a_legend_set			= Please select a legend set
 link_legend_set_to_indicator		= Link legend set to indicator
 please_select_at_least_one_indicator	= Please select at least one indicator.
@@ -175,7 +176,6 @@
 must_be_between_-90_and_90			= must be between -90 and 90.
 there_is_already_a_map_called		= There is already a map called
 the_source_file						= The source file
-assign_to_indicators				= Assign to indicators
 selected_relations_removed			= Selected relations removed.
 the_source_file						= The source file
 delete_baselayer					= Delete base layer

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/resources/struts.xml	2010-09-02 12:28:43 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/resources/struts.xml	2010-09-09 19:19:51 +0000
@@ -229,24 +229,30 @@
 				/dhis-web-mapping/jsonMapLegendSet.vm</result>
 		</action>
 
+        <action name="getMapLegendSetByDataElement"
+            class="org.hisp.dhis.mapping.action.GetMapLegendSetByDataElementAction">
+            <result name="success" type="velocity-json">
+                /dhis-web-mapping/jsonMapLegendSet.vm</result>
+        </action>
+
 		<action name="getMapLegendSetsByType"
 			class="org.hisp.dhis.mapping.action.GetMapLegendSetsByTypeAction">
 			<result name="success" type="velocity-json">
 				/dhis-web-mapping/jsonminMapLegendSets.vm</result>
 		</action>
 
-		<action name="getMapLegendSetIndicators"
-			class="org.hisp.dhis.mapping.action.GetMapLegendSetAction">
-			<result name="success" type="velocity-json">
-				/dhis-web-mapping/jsonMapLegendSetIndicators.vm</result>
-		</action>
-
 		<action name="assignIndicatorsToMapLegendSet"
 			class="org.hisp.dhis.mapping.action.AssignIndicatorsToMapLegendSetAction">
 			<result name="success" type="velocity-json">/dhis-web-mapping/void.vm
 			</result>
 		</action>
 
+        <action name="assignDataElementsToMapLegendSet"
+            class="org.hisp.dhis.mapping.action.AssignDataElementsToMapLegendSetAction">
+            <result name="success" type="velocity-json">/dhis-web-mapping/void.vm
+            </result>
+        </action>
+
 		<!-- MapView -->
 
 		<action name="addOrUpdateMapView"

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/i18n.vm'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/i18n.vm	2010-09-06 10:17:56 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/i18n.vm	2010-09-09 19:19:51 +0000
@@ -152,6 +152,7 @@
 var i18n_already_exists = '$encoder.jsEscape($i18n.getString( 'already_exists' ) , "'")';
 var i18n_a_legend_set_called = '$encoder.jsEscape($i18n.getString( 'a_legend_set_called' ) , "'")';
 var i18n_assign_to_indicator = '$encoder.jsEscape($i18n.getString( 'assign_to_indicator' ) , "'")';
+var i18n_assign_to_dataelement = '$encoder.jsEscape($i18n.getString( 'assign_to_dataelement' ) , "'")';
 var i18n_please_select_a_legend_set = '$encoder.jsEscape($i18n.getString( 'please_select_a_legend_set' ) , "'")';
 var i18n_link_legend_set_to_indicator = '$encoder.jsEscape($i18n.getString( 'link_legend_set_to_indicator' ) , "'")';
 var i18n_please_select_at_least_one_indicator = '$encoder.jsEscape($i18n.getString( 'please_select_at_least_one_indicator' ) , "'")';	
@@ -173,7 +174,6 @@
 var i18n_must_be_between_180_and_180 = '$encoder.jsEscape($i18n.getString( 'must_be_between_-180_and_180' ) , "'")';
 var i18n_must_be_between_90_and_90 = '$encoder.jsEscape($i18n.getString( 'must_be_between_-90_and_90' ) , "'")';
 var i18n_there_is_already_a_map_called = '$encoder.jsEscape($i18n.getString( 'there_is_already_a_map_called' ) , "'")';
-var i18n_assign_to_indicators = '$encoder.jsEscape($i18n.getString( 'assign_to_indicators' ) , "'")';
 var i18n_selected_relations_removed = '$encoder.jsEscape($i18n.getString( 'selected_relations_removed' ) , "'")';
 var i18n_the_source_file = '$encoder.jsEscape($i18n.getString( 'the_source_file' ) , "'")';
 var i18n_delete_baselayer = '$encoder.jsEscape($i18n.getString( 'delete_baselayer' ) , "'")';

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapLegendSet.vm'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapLegendSet.vm	2009-05-22 17:15:35 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapLegendSet.vm	2010-09-09 19:19:51 +0000
@@ -1,10 +1,10 @@
+#set( $indicators_size = $object.indicators.size() )
+#set( $dataelements_size = $object.dataElements.size() )
 { "mapLegendSet":
   [{
     "id": "$!{object.id}",
     "name": "$!encoder.jsEncode( ${object.name} )",
-    "method": "$!{object.method}",
-    "classes": "$!{object.classes}",
-    "colorLow": "$!encoder.jsEncode( ${object.colorLow} )",
-    "colorHigh": "$!encoder.jsEncode( ${object.colorHigh} )"
+    "indicators": [#foreach( $indicator in $object.indicators )$!{indicator.id}#if( $velocityCount < $indicators_size ),#end#end],
+    "dataElements": [#foreach( $dataElement in $object.dataElements )$!{dataElement.id}#if( $velocityCount < $dataelements_size ),#end#end]
   }]
 }
\ No newline at end of file

=== removed file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapLegendSetIndicators.vm'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapLegendSetIndicators.vm	2009-09-08 20:33:48 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapLegendSetIndicators.vm	1970-01-01 00:00:00 +0000
@@ -1,7 +0,0 @@
-#set( $size = $object.indicators.size() )
-{ "mapLegendSet":
-  [{
-    "id": $!{object.id},
-    "indicators": [#foreach( $indicator in $object.indicators )$!{indicator.id}#if( $velocityCount < $size ),#end#end]
-  }]
-}
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2010-09-06 10:32:33 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2010-09-09 19:19:51 +0000
@@ -766,8 +766,8 @@
 	/* Section: predefined legend set */
 	var predefinedMapLegendStore = new Ext.data.JsonStore({url:path_mapping+'getAllMapLegends'+type,root:'mapLegends',id:'id',fields:['id','name','startValue','endValue','color','displayString'],autoLoad:true});
 	var predefinedMapLegendSetStore = new Ext.data.JsonStore({url:path_mapping+'getMapLegendSetsByType'+type,baseParams:{type:map_legend_type_predefined},root:'mapLegendSets',id:'id',fields:['id','name'],sortInfo:{field:'name',direction:'ASC'},autoLoad:true});
-	var predefinedMapLegendSetIndicatorStore = new Ext.data.JsonStore({url:path_mapping+'getAllIndicators'+type,root:'indicators',fields:['id','name','shortName'],sortInfo:{field:'name',direction:'ASC'},autoLoad:true});
-    var predefinedMapLegendSetDataElementStore = new Ext.data.JsonStore({url:path_mapping+'getAllDataElements'+type,root:'dataElements',fields:['id','name','shortName'],sortInfo:{field:'name',direction:'ASC'},autoLoad:true});
+	var predefinedMapLegendSetIndicatorStore = new Ext.data.JsonStore({url:path_mapping+'getAllIndicators'+type,root:'indicators',fields:['id','name','shortName'],sortInfo:{field:'shortName',direction:'ASC'},autoLoad:true});
+    var predefinedMapLegendSetDataElementStore = new Ext.data.JsonStore({url:path_mapping+'getAllDataElements'+type,root:'dataElements',fields:['id','name','shortName'],sortInfo:{field:'shortName',direction:'ASC'},autoLoad:true});
 
 	var newPredefinedMapLegendPanel = new Ext.form.FormPanel({
         id: 'newpredefinedmaplegend_p',
@@ -1003,8 +1003,8 @@
         ]
     });
     
-    var assignPredefinedMapLegendSetPanel = new Ext.form.FormPanel({
-        id: 'assignpredefinedmaplegendset_p',
+    var assignPredefinedMapLegendSetIndicatorPanel = new Ext.form.FormPanel({
+        id: 'assignpredefinedmaplegendsetindicator_p',
 		bodyStyle: 'border:0px',
         items:
         [
@@ -1031,7 +1031,7 @@
                             var lsid = Ext.getCmp('predefinedmaplegendsetindicator2_cb').getValue();
                             
                             Ext.Ajax.request({
-                                url: path_mapping + 'getMapLegendSetIndicators' + type,
+                                url: path_mapping + 'getMapLegendSet' + type,
                                 method: 'POST',
                                 params: { id:lsid },
                                 success: function(r) {
@@ -1060,7 +1060,7 @@
             {
                 xtype: 'button',
                 id: 'assignpredefinedmaplegendsetindicator_b',
-                text: i18n_assign_to_indicators,
+                text: i18n_assign_to_indicator,
 				cls: 'window-button',
                 handler: function() {
                     var ls = Ext.getCmp('predefinedmaplegendsetindicator2_cb').getValue();
@@ -1104,13 +1104,115 @@
             }
         ]
     });
+    
+    var assignPredefinedMapLegendSetDataElementPanel = new Ext.form.FormPanel({
+        id: 'assignpredefinedmaplegendsetdataelement_p',
+		bodyStyle: 'border:0px',
+        items:
+        [
+            { html: '<div class="window-field-label-first">'+i18n_legend_set+'</div>' },
+            new Ext.form.ComboBox({
+                id: 'predefinedmaplegendsetdataelement_cb',
+                isFormField: true,
+                hideLabel: true,
+                typeAhead: true,
+                editable: false,
+                valueField: 'id',
+                displayField: 'name',
+                mode: 'remote',
+                forceSelection: true,
+                triggerAction: 'all',
+                emptyText: emptytext,
+                selectOnFocus: true,
+                width: combo_width,
+                minListWidth: combo_width,
+                store: predefinedMapLegendSetStore,
+                listeners:{
+                    'select': {
+                        fn: function() {
+                            var lsid = Ext.getCmp('predefinedmaplegendsetdataelement_cb').getValue();
+                            
+                            Ext.Ajax.request({
+                                url: path_mapping + 'getMapLegendSet' + type,
+                                method: 'POST',
+                                params: {id: lsid},
+                                success: function(r) {
+                                    var dataElements = Ext.util.JSON.decode(r.responseText).mapLegendSet[0].dataElements;
+                                    var dataElementString = '';
+                                    
+                                    for (var i = 0; i < dataElements.length; i++) {
+                                        dataElementString += dataElements[i];
+                                        if (i < dataElements.length-1) {
+                                            dataElementString += ',';
+                                        }
+                                    }
+                                    
+                                    Ext.getCmp('predefinedmaplegendsetdataelement_ms').setValue(dataElementString);							
+                                },
+                                failure: function() {
+                                    alert( i18n_status , i18n_error_while_saving_data );
+                                }
+                            });
+                        }
+                    }
+                }					
+            }),
+            { html: '<div class="window-field-label">'+i18n_dataelement+'</div>' },
+			new Ext.ux.Multiselect({id:'predefinedmaplegendsetdataelement_ms',isFormField:true,hideLabel:true,dataFields:['id','name','shortName'],valueField:'id',displayField:'shortName',width:multiselect_width,height:getMultiSelectHeight(),store:predefinedMapLegendSetDataElementStore}),
+            {
+                xtype: 'button',
+                id: 'assignpredefinedmaplegendsetdataelement_b',
+                text: i18n_assign_to_dataelement,
+				cls: 'window-button',
+                handler: function() {
+                    var ls = Ext.getCmp('predefinedmaplegendsetdataelement_cb').getValue();
+                    var lsrw = Ext.getCmp('predefinedmaplegendsetdataelement_cb').getRawValue();
+                    var lims = Ext.getCmp('predefinedmaplegendsetdataelement_ms').getValue();
+                    
+                    if (!ls) {
+                        Ext.message.msg(false, i18n_please_select_a_legend_set);
+                        return;
+                    }
+                    
+                    if (!lims) {
+                        Ext.message.msg(false, i18n_please_select_at_least_one_indicator);
+                        return;
+                    }
+                    
+                    var array = new Array();
+                    array = lims.split(',');
+                    var params = '?dataElements=' + array[0];
+                    
+                    if (array.length > 1) {
+                        for (var i = 1; i < array.length; i++) {
+                            array[i] = '&dataElements=' + array[i];
+                            params += array[i];
+                        }
+                    }
+                    
+                    Ext.Ajax.request({
+                        url: path_mapping + 'assignDataElementsToMapLegendSet.action' + params,
+                        method: 'POST',
+                        params: {id: ls},
+                        success: function(r) {
+                            Ext.message.msg(true, i18n_legend_set+' <span class="x-msg-hl">' + lsrw + '</span> ' + i18n_was_updated);
+                            Ext.getCmp('predefinedmaplegendsetdataelement_cb').getStore().load();
+                        },
+                        failure: function() {
+                            alert( 'Error: assignDataElementsToMapLegendSet' );
+                        }
+                    });
+                }
+            }
+        ]
+    });
 	
 	var predefinedMapLegendSetWindow = new Ext.Window({
         id: 'predefinedmaplegendset_w',
         title: '<span id="window-predefinedlegendset-title">'+i18n_predefined_legend_sets+'</span>',
 		layout: 'fit',
         closeAction: 'hide',
-		width: 441,
+		width: 592,
         items:
         [
 			{
@@ -1140,6 +1242,9 @@
                         else if (tab.id == 'predefinedmaplegendset4') {
                             w.setHeight(getMultiSelectHeight() + 180);
                         }
+                        else if (tab.id == 'predefinedmaplegendset5') {
+                            w.setHeight(getMultiSelectHeight() + 180);
+                        }
 					}
 				},
 				items:
@@ -1176,7 +1281,14 @@
                         title: '<span class="panel-tab-title">'+i18n_assign_to_indicator+'</span>',
 						id: 'predefinedmaplegendset4',
 						items: [
-							assignPredefinedMapLegendSetPanel
+							assignPredefinedMapLegendSetIndicatorPanel
+						]
+					},
+					{
+                        title: '<span class="panel-tab-title">'+i18n_assign_to_dataelement+'</span>',
+						id: 'predefinedmaplegendset5',
+						items: [
+							assignPredefinedMapLegendSetDataElementPanel
 						]
 					}
 				]

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js	2010-09-06 10:17:56 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js	2010-09-09 19:19:51 +0000
@@ -854,7 +854,35 @@
                         if (Ext.getCmp('mapview_cb').getValue()) {
                             Ext.getCmp('mapview_cb').clearValue();
                         }
-						choropleth.classify(false, true);
+                        
+                        var deId = Ext.getCmp('dataelement_cb').getValue();
+                        
+                        Ext.Ajax.request({
+                            url: path_mapping + 'getMapLegendSetByDataElement' + type,
+                            method: 'POST',
+                            params: {dataElementId: deId},
+                            success: function(r) {
+                                var mapLegendSet = Ext.util.JSON.decode(r.responseText).mapLegendSet[0];
+                                if (mapLegendSet.id) {
+                                    LEGEND[thematicMap].type = map_legend_type_predefined;
+                                    Ext.getCmp('maplegendtype_cb').setValue(map_legend_type_predefined);
+                                    Ext.getCmp('maplegendset_cb').showField();
+                                    Ext.getCmp('maplegendset_cb').setValue(mapLegendSet.id);
+                                    Ext.getCmp('method_cb').hideField();
+                                    Ext.getCmp('numClasses_cb').hideField();
+                                    Ext.getCmp('colorA_cf').hideField();
+                                    Ext.getCmp('colorB_cf').hideField();
+
+                                    choropleth.applyPredefinedLegend();
+                                }
+
+                                choropleth.classify(false, true);
+                            },
+                            failure: function()
+                            {
+                              alert( i18n_status , i18n_error_while_retrieving_data );
+                            } 
+                        });
                     }
                 }
             }

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js	2010-09-04 06:08:10 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js	2010-09-09 19:19:51 +0000
@@ -851,7 +851,35 @@
                         if (Ext.getCmp('mapview_cb2').getValue()) {
                             Ext.getCmp('mapview_cb2').clearValue();
                         }
-						proportionalSymbol.classify(false, true);
+                        
+                        var deId = Ext.getCmp('dataelement_cb2').getValue();
+                        
+                        Ext.Ajax.request({
+                            url: path_mapping + 'getMapLegendSetByDataElement' + type,
+                            method: 'POST',
+                            params: {dataElementId: deId},
+                            success: function(r) {
+                                var mapLegendSet = Ext.util.JSON.decode(r.responseText).mapLegendSet[0];
+                                if (mapLegendSet.id) {
+                                    LEGEND[thematicMap2].type = map_legend_type_predefined;
+                                    Ext.getCmp('maplegendtype_cb2').setValue(map_legend_type_predefined);
+                                    Ext.getCmp('maplegendset_cb2').showField();
+                                    Ext.getCmp('maplegendset_cb2').setValue(mapLegendSet.id);
+                                    Ext.getCmp('method_cb2').hideField();
+                                    Ext.getCmp('numClasses_cb2').hideField();
+                                    Ext.getCmp('colorA_cf2').hideField();
+                                    Ext.getCmp('colorB_cf2').hideField();
+
+                                    proportionalSymbol.applyPredefinedLegend();
+                                }
+
+                                proportionalSymbol.classify(false, true);
+                            },
+                            failure: function()
+                            {
+                              alert( i18n_status , i18n_error_while_retrieving_data );
+                            } 
+                        });
                     }
                 }
             }