← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8698: Merged project dhis-service-mapping into dhis-service-core. dhis-service-mapping should be remove...

 

------------------------------------------------------------
revno: 8698
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-10-24 18:19:29 +0200
message:
  Merged project dhis-service-mapping into dhis-service-core. dhis-service-mapping should be removed from your IDEs.
removed:
  dhis-2/dhis-services/dhis-service-mapping/
  dhis-2/dhis-services/dhis-service-mapping/pom.xml
  dhis-2/dhis-services/dhis-service-mapping/src/
  dhis-2/dhis-services/dhis-service-mapping/src/main/
  dhis-2/dhis-services/dhis-service-mapping/src/main/java/
  dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/
  dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/
  dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/
  dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/
  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/MapLegendSetDeletionHandler.java
  dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/MapViewDeletionHandler.java
  dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/
  dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapLayerStore.java
  dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapLegendSetStore.java
  dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapLegendStore.java
  dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapViewStore.java
  dhis-2/dhis-services/dhis-service-mapping/src/main/resources/
  dhis-2/dhis-services/dhis-service-mapping/src/main/resources/META-INF/
  dhis-2/dhis-services/dhis-service-mapping/src/main/resources/META-INF/dhis/
  dhis-2/dhis-services/dhis-service-mapping/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/
  dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/
  dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/
  dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/
  dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/
  dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLayer.hbm.xml
  dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLegend.hbm.xml
  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/MapView.hbm.xml
  dhis-2/dhis-services/dhis-service-mapping/src/test/
  dhis-2/dhis-services/dhis-service-mapping/src/test/java/
  dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/
  dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/
  dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/
  dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/
  dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java
added:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/
  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/MapViewDeletionHandler.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapLayerStore.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/mapping/hibernate/HibernateMapLegendStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapViewStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLayer.hbm.xml
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLegend.hbm.xml
  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/
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-mapgeneration/pom.xml
  dhis-2/dhis-services/dhis-service-reporting/pom.xml
  dhis-2/dhis-services/pom.xml
  dhis-2/dhis-web/dhis-web-mapping/pom.xml


--
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
=== added directory 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping'
=== added 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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java	2012-10-24 16:19:29 +0000
@@ -0,0 +1,691 @@
+package org.hisp.dhis.mapping;
+
+/*
+ * Copyright (c) 2004-2012, 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 java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.hisp.dhis.aggregation.AggregatedDataValueService;
+import org.hisp.dhis.aggregation.AggregatedMapValue;
+import org.hisp.dhis.configuration.ConfigurationService;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementGroup;
+import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.indicator.Indicator;
+import org.hisp.dhis.indicator.IndicatorGroup;
+import org.hisp.dhis.indicator.IndicatorService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.period.RelativePeriods;
+import org.hisp.dhis.system.util.ConversionUtils;
+import org.hisp.dhis.system.util.MathUtils;
+import org.hisp.dhis.user.CurrentUserService;
+import org.hisp.dhis.user.User;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * @author Jan Henrik Overland
+ */
+@Transactional
+public class DefaultMappingService
+    implements MappingService
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private MapViewStore mapViewStore;
+
+    private MapLayerStore mapLayerStore;
+
+    private MapLegendStore mapLegendStore;
+
+    private MapLegendSetStore mapLegendSetStore;
+
+    public void setMapViewStore( MapViewStore mapViewStore )
+    {
+        this.mapViewStore = mapViewStore;
+    }
+
+    public void setMapLayerStore( MapLayerStore mapLayerStore )
+    {
+        this.mapLayerStore = mapLayerStore;
+    }
+
+    public void setMapLegendStore( MapLegendStore mapLegendStore )
+    {
+        this.mapLegendStore = mapLegendStore;
+    }
+
+    public void setMapLegendSetStore( MapLegendSetStore mapLegendSetStore )
+    {
+        this.mapLegendSetStore = mapLegendSetStore;
+    }
+
+    private OrganisationUnitService organisationUnitService;
+
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+
+    private IndicatorService indicatorService;
+
+    public void setIndicatorService( IndicatorService indicatorService )
+    {
+        this.indicatorService = indicatorService;
+    }
+
+    private DataElementService dataElementService;
+
+    public void setDataElementService( DataElementService dataElementService )
+    {
+        this.dataElementService = dataElementService;
+    }
+
+    private PeriodService periodService;
+
+    public void setPeriodService( PeriodService periodService )
+    {
+        this.periodService = periodService;
+    }
+
+    private AggregatedDataValueService aggregatedDataValueService;
+
+    public void setAggregatedDataValueService( AggregatedDataValueService aggregatedDataValueService )
+    {
+        this.aggregatedDataValueService = aggregatedDataValueService;
+    }
+
+    private CurrentUserService currentUserService;
+
+    public void setCurrentUserService( CurrentUserService currentUserService )
+    {
+        this.currentUserService = currentUserService;
+    }
+
+    private ConfigurationService configurationService;
+
+    public void setConfigurationService( ConfigurationService configurationService )
+    {
+        this.configurationService = configurationService;
+    }
+
+    // -------------------------------------------------------------------------
+    // MappingService implementation
+    // -------------------------------------------------------------------------
+
+    // -------------------------------------------------------------------------
+    // OrganisationUnits
+    // -------------------------------------------------------------------------
+
+    /**
+     * Returns the relevant OrganisationUnits for the given parent identifier
+     * and / or level.
+     * 
+     * @param parentOrganisationUnitId the OrganisationUnit level.
+     * @param level the OrganisationUnit level.
+     * @return a collection of OrganisationUnits.
+     */
+    private Collection<OrganisationUnit> getOrganisationUnits( Integer parentOrganisationUnitId, Integer level )
+    {
+        Collection<OrganisationUnit> organisationUnits = null;
+
+        if ( parentOrganisationUnitId != null && level != null )
+        {
+            organisationUnits = organisationUnitService.getOrganisationUnitsAtLevel( level,
+                organisationUnitService.getOrganisationUnit( parentOrganisationUnitId ) );
+        }
+        else if ( level != null )
+        {
+            organisationUnits = organisationUnitService.getOrganisationUnitsAtLevel( level );
+        }
+        else if ( parentOrganisationUnitId != null )
+        {
+            organisationUnits = organisationUnitService.getOrganisationUnit( parentOrganisationUnitId ).getChildren();
+        }
+
+        return organisationUnits;
+    }
+
+    // -------------------------------------------------------------------------
+    // IndicatorMapValues
+    // -------------------------------------------------------------------------
+
+    /**
+     * Generates a collection AggregatedMapValues. Only one of Period and
+     * start/end date can be specified. At least one of parent organisation unit
+     * and level must be specified. Period should be specified with "real time"
+     * aggregation strategy, any may be specified with "batch" aggregation
+     * strategy.
+     * 
+     * @param indicatorId the Indicator identifier.
+     * @param periodId the Period identifier. Ignored if null.
+     * @param parentOrganisationUnitId the parent OrganisationUnit identifier.
+     *        Ignored if null.
+     * @param level the OrganisationUnit level. Ignored if null.
+     * @return a collection of AggregatedMapValues.
+     */
+    public Collection<AggregatedMapValue> getIndicatorMapValues( int indicatorId, int periodId,
+        int parentOrganisationUnitId, Integer level )
+    {
+        Collection<OrganisationUnit> units = getOrganisationUnits( parentOrganisationUnitId, level );
+
+        return getIndicatorMapValues( indicatorId, periodId, units );
+    }
+
+    public Collection<AggregatedMapValue> getIndicatorMapValues( int indicatorId, int periodId,
+        Collection<OrganisationUnit> units )
+    {
+        Collection<AggregatedMapValue> values = aggregatedDataValueService.getAggregatedIndicatorMapValues(
+            indicatorId, periodId, ConversionUtils.getIdentifiers( OrganisationUnit.class, units ) );
+
+        for ( AggregatedMapValue value : values )
+        {
+            value.setValue( MathUtils.getRounded( value.getValue(), 2 ) );
+        }
+
+        return values;
+    }
+
+    // -------------------------------------------------------------------------
+    // DataElementMapValues
+    // -------------------------------------------------------------------------
+
+    /**
+     * Generates a collection AggregatedMapValues. Only one of Period and
+     * start/end date can be specified. At least one of parent organisation unit
+     * and level must be specified. Period should be specified with "real time"
+     * aggregation strategy, any may be specified with "batch" aggregation
+     * strategy.
+     * 
+     * @param dataElementId the DataElement identifier.
+     * @param periodId the Period identifier. Ignored if null.
+     * @param parentOrganisationUnitId the parent OrganisationUnit identifier.
+     *        Ignored if null.
+     * @param level the OrganisationUnit level. Ignored if null.
+     * @return a collection of AggregatedMapValues.
+     */
+    public Collection<AggregatedMapValue> getDataElementMapValues( int dataElementId, int periodId,
+        int parentOrganisationUnitId, Integer level )
+    {
+        Collection<OrganisationUnit> units = getOrganisationUnits( parentOrganisationUnitId, level );
+
+        return getDataElementMapValues( dataElementId, periodId, units );
+    }
+
+    public Collection<AggregatedMapValue> getDataElementMapValues( int dataElementId, int periodId,
+        Collection<OrganisationUnit> units )
+    {
+        Collection<AggregatedMapValue> values = aggregatedDataValueService.getAggregatedDataMapValues( dataElementId,
+            periodId, ConversionUtils.getIdentifiers( OrganisationUnit.class, units ) );
+
+        for ( AggregatedMapValue value : values )
+        {
+            value.setValue( MathUtils.getRounded( value.getValue(), 2 ) );
+        }
+
+        return values;
+    }
+
+    public Collection<AggregatedMapValue> getInfrastructuralDataElementMapValues( Integer periodId,
+        Integer organisationUnitId )
+    {
+        DataElementGroup group = configurationService.getConfiguration().getInfrastructuralDataElements();
+
+        if ( group == null )
+        {
+            return new HashSet<AggregatedMapValue>();
+        }
+
+        Collection<Integer> dataElementIds = ConversionUtils.getIdentifiers( DataElement.class, group.getMembers() );
+
+        return aggregatedDataValueService.getAggregatedDataMapValues( dataElementIds, periodId, organisationUnitId );
+    }
+
+    // -------------------------------------------------------------------------
+    // MapLegend
+    // -------------------------------------------------------------------------
+
+    public void addOrUpdateMapLegend( String name, Double startValue, Double endValue, String color, String image )
+    {
+        MapLegend mapLegend = getMapLegendByName( name );
+
+        if ( mapLegend != null )
+        {
+            mapLegend.setName( name );
+            mapLegend.setStartValue( startValue );
+            mapLegend.setEndValue( endValue );
+            mapLegend.setColor( color );
+            mapLegend.setImage( image );
+
+            mapLegendStore.update( mapLegend );
+        }
+        else
+        {
+            mapLegend = new MapLegend( name, startValue, endValue, color, image );
+
+            mapLegendStore.save( mapLegend );
+        }
+    }
+
+    public int addMapLegend( MapLegend mapLegend )
+    {
+        return mapLegendStore.save( mapLegend );
+    }
+    
+    public void deleteMapLegend( MapLegend mapLegend )
+    {
+        mapLegendStore.delete( mapLegend );
+    }
+
+    public MapLegend getMapLegend( int id )
+    {
+        return mapLegendStore.get( id );
+    }
+
+    @Override
+    public MapLegend getMapLegend( String uid )
+    {
+        return mapLegendStore.getByUid( uid );
+    }
+
+    public MapLegend getMapLegendByName( String name )
+    {
+        return mapLegendStore.getByName( name );
+    }
+
+    public Collection<MapLegend> getAllMapLegends()
+    {
+        return mapLegendStore.getAll();
+    }
+
+    // -------------------------------------------------------------------------
+    // MapLegendSet
+    // -------------------------------------------------------------------------
+
+    public int addMapLegendSet( MapLegendSet mapLegendSet )
+    {
+        return mapLegendSetStore.save( mapLegendSet );
+    }
+
+    public void updateMapLegendSet( MapLegendSet mapLegendSet )
+    {
+        mapLegendSetStore.update( mapLegendSet );
+    }
+
+    public void addOrUpdateMapLegendSet( String name, String type, String symbolizer, Set<MapLegend> mapLegends )
+    {
+        MapLegendSet mapLegendSet = getMapLegendSetByName( name );
+
+        Set<Indicator> indicators = new HashSet<Indicator>();
+
+        Set<DataElement> dataElements = new HashSet<DataElement>();
+
+        if ( mapLegendSet != null )
+        {
+            mapLegendSet.setType( type );
+            mapLegendSet.setSymbolizer( symbolizer );
+            mapLegendSet.setMapLegends( mapLegends );
+            mapLegendSet.setIndicators( indicators );
+            mapLegendSet.setDataElements( dataElements );
+
+            mapLegendSetStore.update( mapLegendSet );
+        }
+        else
+        {
+            mapLegendSet = new MapLegendSet( name, type, symbolizer, mapLegends, indicators, dataElements );
+
+            mapLegendSetStore.save( mapLegendSet );
+        }
+    }
+
+    public void deleteMapLegendSet( MapLegendSet mapLegendSet )
+    {
+        mapLegendSetStore.delete( mapLegendSet );
+    }
+
+    public MapLegendSet getMapLegendSet( int id )
+    {
+        return mapLegendSetStore.get( id );
+    }
+
+    @Override
+    public MapLegendSet getMapLegendSet( String uid )
+    {
+        return mapLegendSetStore.getByUid( uid );
+    }
+
+    public MapLegendSet getMapLegendSetByName( String name )
+    {
+        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
+    // -------------------------------------------------------------------------
+
+    public int addMapView( MapView mapView )
+    {
+        return mapViewStore.save( mapView );
+    }
+
+    public void addMapView( String name, boolean system, String mapValueType, Integer indicatorGroupId,
+        Integer indicatorId, Integer dataElementGroupId, Integer dataElementId, String periodTypeName,
+        Integer periodId, Integer parentOrganisationUnitId, Integer organisationUnitLevel, String mapLegendType,
+        Integer method, Integer classes, String bounds, String colorLow, String colorHigh, Integer mapLegendSetId,
+        Integer radiusLow, Integer radiusHigh, String longitude, String latitude, int zoom )
+    {
+        User user = system ? null : currentUserService.getCurrentUser();
+
+        IndicatorGroup indicatorGroup = null;
+
+        Indicator indicator = null;
+
+        DataElementGroup dataElementGroup = null;
+
+        DataElement dataElement = null;
+
+        if ( mapValueType.equals( MappingService.MAP_VALUE_TYPE_INDICATOR ) )
+        {
+            indicatorGroup = indicatorService.getIndicatorGroup( indicatorGroupId );
+            indicator = indicatorService.getIndicator( indicatorId );
+        }
+        else
+        {
+            dataElementGroup = dataElementService.getDataElementGroup( dataElementGroupId );
+            dataElement = dataElementService.getDataElement( dataElementId );
+        }
+
+        PeriodType periodType = periodTypeName != null && !periodTypeName.isEmpty() ? periodService
+            .getPeriodTypeByClass( PeriodType.getPeriodTypeByName( periodTypeName ).getClass() ) : null;
+
+        Period period = periodId != null ? periodService.getPeriod( periodId ) : null;
+
+        OrganisationUnit parent = organisationUnitService.getOrganisationUnit( parentOrganisationUnitId );
+
+        OrganisationUnitLevel level = organisationUnitService.getOrganisationUnitLevelByLevel( organisationUnitLevel );
+
+        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,
+            mapLegendSet, radiusLow, radiusHigh, longitude, latitude, zoom ) );
+    }
+
+    public void updateMapView( MapView mapView )
+    {
+        mapViewStore.update( mapView );
+    }
+
+    public void deleteMapView( MapView mapView )
+    {
+        mapViewStore.delete( mapView );
+    }
+
+    public MapView getMapView( int id )
+    {
+        MapView mapView = mapViewStore.get( id );
+
+        setMapViewLevel( mapView );
+
+        return mapView;
+    }
+
+    public MapView getMapView( String uid )
+    {
+        MapView mapView = mapViewStore.getByUid( uid );
+
+        setMapViewLevel( mapView );
+
+        return mapView;
+    }
+
+    private void setMapViewLevel( MapView mapView )
+    {
+        if ( mapView != null )
+        {
+            mapView.getParentOrganisationUnit().setLevel(
+                organisationUnitService.getLevelOfOrganisationUnit( mapView.getParentOrganisationUnit().getId() ) );
+        }
+    }
+
+    public MapView getMapViewByName( String name )
+    {
+        return mapViewStore.getByName( name );
+    }
+
+    public MapView getIndicatorLastYearMapView( String indicatorUid, String organisationUnitUid, int level )
+    {
+        MapView mapView = new MapView();
+
+        Period period = periodService.reloadPeriod( new RelativePeriods().setThisYear( true ).getRelativePeriods()
+            .iterator().next() );
+
+        Indicator indicator = indicatorService.getIndicator( indicatorUid );
+        OrganisationUnit unit = organisationUnitService.getOrganisationUnit( organisationUnitUid );
+
+        mapView.setIndicator( indicator );
+        mapView.setPeriod( period );
+        mapView.setParentOrganisationUnit( unit );
+        mapView.setOrganisationUnitLevel( new OrganisationUnitLevel( level, "" ) );
+        mapView.setName( indicator.getName() );
+        mapView.setMapValueType( MappingService.MAP_VALUE_TYPE_INDICATOR );
+
+        return mapView;
+    }
+
+    public Collection<MapView> getSystemAndUserMapViews()
+    {
+        User user = currentUserService.getCurrentUser();
+        
+        return mapViewStore.getSystemAndUserMapViews( user );
+    }
+    
+    public Collection<MapView> getAllMapViews()
+    {
+        Collection<MapView> mapViews = mapViewStore.getAll();
+
+        if ( mapViews.size() > 0 )
+        {
+            for ( MapView mapView : mapViews )
+            {
+                mapView.getParentOrganisationUnit().setLevel(
+                    organisationUnitService.getLevelOfOrganisationUnit( mapView.getParentOrganisationUnit().getId() ) );
+            }
+        }
+
+        return mapViews;
+    }
+
+    public Collection<MapView> getMapViewsByFeatureType( String featureType )
+    {
+        User user = currentUserService.getCurrentUser();
+
+        Collection<MapView> mapViews = mapViewStore.getMapViewsByFeatureType( featureType, user );
+
+        for ( MapView mapView : mapViews )
+        {
+            mapView.getParentOrganisationUnit().setLevel(
+                organisationUnitService.getLevelOfOrganisationUnit( mapView.getParentOrganisationUnit().getId() ) );
+        }
+
+        return mapViews;
+    }
+    
+    public Collection<MapView> getMapViewsByUser( User user )
+    {
+        return mapViewStore.getByUser( user );
+    }
+    
+    public Collection<MapView> getMapViewsBetweenByName( String name, int first, int max )
+    {
+        return mapViewStore.getBetweenByName( name, first, max );
+    }
+
+    // -------------------------------------------------------------------------
+    // MapLayer
+    // -------------------------------------------------------------------------
+
+    public int addMapLayer( MapLayer mapLayer )
+    {
+        return mapLayerStore.save( mapLayer );
+    }
+
+    public void updateMapLayer( MapLayer mapLayer )
+    {
+        mapLayerStore.update( mapLayer );
+    }
+
+    public void addOrUpdateMapLayer( String name, String type, String url, String layers, String time,
+        String fillColor, double fillOpacity, String strokeColor, int strokeWidth )
+    {
+        MapLayer mapLayer = mapLayerStore.getByName( name );
+
+        if ( mapLayer != null )
+        {
+            mapLayer.setName( name );
+            mapLayer.setType( type );
+            mapLayer.setUrl( url );
+            mapLayer.setLayers( layers );
+            mapLayer.setTime( time );
+            mapLayer.setFillColor( fillColor );
+            mapLayer.setFillOpacity( fillOpacity );
+            mapLayer.setStrokeColor( strokeColor );
+            mapLayer.setStrokeWidth( strokeWidth );
+
+            updateMapLayer( mapLayer );
+        }
+        else
+        {
+            addMapLayer( new MapLayer( name, type, url, layers, time, fillColor, fillOpacity, strokeColor, strokeWidth ) );
+        }
+    }
+
+    public void deleteMapLayer( MapLayer mapLayer )
+    {
+        mapLayerStore.delete( mapLayer );
+    }
+
+    public MapLayer getMapLayer( int id )
+    {
+        return mapLayerStore.get( id );
+    }
+
+    @Override
+    public MapLayer getMapLayer( String uid )
+    {
+        return mapLayerStore.getByUid( uid );
+    }
+
+    public MapLayer getMapLayerByName( String name )
+    {
+        return mapLayerStore.getByName( name );
+    }
+
+    public Collection<MapLayer> getMapLayersByType( String type )
+    {
+        return mapLayerStore.getMapLayersByType( type );
+    }
+
+    public MapLayer getMapLayerByMapSource( String mapSource )
+    {
+        return mapLayerStore.getMapLayerByMapSource( mapSource );
+    }
+
+    public Collection<MapLayer> getAllMapLayers()
+    {
+        return mapLayerStore.getAll();
+    }
+}

