← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8701: Removed MapLegendSet.type, .dataElements and .indicators assocations

 

------------------------------------------------------------
revno: 8701
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-10-25 10:23:30 +0200
message:
  Removed MapLegendSet.type, .dataElements and .indicators assocations
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/MapLegendSetStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/MapLegendSetDeletionHandler.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapLegendSetStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLegendSet.hbm.xml
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java
  dhis-2/dhis-services/dhis-service-mapgeneration/src/test/java/org/hisp/dhis/mapgenerator/GeoToolsMapLayerTest.java
  dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java
  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/AssignIndicatorsToMapLegendSetAction.java
  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/GetMapLegendSetByIndicatorAction.java
  dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetMapLegendSetsByTypeAction.java


--
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	2012-10-24 09:11:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendSet.java	2012-10-25 08:23:30 +0000
@@ -27,12 +27,9 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonView;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import java.util.HashSet;
+import java.util.Set;
+
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.Dxf2Namespace;
 import org.hisp.dhis.common.IdentifiableObject;
@@ -42,8 +39,11 @@
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.indicator.Indicator;
 
-import java.util.HashSet;
-import java.util.Set;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 
 /**
  * @author Jan Henrik Overland
@@ -52,21 +52,11 @@
 public class MapLegendSet
     extends BaseIdentifiableObject
 {
-    //TODO remove type, move indicator/data element to respective objects
-    
-    private String type;
-
     private String symbolizer;
 
     @Scanned
     private Set<MapLegend> mapLegends = new HashSet<MapLegend>();
 
-    @Scanned
-    private Set<Indicator> indicators = new HashSet<Indicator>();
-
-    @Scanned
-    private Set<DataElement> dataElements = new HashSet<DataElement>();
-
     public MapLegendSet()
     {
     }
@@ -75,11 +65,8 @@
                          Set<Indicator> indicators, Set<DataElement> dataElements )
     {
         this.name = name;
-        this.type = type;
         this.symbolizer = symbolizer;
         this.mapLegends = mapLegends;
-        this.indicators = indicators;
-        this.dataElements = dataElements;
     }
 
     // -------------------------------------------------------------------------
@@ -119,16 +106,6 @@
     // Logic
     // -------------------------------------------------------------------------
 
-    public void removeAllDataElements()
-    {
-        dataElements.clear();
-    }
-
-    public void removeAllIndicators()
-    {
-        indicators.clear();
-    }
-
     public void removeAllMapLegends()
     {
         mapLegends.clear();
@@ -141,19 +118,6 @@
     @JsonProperty
     @JsonView( {DetailedView.class, ExportView.class} )
     @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
-    public String getType()
-    {
-        return type;
-    }
-
-    public void setType( String type )
-    {
-        this.type = type;
-    }
-
-    @JsonProperty
-    @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
     public String getSymbolizer()
     {
         return symbolizer;
@@ -178,36 +142,6 @@
         this.mapLegends = mapLegends;
     }
 
-    @JsonProperty
-    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
-    @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlElementWrapper( localName = "indicators", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "indicator", namespace = Dxf2Namespace.NAMESPACE )
-    public Set<Indicator> getIndicators()
-    {
-        return indicators;
-    }
-
-    public void setIndicators( Set<Indicator> indicators )
-    {
-        this.indicators = indicators;
-    }
-
-    @JsonProperty
-    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
-    @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlElementWrapper( localName = "dataElements", namespace = Dxf2Namespace.NAMESPACE )
-    @JacksonXmlProperty( localName = "dataElement", namespace = Dxf2Namespace.NAMESPACE )
-    public Set<DataElement> getDataElements()
-    {
-        return dataElements;
-    }
-
-    public void setDataElements( Set<DataElement> dataElements )
-    {
-        this.dataElements = dataElements;
-    }
-
     @Override
     public void mergeWith( IdentifiableObject other )
     {
@@ -217,17 +151,10 @@
         {
             MapLegendSet mapLegendSet = (MapLegendSet) other;
 
-            type = mapLegendSet.getType() == null ? type : mapLegendSet.getType();
             symbolizer = mapLegendSet.getSymbolizer() == null ? symbolizer : mapLegendSet.getSymbolizer();
 
             removeAllMapLegends();
             mapLegends.addAll( mapLegendSet.getMapLegends() );
-
-            removeAllIndicators();
-            indicators.addAll( mapLegendSet.getIndicators() );
-
-            removeAllDataElements();
-            dataElements.addAll( mapLegendSet.getDataElements() );
         }
     }
 }
\ No newline at end of file

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendSetStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendSetStore.java	2012-03-22 12:34:46 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendSetStore.java	2012-10-25 08:23:30 +0000
@@ -29,8 +29,6 @@
 
 import org.hisp.dhis.common.GenericIdentifiableObjectStore;
 
-import java.util.Collection;
-
 /**
  * @author Jan Henrik Overland
  */