=== added 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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/MapLegendSetDeletionHandler.java	2012-10-24 16:19:29 +0000
@@ -0,0 +1,97 @@
+package org.hisp.dhis.mapping;
+
+/*
+ * Copyright (c) 2004-2012, 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.dataelement.DataElement;
+import org.hisp.dhis.indicator.Indicator;
+import org.hisp.dhis.system.deletion.DeletionHandler;
+
+/**
+ * @author Lars Helge Overland
+ * @version $Id$
+ */
+public class MapLegendSetDeletionHandler
+    extends DeletionHandler
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private MappingService mappingService;
+
+    public void setMappingService( MappingService mappingService )
+    {
+        this.mappingService = mappingService;
+    }
+
+    // -------------------------------------------------------------------------
+    // DeletionHandler implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    protected String getClassName()
+    {
+        return MapLegendSet.class.getSimpleName();
+    }
+    
+    @Override
+    public void deleteMapLegend( MapLegend mapLegend )
+    {
+        for ( MapLegendSet legendSet : mappingService.getAllMapLegendSets() )
+        {
+            if ( legendSet.getMapLegends().remove( mapLegend ) )
+            {
+                mappingService.updateMapLegendSet( legendSet );
+            }
+        }
+    }
+    
+    @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 );
+            }
+        }
+    }
+}

=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/MapViewDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/MapViewDeletionHandler.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/MapViewDeletionHandler.java	2012-10-24 16:19:29 +0000
@@ -0,0 +1,167 @@
+package org.hisp.dhis.mapping;
+
+/*
+ * Copyright (c) 2004-2012, 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 java.util.Iterator;
+
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementGroup;
+import org.hisp.dhis.indicator.Indicator;
+import org.hisp.dhis.indicator.IndicatorGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.system.deletion.DeletionHandler;
+import org.hisp.dhis.user.User;
+
+/**
+ * @author Lars Helge Overland
+ * @version $Id$
+ */
+public class MapViewDeletionHandler
+    extends DeletionHandler
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private MappingService mappingService;
+
+    public void setMappingService( MappingService mappingService )
+    {
+        this.mappingService = mappingService;
+    }
+
+    // -------------------------------------------------------------------------
+    // DeletionHandler implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    protected String getClassName()
+    {
+        return MapView.class.getName();
+    }
+    
+    @Override
+    public String allowDeletePeriod( Period period )
+    {
+        for ( MapView mapView : mappingService.getAllMapViews() )
+        {
+            if ( mapView.getPeriod().equals( period ) )
+            {
+                return mapView.getName();
+            }
+        }
+        
+        return null;
+    }
+    
+    @Override
+    public void deleteIndicatorGroup( IndicatorGroup indicatorGroup )
+    {
+        for ( MapView mapView : mappingService.getAllMapViews() )
+        {
+            if ( mapView.getIndicatorGroup() != null && mapView.getIndicatorGroup().equals( indicatorGroup ) )
+            {
+                mappingService.deleteMapView( mapView );
+            }
+        }
+    }
+    
+    @Override
+    public void deleteIndicator( Indicator indicator )
+    {
+        for ( MapView mapView : mappingService.getAllMapViews() )
+        {
+            if ( mapView.getIndicator() != null && mapView.getIndicator().equals( indicator ) )
+            {
+                mappingService.deleteMapView( mapView );
+            }
+        }
+    }
+    
+    @Override
+    public void deleteDataElementGroup( DataElementGroup dataElementGroup )
+    {
+        for ( MapView mapView : mappingService.getAllMapViews() )
+        {
+            if ( mapView.getDataElementGroup() != null && mapView.getDataElementGroup().equals( dataElementGroup ) )
+            {
+                mappingService.deleteMapView( mapView );
+            }
+        }
+    }
+    
+    @Override
+    public void deleteDataElement( DataElement dataElement )
+    {
+        for ( MapView mapView : mappingService.getAllMapViews() )
+        {
+            if ( mapView.getDataElement() != null && mapView.getDataElement().equals( dataElement ) )
+            {
+                mappingService.deleteMapView( mapView );
+            }
+        }
+    }
+    
+    @Override
+    public void deleteOrganisationUnit( OrganisationUnit organisationUnit )
+    {
+        for ( MapView mapView : mappingService.getAllMapViews() )
+        {
+            if ( mapView.getParentOrganisationUnit() != null && mapView.getParentOrganisationUnit().equals( organisationUnit ) )
+            {
+                mappingService.deleteMapView( mapView );
+            }
+        }
+    }
+    
+    @Override
+    public void deleteMapLegendSet( MapLegendSet mapLegendSet )
+    {
+        for ( MapView mapView : mappingService.getAllMapViews() )
+        {
+            if ( mapView.getMapLegendSet() != null && mapView.getMapLegendSet().equals( mapLegendSet ) )
+            {
+                mappingService.deleteMapView( mapView );
+            }
+        }
+    }
+    
+    @Override
+    public void deleteUser( User user )
+    {
+        Iterator<MapView> iterator = mappingService.getMapViewsByUser( user ).iterator();
+        
+        while ( iterator.hasNext() )
+        {
+            MapView mapView = iterator.next();
+            iterator.remove();
+            mappingService.deleteMapView( mapView );
+        }
+    }
+}

=== added directory 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate'
=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapLayerStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapLayerStore.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapLayerStore.java	2012-10-24 16:19:29 +0000
@@ -0,0 +1,80 @@
+package org.hisp.dhis.mapping.hibernate;
+
+/*
+ * Copyright (c) 2004-2012, 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.hibernate.Criteria;
+import org.hibernate.Session;
+import org.hibernate.criterion.Restrictions;
+import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
+import org.hisp.dhis.mapping.MapLayer;
+import org.hisp.dhis.mapping.MapLayerStore;
+
+import java.util.Collection;
+
+/**
+ * @author Jan Henrik Overland
+ */
+public class HibernateMapLayerStore
+    extends HibernateIdentifiableObjectStore<MapLayer>
+    implements MapLayerStore
+{
+    @SuppressWarnings( "unchecked" )
+    public Collection<MapLayer> getMapLayersByType( String type )
+    {
+        Session session = sessionFactory.getCurrentSession();
+
+        Criteria criteria = session.createCriteria( MapLayer.class );
+
+        criteria.add( Restrictions.eq( "type", type ) );
+
+        return criteria.list();
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public Collection<MapLayer> getMapLayersByMapSourceType( String mapSourceType )
+    {
+        Session session = sessionFactory.getCurrentSession();
+
+        Criteria criteria = session.createCriteria( MapLayer.class );
+
+        criteria.add( Restrictions.eq( "mapSourceType", mapSourceType ) );
+
+        return criteria.list();
+    }
+
+    public MapLayer getMapLayerByMapSource( String mapSource )
+    {
+        Session session = sessionFactory.getCurrentSession();
+
+        Criteria criteria = session.createCriteria( MapLayer.class );
+
+        criteria.add( Restrictions.eq( "mapSource", mapSource ) );
+
+        return (MapLayer) criteria.uniqueResult();
+    }
+}

=== added 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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapLegendSetStore.java	2012-10-24 16:19:29 +0000
@@ -0,0 +1,57 @@
+package org.hisp.dhis.mapping.hibernate;
+
+/*
+ * Copyright (c) 2004-2012, 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.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
+ */
+public class HibernateMapLegendSetStore
+    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();
+    }
+}

=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapLegendStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapLegendStore.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapLegendStore.java	2012-10-24 16:19:29 +0000
@@ -0,0 +1,41 @@
+package org.hisp.dhis.mapping.hibernate;
+
+/*
+ * Copyright (c) 2004-2012, 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.common.hibernate.HibernateIdentifiableObjectStore;
+import org.hisp.dhis.mapping.MapLegend;
+import org.hisp.dhis.mapping.MapLegendStore;
+
+/**
+ * @author Jan Henrik Overland
+ */
+public class HibernateMapLegendStore
+    extends HibernateIdentifiableObjectStore<MapLegend>
+    implements MapLegendStore
+{
+}

=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapViewStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapViewStore.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapViewStore.java	2012-10-24 16:19:29 +0000
@@ -0,0 +1,80 @@
+package org.hisp.dhis.mapping.hibernate;
+
+/*
+ * Copyright (c) 2004-2012, 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.hibernate.Criteria;
+import org.hibernate.Session;
+import org.hibernate.criterion.Restrictions;
+import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
+import org.hisp.dhis.mapping.MapView;
+import org.hisp.dhis.mapping.MapViewStore;
+import org.hisp.dhis.user.User;
+
+import java.util.Collection;
+
+/**
+ * @author Jan Henrik Overland
+ */
+public class HibernateMapViewStore
+    extends HibernateIdentifiableObjectStore<MapView>
+    implements MapViewStore
+{
+    @SuppressWarnings( "unchecked" )
+    public Collection<MapView> getSystemAndUserMapViews( User user )
+    {
+        return getCriteria( 
+            Restrictions.or( Restrictions.isNull( "user" ), 
+            Restrictions.eq( "user", user ) ) ).list();
+    }
+    
+    @SuppressWarnings( "unchecked" )
+    public Collection<MapView> getMapViewsByMapSourceType( String mapSourceType )
+    {
+        Session session = sessionFactory.getCurrentSession();
+
+        Criteria criteria = session.createCriteria( MapView.class );
+
+        criteria.add( Restrictions.eq( "mapSourceType", mapSourceType ) );
+
+        return criteria.list();
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public Collection<MapView> getMapViewsByFeatureType( String featureType, User user )
+    {
+        Session session = sessionFactory.getCurrentSession();
+
+        Criteria criteria = session.createCriteria( MapView.class );
+
+        criteria.add( Restrictions.eq( "featureType", featureType ) );
+
+        criteria.add( Restrictions.or( Restrictions.eq( "user", user ), Restrictions.isNull( "user" ) ) );
+
+        return criteria.list();
+    }
+}

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2012-10-23 08:01:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2012-10-24 16:19:29 +0000
@@ -287,6 +287,30 @@
     <property name="sessionFactory" ref="sessionFactory" />
   </bean>
 
+  <bean id="org.hisp.dhis.mapping.MapViewStore"
+      class="org.hisp.dhis.mapping.hibernate.HibernateMapViewStore">
+    <property name="clazz" value="org.hisp.dhis.mapping.MapView" />
+    <property name="sessionFactory" ref="sessionFactory" />
+  </bean>
+
+  <bean id="org.hisp.dhis.mapping.MapLayerStore"
+      class="org.hisp.dhis.mapping.hibernate.HibernateMapLayerStore">
+    <property name="clazz" value="org.hisp.dhis.mapping.MapLayer" />
+    <property name="sessionFactory" ref="sessionFactory" />
+  </bean>
+
+  <bean id="org.hisp.dhis.mapping.MapLegendStore"
+      class="org.hisp.dhis.mapping.hibernate.HibernateMapLegendStore">
+    <property name="clazz" value="org.hisp.dhis.mapping.MapLegend" />
+    <property name="sessionFactory" ref="sessionFactory" />
+  </bean>
+
+  <bean id="org.hisp.dhis.mapping.MapLegendSetStore"
+      class="org.hisp.dhis.mapping.hibernate.HibernateMapLegendSetStore">
+    <property name="clazz" value="org.hisp.dhis.mapping.MapLegendSet" />
+    <property name="sessionFactory" ref="sessionFactory" />
+  </bean>
+
   <!-- Service definitions -->
 
   <bean id="org.hisp.dhis.dataelement.DataElementOperandService" class="org.hisp.dhis.dataelement.DefaultDataElementOperandService">
@@ -504,6 +528,20 @@
 	<property name="optionStore" ref="org.hisp.dhis.option.OptionStore"/>
   </bean>
 
+  <bean id="org.hisp.dhis.mapping.MappingService" class="org.hisp.dhis.mapping.DefaultMappingService">
+    <property name="mapViewStore" ref="org.hisp.dhis.mapping.MapViewStore" />
+    <property name="mapLayerStore" ref="org.hisp.dhis.mapping.MapLayerStore" />
+    <property name="mapLegendStore" ref="org.hisp.dhis.mapping.MapLegendStore" />
+    <property name="mapLegendSetStore" ref="org.hisp.dhis.mapping.MapLegendSetStore" />
+    <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+    <property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
+    <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
+    <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
+    <property name="aggregatedDataValueService" ref="org.hisp.dhis.aggregation.AggregatedDataValueService" />
+    <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
+    <property name="configurationService" ref="org.hisp.dhis.configuration.ConfigurationService" />
+  </bean>
+
   <bean id="org.hisp.dhis.setting.SystemSettingManager" class="org.hisp.dhis.setting.DefaultSystemSettingManager">
     <property name="systemSettingStore" ref="org.hisp.dhis.setting.SystemSettingStore" />
     <property name="flags">
@@ -843,6 +881,14 @@
 	<property name="jdbcTemplate" ref="jdbcTemplate" />
   </bean>
   
+  <bean id="org.hisp.dhis.mapping.MapLegendSetDeletionHandler" class="org.hisp.dhis.mapping.MapLegendSetDeletionHandler">
+    <property name="mappingService" ref="org.hisp.dhis.mapping.MappingService" />
+  </bean>
+
+  <bean id="org.hisp.dhis.mapping.MapViewDeletionHandler" class="org.hisp.dhis.mapping.MapViewDeletionHandler">
+    <property name="mappingService" ref="org.hisp.dhis.mapping.MappingService" />
+  </bean>
+  
   <!-- DeletionManager -->
 
   <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
@@ -883,6 +929,8 @@
 		  <ref local="org.hisp.dhis.message.MessageConversationDeletionHandler" />
 		  <ref local="org.hisp.dhis.translation.TranslationDeletionHandler" />
 		  <ref local="org.hisp.dhis.attribute.AttributeValueDeletionHandler" />
+		  <ref local="org.hisp.dhis.mapping.MapLegendSetDeletionHandler" />
+          <ref local="org.hisp.dhis.mapping.MapViewDeletionHandler" />
         </list>
       </list>
     </property>
@@ -909,7 +957,10 @@
       <aop:before pointcut="execution( * org.hisp.dhis.concept.ConceptService.delete*(..) )" method="intercept" />
       <aop:before pointcut="execution( * org.hisp.dhis.user.UserGroupService.delete*(..) )" method="intercept" />
       <aop:before pointcut="execution( * org.hisp.dhis.option.OptionService.delete*(..) )" method="intercept" />
-      <aop:before pointcut="execution( * org.hisp.dhis.attribute.AttributeService.delete*(..) )" method="intercept" />	  
+      <aop:before pointcut="execution( * org.hisp.dhis.attribute.AttributeService.delete*(..) )" method="intercept" />
+      <aop:before pointcut="execution( * org.hisp.dhis.mapping.MappingService.deleteMapLegend(..) )" method="intercept" />
+      <aop:before pointcut="execution( * org.hisp.dhis.mapping.MappingService.deleteMapLegendSet(..) )" method="intercept" />
+      <aop:before pointcut="execution( * org.hisp.dhis.mapping.MappingService.deleteMapView(..) )" method="intercept" /> 
     </aop:aspect>
 
     <!-- <aop:aspect ref="i18nTranslationInterceptor"> <aop:after-returning pointcut="execution( * org.hisp.dhis.dataelement.DataElementService.get*(..) 

=== added directory 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping'
=== added directory 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate'
=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLayer.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLayer.hbm.xml	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLayer.hbm.xml	2012-10-24 16:19:29 +0000
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+  "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd";
+  [<!ENTITY identifiableProperties SYSTEM "classpath://org/hisp/dhis/common/identifiableProperties.hbm">]
+>
+
+<hibernate-mapping>
+  <class name="org.hisp.dhis.mapping.MapLayer" table="maplayer">
+
+    <id name="id" column="maplayerid">
+      <generator class="native" />
+    </id>
+    &identifiableProperties;
+
+    <property name="type" column="type" />
+
+    <property name="url" column="url" type="text" />
+
+    <property name="layers" column="layers" type="text" />
+
+    <property name="time" column="time" type="text" />
+
+    <property name="fillColor" column="fillcolor" />
+
+    <property name="fillOpacity" column="fillopacity" not-null="true" />
+
+    <property name="strokeColor" column="strokecolor" />
+
+    <property name="strokeWidth" column="strokewidth" not-null="true" />
+
+  </class>
+</hibernate-mapping>

=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLegend.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLegend.hbm.xml	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLegend.hbm.xml	2012-10-24 16:19:29 +0000
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+  "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd";
+  [<!ENTITY identifiableProperties SYSTEM "classpath://org/hisp/dhis/common/identifiableProperties.hbm">]
+>
+
+<hibernate-mapping>
+  <class name="org.hisp.dhis.mapping.MapLegend" table="maplegend">
+
+    <id name="id" column="maplegendid">
+      <generator class="native" />
+    </id>
+    &identifiableProperties;
+
+    <property name="startValue" column="startvalue" />
+
+    <property name="endValue" column="endvalue" />
+
+    <property name="color" column="color" />
+
+    <property name="image" column="image" />
+
+  </class>
+</hibernate-mapping>

=== added 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	1970-01-01 00:00:00 +0000
+++ 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
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+  "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd";
+  [<!ENTITY identifiableProperties SYSTEM "classpath://org/hisp/dhis/common/identifiableProperties.hbm">]
+>
+
+<hibernate-mapping>
+  <class name="org.hisp.dhis.mapping.MapLegendSet" table="maplegendset">
+
+    <id name="id" column="maplegendsetid">
+      <generator class="native" />
+    </id>
+    &identifiableProperties;
+
+    <property name="type" column="type" />
+
+    <property name="symbolizer" column="symbolizer" />
+
+    <set name="mapLegends" table="maplegendsetmaplegend">
+      <key column="legendsetid" foreign-key="fk_maplegendsetmaplegend_legendsetid" />
+      <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>

=== added 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	1970-01-01 00:00:00 +0000
+++ 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
@@ -0,0 +1,69 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+  "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd";
+  [<!ENTITY identifiableProperties SYSTEM "classpath://org/hisp/dhis/common/identifiableProperties.hbm">]
+>
+
+<hibernate-mapping>
+  <class name="org.hisp.dhis.mapping.MapView" table="mapview">
+
+    <id name="id" column="mapviewid">
+      <generator class="native" />
+    </id>
+    &identifiableProperties;
+
+    <many-to-one name="user" class="org.hisp.dhis.user.User" column="userid" foreign-key="fk_mapview_userid" />
+
+    <property name="mapValueType" />
+
+    <many-to-one name="indicatorGroup" class="org.hisp.dhis.indicator.IndicatorGroup" column="indicatorgroupid"
+      foreign-key="fk_mapview_indicatorgroupid" />
+
+    <many-to-one name="indicator" class="org.hisp.dhis.indicator.Indicator" column="indicatorid"
+      foreign-key="fk_mapview_indicatorid" />
+
+    <many-to-one name="dataElementGroup" class="org.hisp.dhis.dataelement.DataElementGroup" column="dataelementgroupid"
+      foreign-key="fk_mapview_dataelementgroupid" />
+
+    <many-to-one name="dataElement" class="org.hisp.dhis.dataelement.DataElement" column="dataelementid"
+      foreign-key="fk_mapview_dataelementid" />
+
+    <many-to-one name="periodType" class="org.hisp.dhis.period.PeriodType" column="periodtypeid"
+      foreign-key="fk_mapview_periodtypeid" />
+
+    <many-to-one name="period" class="org.hisp.dhis.period.Period" column="periodid" foreign-key="fk_mapview_periodid" />
+
+    <many-to-one name="parentOrganisationUnit" class="org.hisp.dhis.organisationunit.OrganisationUnit"
+      column="parentorganisationunitid" foreign-key="fk_mapview_parentorganisationunitid" />
+
+    <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" />
+
+    <property name="bounds" />
+
+    <property name="colorLow" />
+
+    <property name="colorHigh" />
+
+    <many-to-one name="mapLegendSet" class="org.hisp.dhis.mapping.MapLegendSet" column="maplegendsetid"
+      foreign-key="fk_mapview_maplegendsetid" />
+
+    <property name="radiusLow" />
+
+    <property name="radiusHigh" />
+
+    <property name="longitude" />
+
+    <property name="latitude" />
+
+    <property name="zoom" />
+
+  </class>
+</hibernate-mapping>

=== added directory 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/mapping'
=== added 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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java	2012-10-24 16:19:29 +0000
@@ -0,0 +1,507 @@
+package org.hisp.dhis.mapping;
+
+/*
+ * Copyright (c) 2004-2012, 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 static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertNull;
+import static junit.framework.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+
+import org.hisp.dhis.DhisSpringTest;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementGroup;
+import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.indicator.Indicator;
+import org.hisp.dhis.indicator.IndicatorGroup;
+import org.hisp.dhis.indicator.IndicatorService;
+import org.hisp.dhis.indicator.IndicatorType;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.period.MonthlyPeriodType;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.period.PeriodType;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * @author Lars Helge Overland
+ * @version $Id$
+ */
+public class MappingServiceTest
+    extends DhisSpringTest
+{
+    private MappingService mappingService;
+
+    private OrganisationUnit organisationUnit;
+
+    private OrganisationUnitLevel organisationUnitLevel;
+
+    private IndicatorGroup indicatorGroup;
+
+    private IndicatorType indicatorType;
+
+    private Indicator indicator;
+
+    private DataElement dataElement;
+
+    private DataElementGroup dataElementGroup;
+
+    private PeriodType periodType;
+
+    private Period period;
+
+    private MapLegendSet mapLegendSet;
+
+    // -------------------------------------------------------------------------
+    // Fixture
+    // -------------------------------------------------------------------------
+
+    @Override
+    public void setUpTest()
+    {
+        mappingService = (MappingService) getBean( MappingService.ID );
+
+        organisationUnitService = (OrganisationUnitService) getBean( OrganisationUnitService.ID );
+
+        indicatorService = (IndicatorService) getBean( IndicatorService.ID );
+
+        dataElementService = (DataElementService) getBean( DataElementService.ID );
+
+        periodService = (PeriodService) getBean( PeriodService.ID );
+
+        organisationUnit = createOrganisationUnit( 'A' );
+        organisationUnitLevel = new OrganisationUnitLevel( 1, "Level" );
+
+        organisationUnitService.addOrganisationUnit( organisationUnit );
+        organisationUnitService.addOrganisationUnitLevel( organisationUnitLevel );
+
+        indicatorGroup = createIndicatorGroup( 'A' );
+        indicatorService.addIndicatorGroup( indicatorGroup );
+
+        indicatorType = createIndicatorType( 'A' );
+        indicatorService.addIndicatorType( indicatorType );
+
+        indicator = createIndicator( 'A', indicatorType );
+        indicatorService.addIndicator( indicator );
+
+        dataElement = createDataElement( 'A' );
+        dataElementService.addDataElement( dataElement );
+
+        dataElementGroup = createDataElementGroup( 'A' );
+        dataElementGroup.getMembers().add( dataElement );
+        dataElementService.addDataElementGroup( dataElementGroup );
+
+        periodType = periodService.getPeriodTypeByName( MonthlyPeriodType.NAME );
+        period = createPeriod( periodType, getDate( 2000, 1, 1 ), getDate( 2000, 2, 1 ) );
+        periodService.addPeriod( period );
+
+        mapLegendSet = createMapLegendSet( 'A', indicator );
+        mappingService.addMapLegendSet( mapLegendSet );
+    }
+
+    // -------------------------------------------------------------------------
+    // MapLegend
+    // -------------------------------------------------------------------------
+
+    @Test
+    public void testGetAddOrUpdateMapLegendByName()
+    {
+        MapLegend legend = createMapLegend( 'A', 0.1, 0.2 );
+
+        mappingService.addOrUpdateMapLegend( legend.getName(), legend.getStartValue(), legend.getEndValue(),
+            legend.getColor(), legend.getImage() );
+
+        legend = mappingService.getMapLegendByName( legend.getName() );
+
+        assertNotNull( legend );
+
+        int id = legend.getId();
+
+        mappingService.addOrUpdateMapLegend( legend.getName(), legend.getStartValue(), 0.3, "ColorB", "img.png" );
+
+        assertEquals( "MapLegendA", mappingService.getMapLegend( id ).getName() );
+        assertEquals( 0.1, mappingService.getMapLegend( id ).getStartValue() );
+        assertEquals( 0.3, mappingService.getMapLegend( id ).getEndValue() );
+        assertEquals( "ColorB", mappingService.getMapLegend( id ).getColor() );
+        assertEquals( "img.png", mappingService.getMapLegend( id ).getImage() );
+    }
+
+    @Test
+    public void testDeleteMapLegend()
+    {
+        MapLegend legend = createMapLegend( 'A', 0.1, 0.2 );
+
+        mappingService.addOrUpdateMapLegend( legend.getName(), legend.getStartValue(), legend.getEndValue(),
+            legend.getColor(), legend.getImage() );
+
+        legend = mappingService.getMapLegendByName( legend.getName() );
+
+        assertNotNull( legend );
+
+        int id = legend.getId();
+
+        mappingService.deleteMapLegend( legend );
+
+        assertNull( mappingService.getMapLegend( id ) );
+    }
+
+    @Test
+    public void testGetAllMapLegends()
+    {
+        MapLegend legend1 = createMapLegend( 'A', 0.1, 0.2 );
+        MapLegend legend2 = createMapLegend( 'B', 0.3, 0.4 );
+        MapLegend legend3 = createMapLegend( 'C', 0.5, 0.6 );
+
+        mappingService.addOrUpdateMapLegend( legend1.getName(), legend1.getStartValue(), legend1.getEndValue(),
+            legend1.getColor(), legend1.getImage() );
+        mappingService.addOrUpdateMapLegend( legend3.getName(), legend3.getStartValue(), legend3.getEndValue(),
+            legend3.getColor(), legend3.getImage() );
+
+        legend1 = mappingService.getMapLegendByName( legend1.getName() );
+        legend3 = mappingService.getMapLegendByName( legend3.getName() );
+
+        assertNotNull( legend1 );
+        assertNotNull( legend3 );
+
+        int idA = legend1.getId();
+        int idC = legend3.getId();
+
+        assertEquals( legend1, mappingService.getMapLegend( idA ) );
+        assertEquals( legend3, mappingService.getMapLegend( idC ) );
+        assertTrue( !mappingService.getAllMapLegends().contains( legend2 ) );
+    }
+
+    // -------------------------------------------------------------------------
+    // MapLegendSet
+    // -------------------------------------------------------------------------
+
+    @Test
+    public void testAddGetMapLegendSet()
+    {
+        MapLegendSet legendSet = createMapLegendSet( 'B', indicator );
+
+        int id = mappingService.addMapLegendSet( legendSet );
+
+        assertNotNull( mappingService.getMapLegendSet( id ) );
+    }
+
+    @Test
+    public void testGetUpdateMapLegendSetByName()
+    {
+        MapLegendSet legendSet = createMapLegendSet( 'C', indicator );
+
+        int id = mappingService.addMapLegendSet( legendSet );
+
+        legendSet = mappingService.getMapLegendSet( id );
+
+        assertNotNull( legendSet );
+
+        legendSet.setName( "MapLegendSetB" );
+
+        mappingService.updateMapLegendSet( legendSet );
+
+        assertEquals( "MapLegendSetB", mappingService.getMapLegendSetByName( "MapLegendSetB" ).getName() );
+    }
+
+    @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 );
+
+        Collection<MapLegendSet> mapLegendSets = new HashSet<MapLegendSet>();
+
+        mapLegendSets.add( mapLegendSet );
+        mapLegendSets.add( legendSet1 );
+        mapLegendSets.add( legendSet2 );
+        mapLegendSets.add( legendSet3 );
+
+        mappingService.addMapLegendSet( legendSet1 );
+        mappingService.addMapLegendSet( legendSet2 );
+        mappingService.addMapLegendSet( legendSet3 );
+
+        assertTrue( mappingService.getAllMapLegendSets().containsAll( mapLegendSets ) );
+
+    }
+
+    @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
+    // -------------------------------------------------------------------------
+
+    @Test
+    public void testAddGetMapView()
+    {
+        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",
+            mapLegendSet, 5, 20, "1", "1", 1 );
+
+        int idA = mappingService.addMapView( mapView );
+
+        assertEquals( mapView, mappingService.getMapView( idA ) );
+        assertEquals( indicatorGroup, mappingService.getMapView( idA ).getIndicatorGroup() );
+        assertEquals( indicator, mappingService.getMapView( idA ).getIndicator() );
+        assertEquals( periodType, mappingService.getMapView( idA ).getPeriodType() );
+        assertEquals( period, mappingService.getMapView( idA ).getPeriod() );
+    }
+
+    @Test
+    public void testGetDeleteMapViewByName()
+    {
+        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",
+            mapLegendSet, 5, 20, "1", "1", 1 );
+
+        int id = mappingService.addMapView( mapView );
+
+        mapView = mappingService.getMapViewByName( "MapViewA" );
+
+        mappingService.deleteMapView( mapView );
+
+        assertNull( mappingService.getMapView( id ) );
+    }
+
+    @Test
+    public void testGetAllMapViews()
+    {
+        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",
+            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",
+            mapLegendSet, 5, 20, "2", "2", 1 );
+
+        mappingService.addMapView( mapView1 );
+        mappingService.addMapView( mapView2 );
+
+        assertEquals( 2, mappingService.getAllMapViews().size() );
+    }
+
+    @Test
+    @Ignore
+    // TODO
+    public void testGetMapViewsByFeatureType()
+    {
+        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",
+            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",
+            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",
+            mapLegendSet, 5, 20, "3", "3", 1 );
+
+        mappingService.addMapView( mapView1 );
+        mappingService.addMapView( mapView2 );
+        mappingService.addMapView( mapView3 );
+
+        assertEquals( 1, mappingService.getMapViewsByFeatureType( OrganisationUnit.FEATURETYPE_POLYGON ).size() );
+        assertEquals( 2, mappingService.getMapViewsByFeatureType( OrganisationUnit.FEATURETYPE_MULTIPOLYGON ).size() );
+    }
+
+    // -------------------------------------------------------------------------
+    // MapLayer
+    // -------------------------------------------------------------------------
+
+    @Test
+    public void testAddGetMapLayer()
+    {
+        MapLayer mapLayer = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "", "A", 0.1,
+            "B", 1 );
+
+        int id = mappingService.addMapLayer( mapLayer );
+
+        assertEquals( "MapLayerA", mappingService.getMapLayer( id ).getName() );
+        assertEquals( MappingService.MAP_LAYER_TYPE_BASELAYER, mappingService.getMapLayer( id ).getType() );
+        assertEquals( "A", mappingService.getMapLayer( id ).getFillColor() );
+        assertEquals( "B", mappingService.getMapLayer( id ).getStrokeColor() );
+        assertEquals( 0.1, mappingService.getMapLayer( id ).getFillOpacity() );
+        assertEquals( 1, mappingService.getMapLayer( id ).getStrokeWidth() );
+    }
+
+    @Test
+    public void testGetUpdateDeleteMapLayerByName()
+    {
+        MapLayer mapLayer = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "", "A", 0.1,
+            "B", 1 );
+
+        int id = mappingService.addMapLayer( mapLayer );
+
+        mapLayer = mappingService.getMapLayer( id );
+
+        mapLayer.setName( "MapLayerB" );
+        mapLayer.setFillOpacity( 0.05 );
+        mapLayer.setStrokeWidth( 0 );
+
+        mappingService.updateMapLayer( mapLayer );
+
+        assertEquals( "MapLayerB", mappingService.getMapLayerByName( "MapLayerB" ).getName() );
+        assertEquals( 0.05, mappingService.getMapLayerByName( "MapLayerB" ).getFillOpacity() );
+        assertEquals( 0, mappingService.getMapLayerByName( "MapLayerB" ).getStrokeWidth() );
+    }
+
+    @Test
+    public void testGetAllMapLayers()
+    {
+        MapLayer mapLayer1 = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "", "A", 0.1,
+            "B", 1 );
+        MapLayer mapLayer2 = new MapLayer( "MapLayerB", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "", "C", 0.2,
+            "D", 2 );
+        MapLayer mapLayer3 = new MapLayer( "MapLayerC", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "", "E", 0.3,
+            "F", 3 );
+        MapLayer mapLayer4 = new MapLayer( "MapLayerD", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "", "G", 0.4,
+            "H", 4 );
+
+        int idA = mappingService.addMapLayer( mapLayer1 );
+        int idB = mappingService.addMapLayer( mapLayer2 );
+        int idC = mappingService.addMapLayer( mapLayer3 );
+
+        assertEquals( mapLayer1, mappingService.getMapLayer( idA ) );
+        assertEquals( mapLayer2, mappingService.getMapLayer( idB ) );
+        assertEquals( mapLayer3, mappingService.getMapLayer( idC ) );
+        assertTrue( !mappingService.getAllMapLayers().contains( mapLayer4 ) );
+
+    }
+
+    @Test
+    public void testGetMapLayersByTypeOrMapSource()
+    {
+        List<MapLayer> baseLayers = new ArrayList<MapLayer>();
+        List<MapLayer> overlayLayers = new ArrayList<MapLayer>();
+
+        MapLayer mapLayer1 = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "", "A", 0.1,
+            "B", 1 );
+        MapLayer mapLayer2 = new MapLayer( "MapLayerB", MappingService.MAP_LAYER_TYPE_OVERLAY, "", "", "", "C", 0.2,
+            "D", 2 );
+        MapLayer mapLayer3 = new MapLayer( "MapLayerC", MappingService.MAP_LAYER_TYPE_OVERLAY, "", "", "", "E", 0.3,
+            "F", 3 );
+        MapLayer mapLayer4 = new MapLayer( "MapLayerD", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "", "G", 0.4,
+            "H", 4 );
+
+        baseLayers.add( mapLayer1 );
+        baseLayers.add( mapLayer4 );
+
+        overlayLayers.add( mapLayer2 );
+        overlayLayers.add( mapLayer3 );
+
+        mappingService.addMapLayer( mapLayer1 );
+        mappingService.addMapLayer( mapLayer2 );
+        mappingService.addMapLayer( mapLayer3 );
+        mappingService.addMapLayer( mapLayer4 );
+
+        assertEquals( baseLayers, mappingService.getMapLayersByType( MappingService.MAP_LAYER_TYPE_BASELAYER ) );
+        assertEquals( overlayLayers, mappingService.getMapLayersByType( MappingService.MAP_LAYER_TYPE_OVERLAY ) );
+    }
+}