@@ -38,6 +36,4 @@
     extends GenericIdentifiableObjectStore<MapLegendSet>
 {
     String ID = MapLegendSetStore.class.getName();
-
-    Collection<MapLegendSet> getMapLegendSetsByType( String type );
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java	2012-04-21 11:45:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java	2012-10-25 08:23:30 +0000
@@ -81,8 +81,6 @@
 
     private OrganisationUnitLevel organisationUnitLevel;
 
-    private String mapLegendType;
-
     private Integer method;
 
     private Integer classes;
@@ -112,7 +110,7 @@
     public MapView( String name, User user, String mapValueType, IndicatorGroup indicatorGroup, Indicator indicator,
                     DataElementGroup dataElementGroup, DataElement dataElement, PeriodType periodType,
                     Period period, OrganisationUnit parentOrganisationUnit, OrganisationUnitLevel organisationUnitLevel,
-                    String mapLegendType, Integer method, Integer classes, String bounds, String colorLow, String colorHigh,
+                    Integer method, Integer classes, String bounds, String colorLow, String colorHigh,
                     MapLegendSet mapLegendSet, Integer radiusLow, Integer radiusHigh, String longitude, String latitude, int zoom )
     {
         this.name = name;
@@ -126,7 +124,6 @@
         this.period = period;
         this.parentOrganisationUnit = parentOrganisationUnit;
         this.organisationUnitLevel = organisationUnitLevel;
-        this.mapLegendType = mapLegendType;
         this.method = method;
         this.classes = classes;
         this.bounds = bounds;
@@ -328,19 +325,6 @@
     @JsonProperty
     @JsonView( {DetailedView.class, ExportView.class} )
     @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
-    public String getMapLegendType()
-    {
-        return mapLegendType;
-    }
-
-    public void setMapLegendType( String mapLegendType )
-    {
-        this.mapLegendType = mapLegendType;
-    }
-
-    @JsonProperty
-    @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
     public Integer getMethod()
     {
         return method;
@@ -501,7 +485,6 @@
             period = mapView.getPeriod() == null ? period : mapView.getPeriod();
             parentOrganisationUnit = mapView.getParentOrganisationUnit() == null ? parentOrganisationUnit : mapView.getParentOrganisationUnit();
             organisationUnitLevel = mapView.getOrganisationUnitLevel() == null ? organisationUnitLevel : mapView.getOrganisationUnitLevel();
-            mapLegendType = mapView.getMapLegendType() == null ? mapLegendType : mapView.getMapLegendType();
             method = mapView.getMethod() == null ? method : mapView.getMethod();
             classes = mapView.getClasses() == null ? classes : mapView.getClasses();
             bounds = mapView.getBounds() == null ? bounds : mapView.getBounds();

=== 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	2012-10-24 09:11:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java	2012-10-25 08:23:30 +0000
@@ -50,9 +50,6 @@
     final String MAP_LEGEND_SYMBOLIZER_COLOR = "color";
     final String MAP_LEGEND_SYMBOLIZER_IMAGE = "image";
 
-    final String MAPLEGENDSET_TYPE_AUTOMATIC = "automatic";
-    final String MAPLEGENDSET_TYPE_PREDEFINED = "predefined";
-
     final String KEY_MAP_DATE_TYPE = "dateType";
 
     final String MAP_DATE_TYPE_FIXED = "fixed";
@@ -120,16 +117,8 @@
 
     MapLegendSet getMapLegendSetByName( String name );
 
-    Collection<MapLegendSet> getMapLegendSetsByType( String type );
-
-    MapLegendSet getMapLegendSetByIndicator( int indicatorId );
-
-    MapLegendSet getMapLegendSetByDataElement( int dataElementId );
-
     Collection<MapLegendSet> getAllMapLegendSets();
 
-    boolean indicatorHasMapLegendSet( int indicatorId );
-
     // -------------------------------------------------------------------------
     // MapView
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java	2012-10-24 16:19:29 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java	2012-10-25 08:23:30 +0000
@@ -354,11 +354,8 @@
 
         if ( mapLegendSet != null )
         {
-            mapLegendSet.setType( type );
             mapLegendSet.setSymbolizer( symbolizer );
             mapLegendSet.setMapLegends( mapLegends );
-            mapLegendSet.setIndicators( indicators );
-            mapLegendSet.setDataElements( dataElements );
 
             mapLegendSetStore.update( mapLegendSet );
         }
@@ -391,67 +388,11 @@
         return mapLegendSetStore.getByName( name );
     }
 
-    public Collection<MapLegendSet> getMapLegendSetsByType( String type )
-    {
-        return mapLegendSetStore.getMapLegendSetsByType( type );
-    }
-
-    public MapLegendSet getMapLegendSetByIndicator( int indicatorId )
-    {
-        Indicator indicator = indicatorService.getIndicator( indicatorId );
-
-        Collection<MapLegendSet> mapLegendSets = mapLegendSetStore.getAll();
-
-        for ( MapLegendSet mapLegendSet : mapLegendSets )
-        {
-            if ( mapLegendSet.getIndicators().contains( indicator ) )
-            {
-                return mapLegendSet;
-            }
-        }
-
-        return null;
-    }
-
-    public MapLegendSet getMapLegendSetByDataElement( int dataElementId )
-    {
-        DataElement dataElement = dataElementService.getDataElement( dataElementId );
-
-        Collection<MapLegendSet> mapLegendSets = mapLegendSetStore.getAll();
-
-        for ( MapLegendSet mapLegendSet : mapLegendSets )
-        {
-            if ( mapLegendSet.getDataElements().contains( dataElement ) )
-            {
-                return mapLegendSet;
-            }
-        }
-
-        return null;
-    }
-
     public Collection<MapLegendSet> getAllMapLegendSets()
     {
         return mapLegendSetStore.getAll();
     }
 
-    public boolean indicatorHasMapLegendSet( int indicatorId )
-    {
-        Indicator indicator = indicatorService.getIndicator( indicatorId );
-
-        Collection<MapLegendSet> mapLegendSets = mapLegendSetStore.getAll();
-
-        for ( MapLegendSet mapLegendSet : mapLegendSets )
-        {
-            if ( mapLegendSet.getIndicators().contains( indicator ) )
-            {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
     // -------------------------------------------------------------------------
     // MapView
     // -------------------------------------------------------------------------
@@ -500,7 +441,7 @@
         MapLegendSet mapLegendSet = mapLegendSetId != null ? getMapLegendSet( mapLegendSetId ) : null;
 
         addMapView( new MapView( name, user, mapValueType, indicatorGroup, indicator, dataElementGroup, dataElement,
-            periodType, period, parent, level, mapLegendType, method, classes, bounds, colorLow, colorHigh,
+            periodType, period, parent, level, method, classes, bounds, colorLow, colorHigh,
             mapLegendSet, radiusLow, radiusHigh, longitude, latitude, zoom ) );
     }
 

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/MapLegendSetDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/MapLegendSetDeletionHandler.java	2012-10-24 16:19:29 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/MapLegendSetDeletionHandler.java	2012-10-25 08:23:30 +0000
@@ -27,8 +27,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.system.deletion.DeletionHandler;
 
 /**
@@ -70,28 +68,4 @@
             }
         }
     }
-    
-    @Override
-    public void deleteIndicator( Indicator indicator )
-    {
-        for ( MapLegendSet legendSet : mappingService.getAllMapLegendSets() )
-        {
-            if ( legendSet.getIndicators().remove( indicator ) )
-            {
-                mappingService.updateMapLegendSet( legendSet );
-            }
-        }
-    }
-    
-    @Override
-    public void deleteDataElement( DataElement dataElement )
-    {
-        for ( MapLegendSet legendSet : mappingService.getAllMapLegendSets() )
-        {
-            if ( legendSet.getDataElements().remove( dataElement ) )
-            {
-                mappingService.updateMapLegendSet( legendSet );
-            }
-        }
-    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapLegendSetStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapLegendSetStore.java	2012-10-24 16:19:29 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapLegendSetStore.java	2012-10-25 08:23:30 +0000
@@ -27,15 +27,10 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import org.hibernate.Criteria;
-import org.hibernate.Session;
-import org.hibernate.criterion.Restrictions;
 import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
 import org.hisp.dhis.mapping.MapLegendSet;
 import org.hisp.dhis.mapping.MapLegendSetStore;
 
-import java.util.Collection;
-
 /**
  * @author Jan Henrik Overland
  */
@@ -43,15 +38,4 @@
     extends HibernateIdentifiableObjectStore<MapLegendSet>
     implements MapLegendSetStore
 {
-    @SuppressWarnings( "unchecked" )
-    public Collection<MapLegendSet> getMapLegendSetsByType( String type )
-    {
-        Session session = this.sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( MapLegendSet.class );
-
-        criteria.add( Restrictions.eq( "type", type ) );
-
-        return criteria.list();
-    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2012-10-24 13:47:13 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2012-10-25 08:23:30 +0000
@@ -104,6 +104,8 @@
         executeSql( "DROP TABLE datasetlock" );
         executeSql( "DROP TABLE datasetlockexceptions" );
         executeSql( "DROP TABLE indicator_indicatorgroupsetmembers" );
+        executeSql( "DROP TABLE maplegendsetindicator" );
+        executeSql( "DROP TABLE maplegendsetdataelement" );
         executeSql( "ALTER TABLE dataelementcategoryoption drop column categoryid" );
         executeSql( "ALTER TABLE reporttable DROP column dimension_type" );
         executeSql( "ALTER TABLE reporttable DROP column dimensiontype" );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLegendSet.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLegendSet.hbm.xml	2012-10-24 16:19:29 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLegendSet.hbm.xml	2012-10-25 08:23:30 +0000
@@ -13,8 +13,6 @@
     </id>
     &identifiableProperties;
 
-    <property name="type" column="type" />
-
     <property name="symbolizer" column="symbolizer" />
 
     <set name="mapLegends" table="maplegendsetmaplegend">
@@ -22,15 +20,5 @@
       <many-to-many column="maplegendid" class="org.hisp.dhis.mapping.MapLegend" foreign-key="fk_maplegendset_maplegend" />
     </set>
 
-    <set name="indicators" table="maplegendsetindicator">
-      <key column="legendsetid" foreign-key="fk_maplegendsetindicator_legendsetid" />
-      <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" foreign-key="fk_maplegendsetdataelement_legendsetid" />
-      <many-to-many column="dataelementid" class="org.hisp.dhis.dataelement.DataElement" foreign-key="fk_maplegendset_dataelement" />
-    </set>
-
   </class>
 </hibernate-mapping>

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml	2012-10-24 16:19:29 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml	2012-10-25 08:23:30 +0000
@@ -40,8 +40,6 @@
     <many-to-one name="organisationUnitLevel" class="org.hisp.dhis.organisationunit.OrganisationUnitLevel"
       column="organisationunitlevelid" foreign-key="fk_mapview_organisationunitlevelid" />
 
-    <property name="mapLegendType" />
-
     <property name="method" />
 
     <property name="classes" />

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java	2012-10-24 16:19:29 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java	2012-10-25 08:23:30 +0000
@@ -127,7 +127,7 @@
         period = createPeriod( periodType, getDate( 2000, 1, 1 ), getDate( 2000, 2, 1 ) );
         periodService.addPeriod( period );
 
-        mapLegendSet = createMapLegendSet( 'A', indicator );
+        mapLegendSet = createMapLegendSet( 'A' );
         mappingService.addMapLegendSet( mapLegendSet );
     }
 
@@ -210,7 +210,7 @@
     @Test
     public void testAddGetMapLegendSet()
     {
-        MapLegendSet legendSet = createMapLegendSet( 'B', indicator );
+        MapLegendSet legendSet = createMapLegendSet( 'B' );
 
         int id = mappingService.addMapLegendSet( legendSet );
 
@@ -220,7 +220,7 @@
     @Test
     public void testGetUpdateMapLegendSetByName()
     {
-        MapLegendSet legendSet = createMapLegendSet( 'C', indicator );
+        MapLegendSet legendSet = createMapLegendSet( 'C' );
 
         int id = mappingService.addMapLegendSet( legendSet );
 
@@ -236,66 +236,11 @@
     }
 
     @Test
-    public void testGetMapLegendSetsByType()
-    {
-        MapLegendSet legendSet1 = createMapLegendSet( 'B', indicator );
-        MapLegendSet legendSet2 = createMapLegendSet( 'C', indicator );
-        MapLegendSet legendSet3 = createMapLegendSet( 'D', indicator );
-
-        legendSet1.setType( MappingService.MAPLEGENDSET_TYPE_AUTOMATIC );
-        legendSet2.setType( MappingService.MAPLEGENDSET_TYPE_PREDEFINED );
-        legendSet3.setType( MappingService.MAPLEGENDSET_TYPE_PREDEFINED );
-
-        int idA = mappingService.addMapLegendSet( legendSet1 );
-        int idB = mappingService.addMapLegendSet( legendSet2 );
-        int idC = mappingService.addMapLegendSet( legendSet3 );
-
-        List<MapLegendSet> autoTypes = new ArrayList<MapLegendSet>(
-            mappingService.getMapLegendSetsByType( MappingService.MAPLEGENDSET_TYPE_AUTOMATIC ) );
-
-        List<MapLegendSet> predefinedTypes = new ArrayList<MapLegendSet>(
-            mappingService.getMapLegendSetsByType( MappingService.MAPLEGENDSET_TYPE_PREDEFINED ) );
-
-        assertTrue( autoTypes.contains( mappingService.getMapLegendSet( idA ) ) );
-        assertTrue( !autoTypes.contains( mappingService.getMapLegendSet( idB ) ) );
-        assertTrue( !autoTypes.contains( mappingService.getMapLegendSet( idC ) ) );
-        assertTrue( predefinedTypes.contains( mappingService.getMapLegendSet( idB ) ) );
-        assertTrue( predefinedTypes.contains( mappingService.getMapLegendSet( idC ) ) );
-        assertTrue( !predefinedTypes.contains( mappingService.getMapLegendSet( idA ) ) );
-
-    }
-
-    @Test
-    public void testGetMapLegendSetByIndicatorOrDataElement()
-    {
-        MapLegendSet legendSet1 = createMapLegendSet( 'B', indicator );
-        MapLegendSet legendSet2 = createMapLegendSet( 'C', indicator );
-
-        int idB = mappingService.addMapLegendSet( legendSet1 );
-        int idC = mappingService.addMapLegendSet( legendSet2 );
-
-        assertEquals( "1", mapLegendSet, mappingService.getMapLegendSetByIndicator( indicator.getId() ) );
-
-        legendSet1 = mappingService.getMapLegendSet( idB );
-        legendSet2 = mappingService.getMapLegendSet( idC );
-
-        legendSet1.getDataElements().add( dataElement );
-        legendSet2.getDataElements().add( dataElement );
-
-        mappingService.updateMapLegendSet( legendSet1 );
-        mappingService.updateMapLegendSet( legendSet2 );
-
-        assertEquals( "2", mappingService.getMapLegendSet( idB ),
-            mappingService.getMapLegendSetByDataElement( dataElement.getId() ) );
-
-    }
-
-    @Test
     public void testGetAllMapLegendSets()
     {
-        MapLegendSet legendSet1 = createMapLegendSet( 'B', indicator );
-        MapLegendSet legendSet2 = createMapLegendSet( 'C', indicator );
-        MapLegendSet legendSet3 = createMapLegendSet( 'D', indicator );
+        MapLegendSet legendSet1 = createMapLegendSet( 'B' );
+        MapLegendSet legendSet2 = createMapLegendSet( 'C' );
+        MapLegendSet legendSet3 = createMapLegendSet( 'D' );
 
         Collection<MapLegendSet> mapLegendSets = new HashSet<MapLegendSet>();
 
@@ -312,20 +257,6 @@
 
     }
 
-    @Test
-    public void testIndicatorHasMapLegendSet()
-    {
-        MapLegendSet legendSet1 = createMapLegendSet( 'B', indicator );
-        MapLegendSet legendSet2 = createMapLegendSet( 'C', indicator );
-        MapLegendSet legendSet3 = createMapLegendSet( 'D', indicator );
-
-        mappingService.addMapLegendSet( legendSet1 );
-        mappingService.addMapLegendSet( legendSet2 );
-        mappingService.addMapLegendSet( legendSet3 );
-
-        assertTrue( mappingService.indicatorHasMapLegendSet( indicator.getId() ) );
-    }
-
     // -------------------------------------------------------------------------
     // MapView tests
     // -------------------------------------------------------------------------
@@ -335,7 +266,7 @@
     {
         MapView mapView = new MapView( "MapViewA", null, MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup,
             indicator, dataElementGroup, dataElement, periodType, period,
-            organisationUnit, organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B",
+            organisationUnit, organisationUnitLevel, 1, 1, "", "A", "B",
             mapLegendSet, 5, 20, "1", "1", 1 );
 
         int idA = mappingService.addMapView( mapView );
@@ -352,7 +283,7 @@
     {
         MapView mapView = new MapView( "MapViewA", null, MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup,
             indicator, dataElementGroup, dataElement, periodType, period,
-            organisationUnit, organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B",
+            organisationUnit, organisationUnitLevel, 1, 1, "", "A", "B",
             mapLegendSet, 5, 20, "1", "1", 1 );
 
         int id = mappingService.addMapView( mapView );
@@ -369,12 +300,12 @@
     {
         MapView mapView1 = new MapView( "MapViewA", null, MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup,
             indicator, dataElementGroup, dataElement, periodType, period,
-            organisationUnit, organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B",
+            organisationUnit, organisationUnitLevel, 1, 1, "", "A", "B",
             mapLegendSet, 5, 20, "1", "1", 1 );
 
         MapView mapView2 = new MapView( "MapViewB", null, MappingService.MAP_VALUE_TYPE_DATAELEMENT, indicatorGroup,
             indicator, dataElementGroup, dataElement, periodType, period,
-            organisationUnit, organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B",
+            organisationUnit, organisationUnitLevel, 1, 1, "", "A", "B",
             mapLegendSet, 5, 20, "2", "2", 1 );
 
         mappingService.addMapView( mapView1 );
@@ -390,17 +321,17 @@
     {
         MapView mapView1 = new MapView( "MapViewA", null, MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup,
             indicator, dataElementGroup, dataElement, periodType, period,
-            organisationUnit, organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B",
+            organisationUnit, organisationUnitLevel, 1, 1, "", "A", "B",
             mapLegendSet, 5, 20, "1", "1", 1 );
 
         MapView mapView2 = new MapView( "MapViewB", null, MappingService.MAP_VALUE_TYPE_DATAELEMENT, indicatorGroup,
             indicator, dataElementGroup, dataElement, periodType, period,
-            organisationUnit, organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B",
+            organisationUnit, organisationUnitLevel, 1, 1, "", "A", "B",
             mapLegendSet, 5, 20, "2", "2", 1 );
 
         MapView mapView3 = new MapView( "MapViewC", null, MappingService.MAP_VALUE_TYPE_DATAELEMENT, indicatorGroup,
             indicator, dataElementGroup, dataElement, periodType, period,
-            organisationUnit, organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B",
+            organisationUnit, organisationUnitLevel, 1, 1, "", "A", "B",
             mapLegendSet, 5, 20, "3", "3", 1 );
 
         mappingService.addMapView( mapView1 );

=== modified file 'dhis-2/dhis-services/dhis-service-mapgeneration/src/test/java/org/hisp/dhis/mapgenerator/GeoToolsMapLayerTest.java'
--- dhis-2/dhis-services/dhis-service-mapgeneration/src/test/java/org/hisp/dhis/mapgenerator/GeoToolsMapLayerTest.java	2011-12-09 10:29:57 +0000
+++ dhis-2/dhis-services/dhis-service-mapgeneration/src/test/java/org/hisp/dhis/mapgenerator/GeoToolsMapLayerTest.java	2012-10-25 08:23:30 +0000
@@ -94,7 +94,7 @@
         period = createPeriod( periodType, getDate( 2000, 1, 1 ), getDate( 2000, 2, 1 ) );
         periodService.addPeriod( period );
 
-        mapLegendSet = createMapLegendSet( 'A', indicator );
+        mapLegendSet = createMapLegendSet( 'A' );
         mappingService.addMapLegendSet( mapLegendSet );
 
         internalMapLayer = new InternalMapLayer();

=== modified file 'dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java'
--- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java	2012-10-18 13:04:28 +0000
+++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java	2012-10-25 08:23:30 +0000
@@ -819,17 +819,12 @@
         return legend;
     }
 
-    public static MapLegendSet createMapLegendSet( char uniqueCharacter, Indicator... indicators )
+    public static MapLegendSet createMapLegendSet( char uniqueCharacter )
     {
         MapLegendSet legendSet = new MapLegendSet();
 
         legendSet.setName( "MapLegendSet" + uniqueCharacter );
 
-        for ( Indicator indicator : indicators )
-        {
-            legendSet.getIndicators().add( indicator );
-        }
-
         return legendSet;
     }
 

=== modified 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	2011-04-03 10:19:50 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AssignDataElementsToMapLegendSetAction.java	2012-10-25 08:23:30 +0000
@@ -1,8 +1,6 @@
 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;
@@ -58,17 +56,13 @@
     {
         MapLegendSet mapLegendSet = mappingService.getMapLegendSet( id );
         
-        Set<DataElement> dataElementSet = new HashSet<DataElement>();
-
         for ( String dataElement : dataElements )
         {
-            dataElementSet.add( dataElementService.getDataElement( Integer.parseInt( dataElement ) ) );
+            DataElement element = dataElementService.getDataElement( Integer.parseInt( dataElement ) );
+            element.setLegendSet( mapLegendSet );
+            dataElementService.updateDataElement( element );
         }
         
-        mapLegendSet.setDataElements( dataElementSet );
-        
-        mappingService.updateMapLegendSet( mapLegendSet );
-        
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AssignIndicatorsToMapLegendSetAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AssignIndicatorsToMapLegendSetAction.java	2009-09-08 20:33:48 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AssignIndicatorsToMapLegendSetAction.java	2012-10-25 08:23:30 +0000
@@ -1,8 +1,6 @@
 package org.hisp.dhis.mapping.action;
 
 import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
 
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.indicator.IndicatorService;
@@ -58,15 +56,13 @@
     {
         MapLegendSet mapLegendSet = mappingService.getMapLegendSet( id );
         
-        Set<Indicator> indicatorSet = new HashSet<Indicator>();
-
         for ( String indicator : indicators )
         {
-            indicatorSet.add( indicatorService.getIndicator( Integer.parseInt( indicator ) ) );
+            Indicator i = indicatorService.getIndicator( Integer.parseInt( indicator ) );
+            i.setLegendSet( mapLegendSet );
+            indicatorService.updateIndicator( i );
         }
         
-        mapLegendSet.setIndicators( indicatorSet );
-        
         mappingService.updateMapLegendSet( mapLegendSet );
         
         return SUCCESS;

=== modified 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	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetMapLegendSetByDataElementAction.java	2012-10-25 08:23:30 +0000
@@ -27,6 +27,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.apache.commons.lang.NotImplementedException;
 import org.hisp.dhis.mapping.MapLegendSet;
 import org.hisp.dhis.mapping.MappingService;
 
@@ -79,8 +80,6 @@
     public String execute()
         throws Exception
     {
-        object = mappingService.getMapLegendSetByDataElement( dataElementId );
-        
-        return SUCCESS;
+        throw new NotImplementedException();
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetMapLegendSetByIndicatorAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetMapLegendSetByIndicatorAction.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetMapLegendSetByIndicatorAction.java	2012-10-25 08:23:30 +0000
@@ -27,6 +27,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.apache.commons.lang.NotImplementedException;
 import org.hisp.dhis.mapping.MapLegendSet;
 import org.hisp.dhis.mapping.MappingService;
 
@@ -79,8 +80,6 @@
     public String execute()
         throws Exception
     {
-        object = mappingService.getMapLegendSetByIndicator( indicatorId );
-        
-        return SUCCESS;
+        throw new NotImplementedException();
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetMapLegendSetsByTypeAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetMapLegendSetsByTypeAction.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetMapLegendSetsByTypeAction.java	2012-10-25 08:23:30 +0000
@@ -31,6 +31,7 @@
 import java.util.Collection;
 import java.util.List;
 
+import org.apache.commons.lang.NotImplementedException;
 import org.hisp.dhis.mapping.MapLegendSet;
 import org.hisp.dhis.mapping.MappingService;
 
@@ -89,6 +90,8 @@
 
     public String execute()
     {
+        throw new NotImplementedException();
+        /*
         object = new ArrayList<MapLegendSet>( mappingService.getMapLegendSetsByType( type ) );
 
         if ( symbolizer != null )
@@ -121,5 +124,6 @@
         }
 
         return SUCCESS;
+        */
     }
 }
\ No newline at end of file