=== modified file 'dhis-2/dhis-services/dhis-service-mapgeneration/pom.xml'
--- dhis-2/dhis-services/dhis-service-mapgeneration/pom.xml	2012-08-03 11:05:49 +0000
+++ dhis-2/dhis-services/dhis-service-mapgeneration/pom.xml	2012-10-24 16:19:29 +0000
@@ -29,10 +29,6 @@
       <groupId>org.hisp.dhis</groupId>
       <artifactId>dhis-service-aggregationengine-default</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.hisp.dhis</groupId>
-      <artifactId>dhis-service-mapping</artifactId>
-    </dependency>
     
     <!-- Other -->
     

=== removed directory 'dhis-2/dhis-services/dhis-service-mapping'
=== removed file 'dhis-2/dhis-services/dhis-service-mapping/pom.xml'
--- dhis-2/dhis-services/dhis-service-mapping/pom.xml	2012-08-22 12:45:25 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/pom.xml	1970-01-01 00:00:00 +0000
@@ -1,44 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0";
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd";>
-  <modelVersion>4.0.0</modelVersion>
-  
-  <parent>
-    <groupId>org.hisp.dhis</groupId>
-    <artifactId>dhis-services</artifactId>
-    <version>2.10-SNAPSHOT</version>
-  </parent>
-  
-  <artifactId>dhis-service-mapping</artifactId>
-  <packaging>jar</packaging>
-  <name>DHIS Mapping Service Implementation</name>
-  
-  <dependencies>
-    
-    <!-- DHIS -->
-    
-    <dependency>
-      <groupId>org.hisp.dhis</groupId>
-      <artifactId>dhis-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.hisp.dhis</groupId>
-      <artifactId>dhis-service-core</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.hisp.dhis</groupId>
-      <artifactId>dhis-service-aggregationengine-default</artifactId>
-    </dependency>
-    
-    <!-- Other -->
-    
-    <dependency>
-      <groupId>commons-logging</groupId>
-      <artifactId>commons-logging</artifactId>
-    </dependency>
-    
-  </dependencies>
-  <properties>
-    <rootDir>../../</rootDir>
-  </properties>
-</project>

=== removed directory 'dhis-2/dhis-services/dhis-service-mapping/src'
=== removed directory 'dhis-2/dhis-services/dhis-service-mapping/src/main'
=== removed directory 'dhis-2/dhis-services/dhis-service-mapping/src/main/java'
=== removed directory 'dhis-2/dhis-services/dhis-service-mapping/src/main/java/org'
=== removed directory 'dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp'
=== removed directory 'dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis'
=== removed directory 'dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping'
=== removed 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	2012-10-24 09:11:47 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java	1970-01-01 00:00:00 +0000
@@ -1,691 +0,0 @@
-package org.hisp.dhis.mapping;
-
-/*
- * Copyright (c) 2004-2012, 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 java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.hisp.dhis.aggregation.AggregatedDataValueService;
-import org.hisp.dhis.aggregation.AggregatedMapValue;
-import org.hisp.dhis.configuration.ConfigurationService;
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementGroup;
-import org.hisp.dhis.dataelement.DataElementService;
-import org.hisp.dhis.indicator.Indicator;
-import org.hisp.dhis.indicator.IndicatorGroup;
-import org.hisp.dhis.indicator.IndicatorService;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.period.Period;
-import org.hisp.dhis.period.PeriodService;
-import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.period.RelativePeriods;
-import org.hisp.dhis.system.util.ConversionUtils;
-import org.hisp.dhis.system.util.MathUtils;
-import org.hisp.dhis.user.CurrentUserService;
-import org.hisp.dhis.user.User;
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * @author Jan Henrik Overland
- */
-@Transactional
-public class DefaultMappingService
-    implements MappingService
-{
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private MapViewStore mapViewStore;
-
-    private MapLayerStore mapLayerStore;
-
-    private MapLegendStore mapLegendStore;
-
-    private MapLegendSetStore mapLegendSetStore;
-
-    public void setMapViewStore( MapViewStore mapViewStore )
-    {
-        this.mapViewStore = mapViewStore;
-    }
-
-    public void setMapLayerStore( MapLayerStore mapLayerStore )
-    {
-        this.mapLayerStore = mapLayerStore;
-    }
-
-    public void setMapLegendStore( MapLegendStore mapLegendStore )
-    {
-        this.mapLegendStore = mapLegendStore;
-    }
-
-    public void setMapLegendSetStore( MapLegendSetStore mapLegendSetStore )
-    {
-        this.mapLegendSetStore = mapLegendSetStore;
-    }
-
-    private OrganisationUnitService organisationUnitService;
-
-    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
-    {
-        this.organisationUnitService = organisationUnitService;
-    }
-
-    private IndicatorService indicatorService;
-
-    public void setIndicatorService( IndicatorService indicatorService )
-    {
-        this.indicatorService = indicatorService;
-    }
-
-    private DataElementService dataElementService;
-
-    public void setDataElementService( DataElementService dataElementService )
-    {
-        this.dataElementService = dataElementService;
-    }
-
-    private PeriodService periodService;
-
-    public void setPeriodService( PeriodService periodService )
-    {
-        this.periodService = periodService;
-    }
-
-    private AggregatedDataValueService aggregatedDataValueService;
-
-    public void setAggregatedDataValueService( AggregatedDataValueService aggregatedDataValueService )
-    {
-        this.aggregatedDataValueService = aggregatedDataValueService;
-    }
-
-    private CurrentUserService currentUserService;
-
-    public void setCurrentUserService( CurrentUserService currentUserService )
-    {
-        this.currentUserService = currentUserService;
-    }
-
-    private ConfigurationService configurationService;
-
-    public void setConfigurationService( ConfigurationService configurationService )
-    {
-        this.configurationService = configurationService;
-    }
-
-    // -------------------------------------------------------------------------
-    // MappingService implementation
-    // -------------------------------------------------------------------------
-
-    // -------------------------------------------------------------------------
-    // OrganisationUnits
-    // -------------------------------------------------------------------------
-
-    /**
-     * Returns the relevant OrganisationUnits for the given parent identifier
-     * and / or level.
-     * 
-     * @param parentOrganisationUnitId the OrganisationUnit level.
-     * @param level the OrganisationUnit level.
-     * @return a collection of OrganisationUnits.
-     */
-    private Collection<OrganisationUnit> getOrganisationUnits( Integer parentOrganisationUnitId, Integer level )
-    {
-        Collection<OrganisationUnit> organisationUnits = null;
-
-        if ( parentOrganisationUnitId != null && level != null )
-        {
-            organisationUnits = organisationUnitService.getOrganisationUnitsAtLevel( level,
-                organisationUnitService.getOrganisationUnit( parentOrganisationUnitId ) );
-        }
-        else if ( level != null )
-        {
-            organisationUnits = organisationUnitService.getOrganisationUnitsAtLevel( level );
-        }
-        else if ( parentOrganisationUnitId != null )
-        {
-            organisationUnits = organisationUnitService.getOrganisationUnit( parentOrganisationUnitId ).getChildren();
-        }
-
-        return organisationUnits;
-    }
-
-    // -------------------------------------------------------------------------
-    // IndicatorMapValues
-    // -------------------------------------------------------------------------
-
-    /**
-     * Generates a collection AggregatedMapValues. Only one of Period and
-     * start/end date can be specified. At least one of parent organisation unit
-     * and level must be specified. Period should be specified with "real time"
-     * aggregation strategy, any may be specified with "batch" aggregation
-     * strategy.
-     * 
-     * @param indicatorId the Indicator identifier.
-     * @param periodId the Period identifier. Ignored if null.
-     * @param parentOrganisationUnitId the parent OrganisationUnit identifier.
-     *        Ignored if null.
-     * @param level the OrganisationUnit level. Ignored if null.
-     * @return a collection of AggregatedMapValues.
-     */
-    public Collection<AggregatedMapValue> getIndicatorMapValues( int indicatorId, int periodId,
-        int parentOrganisationUnitId, Integer level )
-    {
-        Collection<OrganisationUnit> units = getOrganisationUnits( parentOrganisationUnitId, level );
-
-        return getIndicatorMapValues( indicatorId, periodId, units );
-    }
-
-    public Collection<AggregatedMapValue> getIndicatorMapValues( int indicatorId, int periodId,
-        Collection<OrganisationUnit> units )
-    {
-        Collection<AggregatedMapValue> values = aggregatedDataValueService.getAggregatedIndicatorMapValues(
-            indicatorId, periodId, ConversionUtils.getIdentifiers( OrganisationUnit.class, units ) );
-
-        for ( AggregatedMapValue value : values )
-        {
-            value.setValue( MathUtils.getRounded( value.getValue(), 2 ) );
-        }
-
-        return values;
-    }
-
-    // -------------------------------------------------------------------------
-    // DataElementMapValues
-    // -------------------------------------------------------------------------
-
-    /**
-     * Generates a collection AggregatedMapValues. Only one of Period and
-     * start/end date can be specified. At least one of parent organisation unit
-     * and level must be specified. Period should be specified with "real time"
-     * aggregation strategy, any may be specified with "batch" aggregation
-     * strategy.
-     * 
-     * @param dataElementId the DataElement identifier.
-     * @param periodId the Period identifier. Ignored if null.
-     * @param parentOrganisationUnitId the parent OrganisationUnit identifier.
-     *        Ignored if null.
-     * @param level the OrganisationUnit level. Ignored if null.
-     * @return a collection of AggregatedMapValues.
-     */
-    public Collection<AggregatedMapValue> getDataElementMapValues( int dataElementId, int periodId,
-        int parentOrganisationUnitId, Integer level )
-    {
-        Collection<OrganisationUnit> units = getOrganisationUnits( parentOrganisationUnitId, level );
-
-        return getDataElementMapValues( dataElementId, periodId, units );
-    }
-
-    public Collection<AggregatedMapValue> getDataElementMapValues( int dataElementId, int periodId,
-        Collection<OrganisationUnit> units )
-    {
-        Collection<AggregatedMapValue> values = aggregatedDataValueService.getAggregatedDataMapValues( dataElementId,
-            periodId, ConversionUtils.getIdentifiers( OrganisationUnit.class, units ) );
-
-        for ( AggregatedMapValue value : values )
-        {
-            value.setValue( MathUtils.getRounded( value.getValue(), 2 ) );
-        }
-
-        return values;
-    }
-
-    public Collection<AggregatedMapValue> getInfrastructuralDataElementMapValues( Integer periodId,
-        Integer organisationUnitId )
-    {
-        DataElementGroup group = configurationService.getConfiguration().getInfrastructuralDataElements();
-
-        if ( group == null )
-        {
-            return new HashSet<AggregatedMapValue>();
-        }
-
-        Collection<Integer> dataElementIds = ConversionUtils.getIdentifiers( DataElement.class, group.getMembers() );
-
-        return aggregatedDataValueService.getAggregatedDataMapValues( dataElementIds, periodId, organisationUnitId );
-    }
-
-    // -------------------------------------------------------------------------
-    // MapLegend
-    // -------------------------------------------------------------------------
-
-    public void addOrUpdateMapLegend( String name, Double startValue, Double endValue, String color, String image )
-    {
-        MapLegend mapLegend = getMapLegendByName( name );
-
-        if ( mapLegend != null )
-        {
-            mapLegend.setName( name );
-            mapLegend.setStartValue( startValue );
-            mapLegend.setEndValue( endValue );
-            mapLegend.setColor( color );
-            mapLegend.setImage( image );
-
-            mapLegendStore.update( mapLegend );
-        }
-        else
-        {
-            mapLegend = new MapLegend( name, startValue, endValue, color, image );
-
-            mapLegendStore.save( mapLegend );
-        }
-    }
-
-    public int addMapLegend( MapLegend mapLegend )
-    {
-        return mapLegendStore.save( mapLegend );
-    }
-    
-    public void deleteMapLegend( MapLegend mapLegend )
-    {
-        mapLegendStore.delete( mapLegend );
-    }
-
-    public MapLegend getMapLegend( int id )
-    {
-        return mapLegendStore.get( id );
-    }
-
-    @Override
-    public MapLegend getMapLegend( String uid )
-    {
-        return mapLegendStore.getByUid( uid );
-    }
-
-    public MapLegend getMapLegendByName( String name )
-    {
-        return mapLegendStore.getByName( name );
-    }
-
-    public Collection<MapLegend> getAllMapLegends()
-    {
-        return mapLegendStore.getAll();
-    }
-
-    // -------------------------------------------------------------------------
-    // MapLegendSet
-    // -------------------------------------------------------------------------
-
-    public int addMapLegendSet( MapLegendSet mapLegendSet )
-    {
-        return mapLegendSetStore.save( mapLegendSet );
-    }
-
-    public void updateMapLegendSet( MapLegendSet mapLegendSet )
-    {
-        mapLegendSetStore.update( mapLegendSet );
-    }
-
-    public void addOrUpdateMapLegendSet( String name, String type, String symbolizer, Set<MapLegend> mapLegends )
-    {
-        MapLegendSet mapLegendSet = getMapLegendSetByName( name );
-
-        Set<Indicator> indicators = new HashSet<Indicator>();
-
-        Set<DataElement> dataElements = new HashSet<DataElement>();
-
-        if ( mapLegendSet != null )
-        {
-            mapLegendSet.setType( type );
-            mapLegendSet.setSymbolizer( symbolizer );
-            mapLegendSet.setMapLegends( mapLegends );
-            mapLegendSet.setIndicators( indicators );
-            mapLegendSet.setDataElements( dataElements );
-
-            mapLegendSetStore.update( mapLegendSet );
-        }
-        else
-        {
-            mapLegendSet = new MapLegendSet( name, type, symbolizer, mapLegends, indicators, dataElements );
-
-            mapLegendSetStore.save( mapLegendSet );
-        }
-    }
-
-    public void deleteMapLegendSet( MapLegendSet mapLegendSet )
-    {
-        mapLegendSetStore.delete( mapLegendSet );
-    }
-
-    public MapLegendSet getMapLegendSet( int id )
-    {
-        return mapLegendSetStore.get( id );
-    }
-
-    @Override
-    public MapLegendSet getMapLegendSet( String uid )
-    {
-        return mapLegendSetStore.getByUid( uid );
-    }
-
-    public MapLegendSet getMapLegendSetByName( String name )
-    {
-        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
-    // -------------------------------------------------------------------------
-
-    public int addMapView( MapView mapView )
-    {
-        return mapViewStore.save( mapView );
-    }
-
-    public void addMapView( String name, boolean system, String mapValueType, Integer indicatorGroupId,
-        Integer indicatorId, Integer dataElementGroupId, Integer dataElementId, String periodTypeName,
-        Integer periodId, Integer parentOrganisationUnitId, Integer organisationUnitLevel, String mapLegendType,
-        Integer method, Integer classes, String bounds, String colorLow, String colorHigh, Integer mapLegendSetId,
-        Integer radiusLow, Integer radiusHigh, String longitude, String latitude, int zoom )
-    {
-        User user = system ? null : currentUserService.getCurrentUser();
-
-        IndicatorGroup indicatorGroup = null;
-
-        Indicator indicator = null;
-
-        DataElementGroup dataElementGroup = null;
-
-        DataElement dataElement = null;
-
-        if ( mapValueType.equals( MappingService.MAP_VALUE_TYPE_INDICATOR ) )
-        {
-            indicatorGroup = indicatorService.getIndicatorGroup( indicatorGroupId );
-            indicator = indicatorService.getIndicator( indicatorId );
-        }
-        else
-        {
-            dataElementGroup = dataElementService.getDataElementGroup( dataElementGroupId );
-            dataElement = dataElementService.getDataElement( dataElementId );
-        }
-
-        PeriodType periodType = periodTypeName != null && !periodTypeName.isEmpty() ? periodService
-            .getPeriodTypeByClass( PeriodType.getPeriodTypeByName( periodTypeName ).getClass() ) : null;
-
-        Period period = periodId != null ? periodService.getPeriod( periodId ) : null;
-
-        OrganisationUnit parent = organisationUnitService.getOrganisationUnit( parentOrganisationUnitId );
-
-        OrganisationUnitLevel level = organisationUnitService.getOrganisationUnitLevelByLevel( organisationUnitLevel );
-
-        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,
-            mapLegendSet, radiusLow, radiusHigh, longitude, latitude, zoom ) );
-    }
-
-    public void updateMapView( MapView mapView )
-    {
-        mapViewStore.update( mapView );
-    }
-
-    public void deleteMapView( MapView mapView )
-    {
-        mapViewStore.delete( mapView );
-    }
-
-    public MapView getMapView( int id )
-    {
-        MapView mapView = mapViewStore.get( id );
-
-        setMapViewLevel( mapView );
-
-        return mapView;
-    }
-
-    public MapView getMapView( String uid )
-    {
-        MapView mapView = mapViewStore.getByUid( uid );
-
-        setMapViewLevel( mapView );
-
-        return mapView;
-    }
-
-    private void setMapViewLevel( MapView mapView )
-    {
-        if ( mapView != null )
-        {
-            mapView.getParentOrganisationUnit().setLevel(
-                organisationUnitService.getLevelOfOrganisationUnit( mapView.getParentOrganisationUnit().getId() ) );
-        }
-    }
-
-    public MapView getMapViewByName( String name )
-    {
-        return mapViewStore.getByName( name );
-    }
-
-    public MapView getIndicatorLastYearMapView( String indicatorUid, String organisationUnitUid, int level )
-    {
-        MapView mapView = new MapView();
-
-        Period period = periodService.reloadPeriod( new RelativePeriods().setThisYear( true ).getRelativePeriods()
-            .iterator().next() );
-
-        Indicator indicator = indicatorService.getIndicator( indicatorUid );
-        OrganisationUnit unit = organisationUnitService.getOrganisationUnit( organisationUnitUid );
-
-        mapView.setIndicator( indicator );
-        mapView.setPeriod( period );
-        mapView.setParentOrganisationUnit( unit );
-        mapView.setOrganisationUnitLevel( new OrganisationUnitLevel( level, "" ) );
-        mapView.setName( indicator.getName() );
-        mapView.setMapValueType( MappingService.MAP_VALUE_TYPE_INDICATOR );
-
-        return mapView;
-    }
-
-    public Collection<MapView> getSystemAndUserMapViews()
-    {
-        User user = currentUserService.getCurrentUser();
-        
-        return mapViewStore.getSystemAndUserMapViews( user );
-    }
-    
-    public Collection<MapView> getAllMapViews()
-    {
-        Collection<MapView> mapViews = mapViewStore.getAll();
-
-        if ( mapViews.size() > 0 )
-        {
-            for ( MapView mapView : mapViews )
-            {
-                mapView.getParentOrganisationUnit().setLevel(
-                    organisationUnitService.getLevelOfOrganisationUnit( mapView.getParentOrganisationUnit().getId() ) );
-            }
-        }
-
-        return mapViews;
-    }
-
-    public Collection<MapView> getMapViewsByFeatureType( String featureType )
-    {
-        User user = currentUserService.getCurrentUser();
-
-        Collection<MapView> mapViews = mapViewStore.getMapViewsByFeatureType( featureType, user );
-
-        for ( MapView mapView : mapViews )
-        {
-            mapView.getParentOrganisationUnit().setLevel(
-                organisationUnitService.getLevelOfOrganisationUnit( mapView.getParentOrganisationUnit().getId() ) );
-        }
-
-        return mapViews;
-    }
-    
-    public Collection<MapView> getMapViewsByUser( User user )
-    {
-        return mapViewStore.getByUser( user );
-    }
-    
-    public Collection<MapView> getMapViewsBetweenByName( String name, int first, int max )
-    {
-        return mapViewStore.getBetweenByName( name, first, max );
-    }
-
-    // -------------------------------------------------------------------------
-    // MapLayer
-    // -------------------------------------------------------------------------
-
-    public int addMapLayer( MapLayer mapLayer )
-    {
-        return mapLayerStore.save( mapLayer );
-    }
-
-    public void updateMapLayer( MapLayer mapLayer )
-    {
-        mapLayerStore.update( mapLayer );
-    }
-
-    public void addOrUpdateMapLayer( String name, String type, String url, String layers, String time,
-        String fillColor, double fillOpacity, String strokeColor, int strokeWidth )
-    {
-        MapLayer mapLayer = mapLayerStore.getByName( name );
-
-        if ( mapLayer != null )
-        {
-            mapLayer.setName( name );
-            mapLayer.setType( type );
-            mapLayer.setUrl( url );
-            mapLayer.setLayers( layers );
-            mapLayer.setTime( time );
-            mapLayer.setFillColor( fillColor );
-            mapLayer.setFillOpacity( fillOpacity );
-            mapLayer.setStrokeColor( strokeColor );
-            mapLayer.setStrokeWidth( strokeWidth );
-
-            updateMapLayer( mapLayer );
-        }
-        else
-        {
-            addMapLayer( new MapLayer( name, type, url, layers, time, fillColor, fillOpacity, strokeColor, strokeWidth ) );
-        }
-    }
-
-    public void deleteMapLayer( MapLayer mapLayer )
-    {
-        mapLayerStore.delete( mapLayer );
-    }
-
-    public MapLayer getMapLayer( int id )
-    {
-        return mapLayerStore.get( id );
-    }
-
-    @Override
-    public MapLayer getMapLayer( String uid )
-    {
-        return mapLayerStore.getByUid( uid );
-    }
-
-    public MapLayer getMapLayerByName( String name )
-    {
-        return mapLayerStore.getByName( name );
-    }
-
-    public Collection<MapLayer> getMapLayersByType( String type )
-    {
-        return mapLayerStore.getMapLayersByType( type );
-    }
-
-    public MapLayer getMapLayerByMapSource( String mapSource )
-    {
-        return mapLayerStore.getMapLayerByMapSource( mapSource );
-    }
-
-    public Collection<MapLayer> getAllMapLayers()
-    {
-        return mapLayerStore.getAll();
-    }
-}

=== removed file 'dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/MapLegendSetDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/MapLegendSetDeletionHandler.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/MapLegendSetDeletionHandler.java	1970-01-01 00:00:00 +0000
@@ -1,97 +0,0 @@
-package org.hisp.dhis.mapping;
-
-/*
- * Copyright (c) 2004-2012, 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.dataelement.DataElement;
-import org.hisp.dhis.indicator.Indicator;
-import org.hisp.dhis.system.deletion.DeletionHandler;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class MapLegendSetDeletionHandler
-    extends DeletionHandler
-{
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private MappingService mappingService;
-
-    public void setMappingService( MappingService mappingService )
-    {
-        this.mappingService = mappingService;
-    }
-
-    // -------------------------------------------------------------------------
-    // DeletionHandler implementation
-    // -------------------------------------------------------------------------
-
-    @Override
-    protected String getClassName()
-    {
-        return MapLegendSet.class.getSimpleName();
-    }
-    
-    @Override
-    public void deleteMapLegend( MapLegend mapLegend )
-    {
-        for ( MapLegendSet legendSet : mappingService.getAllMapLegendSets() )
-        {
-            if ( legendSet.getMapLegends().remove( mapLegend ) )
-            {
-                mappingService.updateMapLegendSet( legendSet );
-            }
-        }
-    }
-    
-    @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 );
-            }
-        }
-    }
-}

=== removed file 'dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/MapViewDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/MapViewDeletionHandler.java	2012-07-01 11:33:07 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/MapViewDeletionHandler.java	1970-01-01 00:00:00 +0000
@@ -1,167 +0,0 @@
-package org.hisp.dhis.mapping;
-
-/*
- * Copyright (c) 2004-2012, 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 java.util.Iterator;
-
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementGroup;
-import org.hisp.dhis.indicator.Indicator;
-import org.hisp.dhis.indicator.IndicatorGroup;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.period.Period;
-import org.hisp.dhis.system.deletion.DeletionHandler;
-import org.hisp.dhis.user.User;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class MapViewDeletionHandler
-    extends DeletionHandler
-{
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private MappingService mappingService;
-
-    public void setMappingService( MappingService mappingService )
-    {
-        this.mappingService = mappingService;
-    }
-
-    // -------------------------------------------------------------------------
-    // DeletionHandler implementation
-    // -------------------------------------------------------------------------
-
-    @Override
-    protected String getClassName()
-    {
-        return MapView.class.getName();
-    }
-    
-    @Override
-    public String allowDeletePeriod( Period period )
-    {
-        for ( MapView mapView : mappingService.getAllMapViews() )
-        {
-            if ( mapView.getPeriod().equals( period ) )
-            {
-                return mapView.getName();
-            }
-        }
-        
-        return null;
-    }
-    
-    @Override
-    public void deleteIndicatorGroup( IndicatorGroup indicatorGroup )
-    {
-        for ( MapView mapView : mappingService.getAllMapViews() )
-        {
-            if ( mapView.getIndicatorGroup() != null && mapView.getIndicatorGroup().equals( indicatorGroup ) )
-            {
-                mappingService.deleteMapView( mapView );
-            }
-        }
-    }
-    
-    @Override
-    public void deleteIndicator( Indicator indicator )
-    {
-        for ( MapView mapView : mappingService.getAllMapViews() )
-        {
-            if ( mapView.getIndicator() != null && mapView.getIndicator().equals( indicator ) )
-            {
-                mappingService.deleteMapView( mapView );
-            }
-        }
-    }
-    
-    @Override
-    public void deleteDataElementGroup( DataElementGroup dataElementGroup )
-    {
-        for ( MapView mapView : mappingService.getAllMapViews() )
-        {
-            if ( mapView.getDataElementGroup() != null && mapView.getDataElementGroup().equals( dataElementGroup ) )
-            {
-                mappingService.deleteMapView( mapView );
-            }
-        }
-    }
-    
-    @Override
-    public void deleteDataElement( DataElement dataElement )
-    {
-        for ( MapView mapView : mappingService.getAllMapViews() )
-        {
-            if ( mapView.getDataElement() != null && mapView.getDataElement().equals( dataElement ) )
-            {
-                mappingService.deleteMapView( mapView );
-            }
-        }
-    }
-    
-    @Override
-    public void deleteOrganisationUnit( OrganisationUnit organisationUnit )
-    {
-        for ( MapView mapView : mappingService.getAllMapViews() )
-        {
-            if ( mapView.getParentOrganisationUnit() != null && mapView.getParentOrganisationUnit().equals( organisationUnit ) )
-            {
-                mappingService.deleteMapView( mapView );
-            }
-        }
-    }
-    
-    @Override
-    public void deleteMapLegendSet( MapLegendSet mapLegendSet )
-    {
-        for ( MapView mapView : mappingService.getAllMapViews() )
-        {
-            if ( mapView.getMapLegendSet() != null && mapView.getMapLegendSet().equals( mapLegendSet ) )
-            {
-                mappingService.deleteMapView( mapView );
-            }
-        }
-    }
-    
-    @Override
-    public void deleteUser( User user )
-    {
-        Iterator<MapView> iterator = mappingService.getMapViewsByUser( user ).iterator();
-        
-        while ( iterator.hasNext() )
-        {
-            MapView mapView = iterator.next();
-            iterator.remove();
-            mappingService.deleteMapView( mapView );
-        }
-    }
-}

=== removed directory 'dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate'
=== removed file 'dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapLayerStore.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapLayerStore.java	2012-03-22 12:34:46 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapLayerStore.java	1970-01-01 00:00:00 +0000
@@ -1,80 +0,0 @@
-package org.hisp.dhis.mapping.hibernate;
-
-/*
- * Copyright (c) 2004-2012, 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.hibernate.Criteria;
-import org.hibernate.Session;
-import org.hibernate.criterion.Restrictions;
-import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
-import org.hisp.dhis.mapping.MapLayer;
-import org.hisp.dhis.mapping.MapLayerStore;
-
-import java.util.Collection;
-
-/**
- * @author Jan Henrik Overland
- */
-public class HibernateMapLayerStore
-    extends HibernateIdentifiableObjectStore<MapLayer>
-    implements MapLayerStore
-{
-    @SuppressWarnings( "unchecked" )
-    public Collection<MapLayer> getMapLayersByType( String type )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( MapLayer.class );
-
-        criteria.add( Restrictions.eq( "type", type ) );
-
-        return criteria.list();
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public Collection<MapLayer> getMapLayersByMapSourceType( String mapSourceType )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( MapLayer.class );
-
-        criteria.add( Restrictions.eq( "mapSourceType", mapSourceType ) );
-
-        return criteria.list();
-    }
-
-    public MapLayer getMapLayerByMapSource( String mapSource )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( MapLayer.class );
-
-        criteria.add( Restrictions.eq( "mapSource", mapSource ) );
-
-        return (MapLayer) criteria.uniqueResult();
-    }
-}

=== removed file 'dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapLegendSetStore.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapLegendSetStore.java	2012-03-22 12:34:46 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapLegendSetStore.java	1970-01-01 00:00:00 +0000
@@ -1,57 +0,0 @@
-package org.hisp.dhis.mapping.hibernate;
-
-/*
- * Copyright (c) 2004-2012, 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.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
- */
-public class HibernateMapLegendSetStore
-    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();
-    }
-}

=== removed file 'dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapLegendStore.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapLegendStore.java	2012-03-22 12:34:46 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapLegendStore.java	1970-01-01 00:00:00 +0000
@@ -1,41 +0,0 @@
-package org.hisp.dhis.mapping.hibernate;
-
-/*
- * Copyright (c) 2004-2012, 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.common.hibernate.HibernateIdentifiableObjectStore;
-import org.hisp.dhis.mapping.MapLegend;
-import org.hisp.dhis.mapping.MapLegendStore;
-
-/**
- * @author Jan Henrik Overland
- */
-public class HibernateMapLegendStore
-    extends HibernateIdentifiableObjectStore<MapLegend>
-    implements MapLegendStore
-{
-}

=== removed file 'dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapViewStore.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapViewStore.java	2012-04-29 18:04:08 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapViewStore.java	1970-01-01 00:00:00 +0000
@@ -1,80 +0,0 @@
-package org.hisp.dhis.mapping.hibernate;
-
-/*
- * Copyright (c) 2004-2012, 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.hibernate.Criteria;
-import org.hibernate.Session;
-import org.hibernate.criterion.Restrictions;
-import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
-import org.hisp.dhis.mapping.MapView;
-import org.hisp.dhis.mapping.MapViewStore;
-import org.hisp.dhis.user.User;
-
-import java.util.Collection;
-
-/**
- * @author Jan Henrik Overland
- */
-public class HibernateMapViewStore
-    extends HibernateIdentifiableObjectStore<MapView>
-    implements MapViewStore
-{
-    @SuppressWarnings( "unchecked" )
-    public Collection<MapView> getSystemAndUserMapViews( User user )
-    {
-        return getCriteria( 
-            Restrictions.or( Restrictions.isNull( "user" ), 
-            Restrictions.eq( "user", user ) ) ).list();
-    }
-    
-    @SuppressWarnings( "unchecked" )
-    public Collection<MapView> getMapViewsByMapSourceType( String mapSourceType )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( MapView.class );
-
-        criteria.add( Restrictions.eq( "mapSourceType", mapSourceType ) );
-
-        return criteria.list();
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public Collection<MapView> getMapViewsByFeatureType( String featureType, User user )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( MapView.class );
-
-        criteria.add( Restrictions.eq( "featureType", featureType ) );
-
-        criteria.add( Restrictions.or( Restrictions.eq( "user", user ), Restrictions.isNull( "user" ) ) );
-
-        return criteria.list();
-    }
-}

=== removed directory 'dhis-2/dhis-services/dhis-service-mapping/src/main/resources'
=== removed directory 'dhis-2/dhis-services/dhis-service-mapping/src/main/resources/META-INF'
=== removed directory 'dhis-2/dhis-services/dhis-service-mapping/src/main/resources/META-INF/dhis'
=== removed file 'dhis-2/dhis-services/dhis-service-mapping/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/resources/META-INF/dhis/beans.xml	2012-04-29 18:04:08 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/resources/META-INF/dhis/beans.xml	1970-01-01 00:00:00 +0000
@@ -1,95 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans";
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-    xmlns:aop="http://www.springframework.org/schema/aop";
-    xsi:schemaLocation="
-http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
-http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd";>
-
-  <!-- Service definitions -->
-
-  <bean id="org.hisp.dhis.mapping.MappingService"
-      class="org.hisp.dhis.mapping.DefaultMappingService">
-    <property name="mapViewStore" ref="org.hisp.dhis.mapping.MapViewStore" />
-    <property name="mapLayerStore" ref="org.hisp.dhis.mapping.MapLayerStore" />
-    <property name="mapLegendStore" ref="org.hisp.dhis.mapping.MapLegendStore" />
-    <property name="mapLegendSetStore" ref="org.hisp.dhis.mapping.MapLegendSetStore" />
-    <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
-    <property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
-    <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
-    <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
-    <property name="aggregatedDataValueService" ref="org.hisp.dhis.aggregation.AggregatedDataValueService" />
-    <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
-    <property name="configurationService" ref="org.hisp.dhis.configuration.ConfigurationService" />
-  </bean>
-
-  <!-- Store definitions -->
-
-  <bean id="org.hisp.dhis.mapping.MapViewStore"
-      class="org.hisp.dhis.mapping.hibernate.HibernateMapViewStore">
-    <property name="clazz" value="org.hisp.dhis.mapping.MapView" />
-    <property name="sessionFactory" ref="sessionFactory" />
-  </bean>
-
-  <bean id="org.hisp.dhis.mapping.MapLayerStore"
-      class="org.hisp.dhis.mapping.hibernate.HibernateMapLayerStore">
-    <property name="clazz" value="org.hisp.dhis.mapping.MapLayer" />
-    <property name="sessionFactory" ref="sessionFactory" />
-  </bean>
-
-  <bean id="org.hisp.dhis.mapping.MapLegendStore"
-      class="org.hisp.dhis.mapping.hibernate.HibernateMapLegendStore">
-    <property name="clazz" value="org.hisp.dhis.mapping.MapLegend" />
-    <property name="sessionFactory" ref="sessionFactory" />
-  </bean>
-
-  <bean id="org.hisp.dhis.mapping.MapLegendSetStore"
-      class="org.hisp.dhis.mapping.hibernate.HibernateMapLegendSetStore">
-    <property name="clazz" value="org.hisp.dhis.mapping.MapLegendSet" />
-    <property name="sessionFactory" ref="sessionFactory" />
-  </bean>
-
-  <!-- DeletionHandlers -->
-
-  <bean id="org.hisp.dhis.mapping.MapLegendSetDeletionHandler"
-      class="org.hisp.dhis.mapping.MapLegendSetDeletionHandler">
-    <property name="mappingService"
-        ref="org.hisp.dhis.mapping.MappingService" />
-  </bean>
-
-  <bean id="org.hisp.dhis.mapping.MapViewDeletionHandler"
-      class="org.hisp.dhis.mapping.MapViewDeletionHandler">
-    <property name="mappingService"
-        ref="org.hisp.dhis.mapping.MappingService" />
-  </bean>
-
-  <!-- DeletionManager -->
-
-  <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
-    <property name="targetObject" ref="deletionManager" />
-    <property name="targetMethod" value="addDeletionHandlers" />
-    <property name="arguments">
-      <list>
-        <list>
-          <ref local="org.hisp.dhis.mapping.MapLegendSetDeletionHandler" />
-          <ref local="org.hisp.dhis.mapping.MapViewDeletionHandler" />
-        </list>
-      </list>
-    </property>
-  </bean>
-
-  <!-- Deletion AOP definitions -->
-
-  <aop:config>
-
-    <aop:aspect ref="deletionInterceptor">
-      <aop:before pointcut="execution( * org.hisp.dhis.mapping.MappingService.deleteMapLegend(..) )"
-          method="intercept" />
-      <aop:before pointcut="execution( * org.hisp.dhis.mapping.MappingService.deleteMapLegendSet(..) )"
-          method="intercept" />
-      <aop:before pointcut="execution( * org.hisp.dhis.mapping.MappingService.deleteMapView(..) )" method="intercept" />
-    </aop:aspect>
-
-  </aop:config>
-
-</beans>

=== removed directory 'dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org'
=== removed directory 'dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp'
=== removed directory 'dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis'
=== removed directory 'dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping'
=== removed directory 'dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate'
=== removed file 'dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLayer.hbm.xml'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLayer.hbm.xml	2012-03-19 22:10:02 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLayer.hbm.xml	1970-01-01 00:00:00 +0000
@@ -1,33 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
-  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-  "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd";
-  [<!ENTITY identifiableProperties SYSTEM "classpath://org/hisp/dhis/common/identifiableProperties.hbm">]
->
-
-<hibernate-mapping>
-  <class name="org.hisp.dhis.mapping.MapLayer" table="maplayer">
-
-    <id name="id" column="maplayerid">
-      <generator class="native" />
-    </id>
-    &identifiableProperties;
-
-    <property name="type" column="type" />
-
-    <property name="url" column="url" type="text" />
-
-    <property name="layers" column="layers" type="text" />
-
-    <property name="time" column="time" type="text" />
-
-    <property name="fillColor" column="fillcolor" />
-
-    <property name="fillOpacity" column="fillopacity" not-null="true" />
-
-    <property name="strokeColor" column="strokecolor" />
-
-    <property name="strokeWidth" column="strokewidth" not-null="true" />
-
-  </class>
-</hibernate-mapping>

=== removed file 'dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLegend.hbm.xml'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLegend.hbm.xml	2012-03-19 18:32:42 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLegend.hbm.xml	1970-01-01 00:00:00 +0000
@@ -1,25 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
-  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-  "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd";
-  [<!ENTITY identifiableProperties SYSTEM "classpath://org/hisp/dhis/common/identifiableProperties.hbm">]
->
-
-<hibernate-mapping>
-  <class name="org.hisp.dhis.mapping.MapLegend" table="maplegend">
-
-    <id name="id" column="maplegendid">
-      <generator class="native" />
-    </id>
-    &identifiableProperties;
-
-    <property name="startValue" column="startvalue" />
-
-    <property name="endValue" column="endvalue" />
-
-    <property name="color" column="color" />
-
-    <property name="image" column="image" />
-
-  </class>
-</hibernate-mapping>

=== removed 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	2012-03-19 18:32:42 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLegendSet.hbm.xml	1970-01-01 00:00:00 +0000
@@ -1,36 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
-  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-  "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd";
-  [<!ENTITY identifiableProperties SYSTEM "classpath://org/hisp/dhis/common/identifiableProperties.hbm">]
->
-
-<hibernate-mapping>
-  <class name="org.hisp.dhis.mapping.MapLegendSet" table="maplegendset">
-
-    <id name="id" column="maplegendsetid">
-      <generator class="native" />
-    </id>
-    &identifiableProperties;
-
-    <property name="type" column="type" />
-
-    <property name="symbolizer" column="symbolizer" />
-
-    <set name="mapLegends" table="maplegendsetmaplegend">
-      <key column="legendsetid" foreign-key="fk_maplegendsetmaplegend_legendsetid" />
-      <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>

=== removed file 'dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml	2012-03-26 13:00:42 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml	1970-01-01 00:00:00 +0000
@@ -1,69 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
-  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-  "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd";
-  [<!ENTITY identifiableProperties SYSTEM "classpath://org/hisp/dhis/common/identifiableProperties.hbm">]
->
-
-<hibernate-mapping>
-  <class name="org.hisp.dhis.mapping.MapView" table="mapview">
-
-    <id name="id" column="mapviewid">
-      <generator class="native" />
-    </id>
-    &identifiableProperties;
-
-    <many-to-one name="user" class="org.hisp.dhis.user.User" column="userid" foreign-key="fk_mapview_userid" />
-
-    <property name="mapValueType" />
-
-    <many-to-one name="indicatorGroup" class="org.hisp.dhis.indicator.IndicatorGroup" column="indicatorgroupid"
-      foreign-key="fk_mapview_indicatorgroupid" />
-
-    <many-to-one name="indicator" class="org.hisp.dhis.indicator.Indicator" column="indicatorid"
-      foreign-key="fk_mapview_indicatorid" />
-
-    <many-to-one name="dataElementGroup" class="org.hisp.dhis.dataelement.DataElementGroup" column="dataelementgroupid"
-      foreign-key="fk_mapview_dataelementgroupid" />
-
-    <many-to-one name="dataElement" class="org.hisp.dhis.dataelement.DataElement" column="dataelementid"
-      foreign-key="fk_mapview_dataelementid" />
-
-    <many-to-one name="periodType" class="org.hisp.dhis.period.PeriodType" column="periodtypeid"
-      foreign-key="fk_mapview_periodtypeid" />
-
-    <many-to-one name="period" class="org.hisp.dhis.period.Period" column="periodid" foreign-key="fk_mapview_periodid" />
-
-    <many-to-one name="parentOrganisationUnit" class="org.hisp.dhis.organisationunit.OrganisationUnit"
-      column="parentorganisationunitid" foreign-key="fk_mapview_parentorganisationunitid" />
-
-    <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" />
-
-    <property name="bounds" />
-
-    <property name="colorLow" />
-
-    <property name="colorHigh" />
-
-    <many-to-one name="mapLegendSet" class="org.hisp.dhis.mapping.MapLegendSet" column="maplegendsetid"
-      foreign-key="fk_mapview_maplegendsetid" />
-
-    <property name="radiusLow" />
-
-    <property name="radiusHigh" />
-
-    <property name="longitude" />
-
-    <property name="latitude" />
-
-    <property name="zoom" />
-
-  </class>
-</hibernate-mapping>

=== removed directory 'dhis-2/dhis-services/dhis-service-mapping/src/test'
=== removed directory 'dhis-2/dhis-services/dhis-service-mapping/src/test/java'
=== removed directory 'dhis-2/dhis-services/dhis-service-mapping/src/test/java/org'
=== removed directory 'dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp'
=== removed directory 'dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis'
=== removed directory 'dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping'
=== removed file 'dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java	2012-03-26 13:00:42 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java	1970-01-01 00:00:00 +0000
@@ -1,507 +0,0 @@
-package org.hisp.dhis.mapping;
-
-/*
- * Copyright (c) 2004-2012, 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 static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertNull;
-import static junit.framework.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-
-import org.hisp.dhis.DhisSpringTest;
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementGroup;
-import org.hisp.dhis.dataelement.DataElementService;
-import org.hisp.dhis.indicator.Indicator;
-import org.hisp.dhis.indicator.IndicatorGroup;
-import org.hisp.dhis.indicator.IndicatorService;
-import org.hisp.dhis.indicator.IndicatorType;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.period.MonthlyPeriodType;
-import org.hisp.dhis.period.Period;
-import org.hisp.dhis.period.PeriodService;
-import org.hisp.dhis.period.PeriodType;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class MappingServiceTest
-    extends DhisSpringTest
-{
-    private MappingService mappingService;
-
-    private OrganisationUnit organisationUnit;
-
-    private OrganisationUnitLevel organisationUnitLevel;
-
-    private IndicatorGroup indicatorGroup;
-
-    private IndicatorType indicatorType;
-
-    private Indicator indicator;
-
-    private DataElement dataElement;
-
-    private DataElementGroup dataElementGroup;
-
-    private PeriodType periodType;
-
-    private Period period;
-
-    private MapLegendSet mapLegendSet;
-
-    // -------------------------------------------------------------------------
-    // Fixture
-    // -------------------------------------------------------------------------
-
-    @Override
-    public void setUpTest()
-    {
-        mappingService = (MappingService) getBean( MappingService.ID );
-
-        organisationUnitService = (OrganisationUnitService) getBean( OrganisationUnitService.ID );
-
-        indicatorService = (IndicatorService) getBean( IndicatorService.ID );
-
-        dataElementService = (DataElementService) getBean( DataElementService.ID );
-
-        periodService = (PeriodService) getBean( PeriodService.ID );
-
-        organisationUnit = createOrganisationUnit( 'A' );
-        organisationUnitLevel = new OrganisationUnitLevel( 1, "Level" );
-
-        organisationUnitService.addOrganisationUnit( organisationUnit );
-        organisationUnitService.addOrganisationUnitLevel( organisationUnitLevel );
-
-        indicatorGroup = createIndicatorGroup( 'A' );
-        indicatorService.addIndicatorGroup( indicatorGroup );
-
-        indicatorType = createIndicatorType( 'A' );
-        indicatorService.addIndicatorType( indicatorType );
-
-        indicator = createIndicator( 'A', indicatorType );
-        indicatorService.addIndicator( indicator );
-
-        dataElement = createDataElement( 'A' );
-        dataElementService.addDataElement( dataElement );
-
-        dataElementGroup = createDataElementGroup( 'A' );
-        dataElementGroup.getMembers().add( dataElement );
-        dataElementService.addDataElementGroup( dataElementGroup );
-
-        periodType = periodService.getPeriodTypeByName( MonthlyPeriodType.NAME );
-        period = createPeriod( periodType, getDate( 2000, 1, 1 ), getDate( 2000, 2, 1 ) );
-        periodService.addPeriod( period );
-
-        mapLegendSet = createMapLegendSet( 'A', indicator );
-        mappingService.addMapLegendSet( mapLegendSet );
-    }
-
-    // -------------------------------------------------------------------------
-    // MapLegend
-    // -------------------------------------------------------------------------
-
-    @Test
-    public void testGetAddOrUpdateMapLegendByName()
-    {
-        MapLegend legend = createMapLegend( 'A', 0.1, 0.2 );
-
-        mappingService.addOrUpdateMapLegend( legend.getName(), legend.getStartValue(), legend.getEndValue(),
-            legend.getColor(), legend.getImage() );
-
-        legend = mappingService.getMapLegendByName( legend.getName() );
-
-        assertNotNull( legend );
-
-        int id = legend.getId();
-
-        mappingService.addOrUpdateMapLegend( legend.getName(), legend.getStartValue(), 0.3, "ColorB", "img.png" );
-
-        assertEquals( "MapLegendA", mappingService.getMapLegend( id ).getName() );
-        assertEquals( 0.1, mappingService.getMapLegend( id ).getStartValue() );
-        assertEquals( 0.3, mappingService.getMapLegend( id ).getEndValue() );
-        assertEquals( "ColorB", mappingService.getMapLegend( id ).getColor() );
-        assertEquals( "img.png", mappingService.getMapLegend( id ).getImage() );
-    }
-
-    @Test
-    public void testDeleteMapLegend()
-    {
-        MapLegend legend = createMapLegend( 'A', 0.1, 0.2 );
-
-        mappingService.addOrUpdateMapLegend( legend.getName(), legend.getStartValue(), legend.getEndValue(),
-            legend.getColor(), legend.getImage() );
-
-        legend = mappingService.getMapLegendByName( legend.getName() );
-
-        assertNotNull( legend );
-
-        int id = legend.getId();
-
-        mappingService.deleteMapLegend( legend );
-
-        assertNull( mappingService.getMapLegend( id ) );
-    }
-
-    @Test
-    public void testGetAllMapLegends()
-    {
-        MapLegend legend1 = createMapLegend( 'A', 0.1, 0.2 );
-        MapLegend legend2 = createMapLegend( 'B', 0.3, 0.4 );
-        MapLegend legend3 = createMapLegend( 'C', 0.5, 0.6 );
-
-        mappingService.addOrUpdateMapLegend( legend1.getName(), legend1.getStartValue(), legend1.getEndValue(),
-            legend1.getColor(), legend1.getImage() );
-        mappingService.addOrUpdateMapLegend( legend3.getName(), legend3.getStartValue(), legend3.getEndValue(),
-            legend3.getColor(), legend3.getImage() );
-
-        legend1 = mappingService.getMapLegendByName( legend1.getName() );
-        legend3 = mappingService.getMapLegendByName( legend3.getName() );
-
-        assertNotNull( legend1 );
-        assertNotNull( legend3 );
-
-        int idA = legend1.getId();
-        int idC = legend3.getId();
-
-        assertEquals( legend1, mappingService.getMapLegend( idA ) );
-        assertEquals( legend3, mappingService.getMapLegend( idC ) );
-        assertTrue( !mappingService.getAllMapLegends().contains( legend2 ) );
-    }
-
-    // -------------------------------------------------------------------------
-    // MapLegendSet
-    // -------------------------------------------------------------------------
-
-    @Test
-    public void testAddGetMapLegendSet()
-    {
-        MapLegendSet legendSet = createMapLegendSet( 'B', indicator );
-
-        int id = mappingService.addMapLegendSet( legendSet );
-
-        assertNotNull( mappingService.getMapLegendSet( id ) );
-    }
-
-    @Test
-    public void testGetUpdateMapLegendSetByName()
-    {
-        MapLegendSet legendSet = createMapLegendSet( 'C', indicator );
-
-        int id = mappingService.addMapLegendSet( legendSet );
-
-        legendSet = mappingService.getMapLegendSet( id );
-
-        assertNotNull( legendSet );
-
-        legendSet.setName( "MapLegendSetB" );
-
-        mappingService.updateMapLegendSet( legendSet );
-
-        assertEquals( "MapLegendSetB", mappingService.getMapLegendSetByName( "MapLegendSetB" ).getName() );
-    }
-
-    @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 );
-
-        Collection<MapLegendSet> mapLegendSets = new HashSet<MapLegendSet>();
-
-        mapLegendSets.add( mapLegendSet );
-        mapLegendSets.add( legendSet1 );
-        mapLegendSets.add( legendSet2 );
-        mapLegendSets.add( legendSet3 );
-
-        mappingService.addMapLegendSet( legendSet1 );
-        mappingService.addMapLegendSet( legendSet2 );
-        mappingService.addMapLegendSet( legendSet3 );
-
-        assertTrue( mappingService.getAllMapLegendSets().containsAll( mapLegendSets ) );
-
-    }
-
-    @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
-    // -------------------------------------------------------------------------
-
-    @Test
-    public void testAddGetMapView()
-    {
-        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",
-            mapLegendSet, 5, 20, "1", "1", 1 );
-
-        int idA = mappingService.addMapView( mapView );
-
-        assertEquals( mapView, mappingService.getMapView( idA ) );
-        assertEquals( indicatorGroup, mappingService.getMapView( idA ).getIndicatorGroup() );
-        assertEquals( indicator, mappingService.getMapView( idA ).getIndicator() );
-        assertEquals( periodType, mappingService.getMapView( idA ).getPeriodType() );
-        assertEquals( period, mappingService.getMapView( idA ).getPeriod() );
-    }
-
-    @Test
-    public void testGetDeleteMapViewByName()
-    {
-        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",
-            mapLegendSet, 5, 20, "1", "1", 1 );
-
-        int id = mappingService.addMapView( mapView );
-
-        mapView = mappingService.getMapViewByName( "MapViewA" );
-
-        mappingService.deleteMapView( mapView );
-
-        assertNull( mappingService.getMapView( id ) );
-    }
-
-    @Test
-    public void testGetAllMapViews()
-    {
-        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",
-            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",
-            mapLegendSet, 5, 20, "2", "2", 1 );
-
-        mappingService.addMapView( mapView1 );
-        mappingService.addMapView( mapView2 );
-
-        assertEquals( 2, mappingService.getAllMapViews().size() );
-    }
-
-    @Test
-    @Ignore
-    // TODO
-    public void testGetMapViewsByFeatureType()
-    {
-        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",
-            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",
-            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",
-            mapLegendSet, 5, 20, "3", "3", 1 );
-
-        mappingService.addMapView( mapView1 );
-        mappingService.addMapView( mapView2 );
-        mappingService.addMapView( mapView3 );
-
-        assertEquals( 1, mappingService.getMapViewsByFeatureType( OrganisationUnit.FEATURETYPE_POLYGON ).size() );
-        assertEquals( 2, mappingService.getMapViewsByFeatureType( OrganisationUnit.FEATURETYPE_MULTIPOLYGON ).size() );
-    }
-
-    // -------------------------------------------------------------------------
-    // MapLayer
-    // -------------------------------------------------------------------------
-
-    @Test
-    public void testAddGetMapLayer()
-    {
-        MapLayer mapLayer = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "", "A", 0.1,
-            "B", 1 );
-
-        int id = mappingService.addMapLayer( mapLayer );
-
-        assertEquals( "MapLayerA", mappingService.getMapLayer( id ).getName() );
-        assertEquals( MappingService.MAP_LAYER_TYPE_BASELAYER, mappingService.getMapLayer( id ).getType() );
-        assertEquals( "A", mappingService.getMapLayer( id ).getFillColor() );
-        assertEquals( "B", mappingService.getMapLayer( id ).getStrokeColor() );
-        assertEquals( 0.1, mappingService.getMapLayer( id ).getFillOpacity() );
-        assertEquals( 1, mappingService.getMapLayer( id ).getStrokeWidth() );
-    }
-
-    @Test
-    public void testGetUpdateDeleteMapLayerByName()
-    {
-        MapLayer mapLayer = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "", "A", 0.1,
-            "B", 1 );
-
-        int id = mappingService.addMapLayer( mapLayer );
-
-        mapLayer = mappingService.getMapLayer( id );
-
-        mapLayer.setName( "MapLayerB" );
-        mapLayer.setFillOpacity( 0.05 );
-        mapLayer.setStrokeWidth( 0 );
-
-        mappingService.updateMapLayer( mapLayer );
-
-        assertEquals( "MapLayerB", mappingService.getMapLayerByName( "MapLayerB" ).getName() );
-        assertEquals( 0.05, mappingService.getMapLayerByName( "MapLayerB" ).getFillOpacity() );
-        assertEquals( 0, mappingService.getMapLayerByName( "MapLayerB" ).getStrokeWidth() );
-    }
-
-    @Test
-    public void testGetAllMapLayers()
-    {
-        MapLayer mapLayer1 = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "", "A", 0.1,
-            "B", 1 );
-        MapLayer mapLayer2 = new MapLayer( "MapLayerB", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "", "C", 0.2,
-            "D", 2 );
-        MapLayer mapLayer3 = new MapLayer( "MapLayerC", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "", "E", 0.3,
-            "F", 3 );
-        MapLayer mapLayer4 = new MapLayer( "MapLayerD", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "", "G", 0.4,
-            "H", 4 );
-
-        int idA = mappingService.addMapLayer( mapLayer1 );
-        int idB = mappingService.addMapLayer( mapLayer2 );
-        int idC = mappingService.addMapLayer( mapLayer3 );
-
-        assertEquals( mapLayer1, mappingService.getMapLayer( idA ) );
-        assertEquals( mapLayer2, mappingService.getMapLayer( idB ) );
-        assertEquals( mapLayer3, mappingService.getMapLayer( idC ) );
-        assertTrue( !mappingService.getAllMapLayers().contains( mapLayer4 ) );
-
-    }
-
-    @Test
-    public void testGetMapLayersByTypeOrMapSource()
-    {
-        List<MapLayer> baseLayers = new ArrayList<MapLayer>();
-        List<MapLayer> overlayLayers = new ArrayList<MapLayer>();
-
-        MapLayer mapLayer1 = new MapLayer( "MapLayerA", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "", "A", 0.1,
-            "B", 1 );
-        MapLayer mapLayer2 = new MapLayer( "MapLayerB", MappingService.MAP_LAYER_TYPE_OVERLAY, "", "", "", "C", 0.2,
-            "D", 2 );
-        MapLayer mapLayer3 = new MapLayer( "MapLayerC", MappingService.MAP_LAYER_TYPE_OVERLAY, "", "", "", "E", 0.3,
-            "F", 3 );
-        MapLayer mapLayer4 = new MapLayer( "MapLayerD", MappingService.MAP_LAYER_TYPE_BASELAYER, "", "", "", "G", 0.4,
-            "H", 4 );
-
-        baseLayers.add( mapLayer1 );
-        baseLayers.add( mapLayer4 );
-
-        overlayLayers.add( mapLayer2 );
-        overlayLayers.add( mapLayer3 );
-
-        mappingService.addMapLayer( mapLayer1 );
-        mappingService.addMapLayer( mapLayer2 );
-        mappingService.addMapLayer( mapLayer3 );
-        mappingService.addMapLayer( mapLayer4 );
-
-        assertEquals( baseLayers, mappingService.getMapLayersByType( MappingService.MAP_LAYER_TYPE_BASELAYER ) );
-        assertEquals( overlayLayers, mappingService.getMapLayersByType( MappingService.MAP_LAYER_TYPE_OVERLAY ) );
-    }
-}

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/pom.xml'
--- dhis-2/dhis-services/dhis-service-reporting/pom.xml	2012-08-03 11:05:49 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/pom.xml	2012-10-24 16:19:29 +0000
@@ -29,10 +29,6 @@
       <groupId>org.hisp.dhis</groupId>
       <artifactId>dhis-service-core</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.hisp.dhis</groupId>
-      <artifactId>dhis-service-mapping</artifactId>
-    </dependency>
     
     <!-- JasperReports -->
 

=== modified file 'dhis-2/dhis-services/pom.xml'
--- dhis-2/dhis-services/pom.xml	2012-08-03 11:05:49 +0000
+++ dhis-2/dhis-services/pom.xml	2012-10-24 16:19:29 +0000
@@ -20,7 +20,6 @@
     <module>dhis-service-datamart-default</module>
     <module>dhis-service-importexport</module>
     <module>dhis-service-reporting</module>
-    <module>dhis-service-mapping</module>
     <module>dhis-service-mapgeneration</module>
     <module>dhis-service-aggregationengine-default</module>
     <module>dhis-service-patient</module>

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/pom.xml'
--- dhis-2/dhis-web/dhis-web-mapping/pom.xml	2012-08-03 11:05:49 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/pom.xml	2012-10-24 16:19:29 +0000
@@ -36,10 +36,6 @@
     </dependency>
     <dependency>
       <groupId>org.hisp.dhis</groupId>
-      <artifactId>dhis-service-mapping</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.hisp.dhis</groupId>
       <artifactId>dhis-service-reporting</artifactId>
     </dependency>
     <dependency>