← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6344: split mappingStore into 4 separate stores (mapView, mapLayer, mapLegend, mapLegendSet)

 

------------------------------------------------------------
revno: 6344
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-03-22 13:34:46 +0100
message:
  split mappingStore into 4 separate stores (mapView, mapLayer, mapLegend, mapLegendSet)
removed:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingStore.java
  dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java
  dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingStoreTest.java
added:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLayerStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendSetStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapViewStore.java
  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
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericStore.java
  dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java
  dhis-2/dhis-services/dhis-service-mapping/src/main/resources/META-INF/dhis/beans.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
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java	2012-03-22 12:34:46 +0000
@@ -31,7 +31,6 @@
 
 /**
  * @author Lars Helge Overland
- * @version $Id$
  */
 public interface GenericIdentifiableObjectStore<T>
     extends GenericStore<T>

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericStore.java	2012-01-19 11:43:06 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericStore.java	2012-03-22 12:34:46 +0000
@@ -31,7 +31,6 @@
 
 /**
  * @author Lars Helge Overland
- * @version $Id$
  */
 public interface GenericStore<T>
 {

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLayerStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLayerStore.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLayerStore.java	2012-03-22 12:34:46 +0000
@@ -0,0 +1,45 @@
+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.common.GenericIdentifiableObjectStore;
+
+import java.util.Collection;
+
+/**
+ * @author Jan Henrik Overland
+ */
+public interface MapLayerStore
+    extends GenericIdentifiableObjectStore<MapLayer>
+{
+    String ID = MapLayerStore.class.getName();
+
+    Collection<MapLayer> getMapLayersByType( String type );
+
+    MapLayer getMapLayerByMapSource( String mapSource );
+}
\ No newline at end of file

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendSetStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendSetStore.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendSetStore.java	2012-03-22 12:34:46 +0000
@@ -0,0 +1,43 @@
+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.common.GenericIdentifiableObjectStore;
+
+import java.util.Collection;
+
+/**
+ * @author Jan Henrik Overland
+ */
+public interface MapLegendSetStore
+    extends GenericIdentifiableObjectStore<MapLegendSet>
+{
+    String ID = MapLegendSetStore.class.getName();
+
+    Collection<MapLegendSet> getMapLegendSetsByType( String type );
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendStore.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendStore.java	2012-03-22 12:34:46 +0000
@@ -0,0 +1,39 @@
+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.common.GenericIdentifiableObjectStore;
+
+/**
+ * @author Jan Henrik Overland
+ */
+public interface MapLegendStore
+    extends GenericIdentifiableObjectStore<MapLegend>
+{
+    String ID = MapLegendStore.class.getName();
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapViewStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapViewStore.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapViewStore.java	2012-03-22 12:34:46 +0000
@@ -0,0 +1,46 @@
+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.common.GenericIdentifiableObjectStore;
+import org.hisp.dhis.user.User;
+
+import java.util.Collection;
+
+/**
+ * @author Jan Henrik Overland
+ */
+public interface MapViewStore
+    extends GenericIdentifiableObjectStore<MapView>
+{
+    String ID = MapViewStore.class.getName();
+
+    Collection<MapView> getMapViewsByMapSourceType( String mapSourceType );
+
+    Collection<MapView> getMapViewsByFeatureType( String featureType, User user );
+}

=== removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingStore.java	2012-03-19 22:10:02 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingStore.java	1970-01-01 00:00:00 +0000
@@ -1,121 +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.common.GenericIdentifiableObjectStore;
-import org.hisp.dhis.user.User;
-
-import java.util.Collection;
-
-/**
- * @author Jan Henrik Overland
- * @version $Id$
- */
-public interface MappingStore
-    extends GenericIdentifiableObjectStore<MapView>
-{
-    String ID = MappingStore.class.getName();
-
-    // -------------------------------------------------------------------------
-    // MapLegend
-    // -------------------------------------------------------------------------
-
-    int addMapLegend( MapLegend legend );
-
-    void updateMapLegend( MapLegend legend );
-
-    void deleteMapLegend( MapLegend legend );
-
-    MapLegend getMapLegend( int id );
-
-    MapLegend getMapLegend( String uid );
-
-    MapLegend getMapLegendByName( String name );
-
-    Collection<MapLegend> getAllMapLegends();
-
-    // -------------------------------------------------------------------------
-    // MapLegendSet
-    // -------------------------------------------------------------------------
-
-    int addMapLegendSet( MapLegendSet legendSet );
-
-    void updateMapLegendSet( MapLegendSet legendSet );
-
-    void deleteMapLegendSet( MapLegendSet legendSet );
-
-    MapLegendSet getMapLegendSet( int id );
-
-    MapLegendSet getMapLegendSet( String uid );
-
-    MapLegendSet getMapLegendSetByName( String name );
-
-    Collection<MapLegendSet> getMapLegendSetsByType( String type );
-
-    Collection<MapLegendSet> getAllMapLegendSets();
-
-    // -------------------------------------------------------------------------
-    // MapView
-    // -------------------------------------------------------------------------
-
-    int addMapView( MapView mapView );
-
-    void updateMapView( MapView mapView );
-
-    void deleteMapView( MapView view );
-
-    MapView getMapView( int id );
-
-    MapView getMapViewByName( String name );
-
-    Collection<MapView> getAllMapViews( User user );
-
-    Collection<MapView> getMapViewsByFeatureType( String featureType, User user );
-
-    // -------------------------------------------------------------------------
-    // MapLayer
-    // -------------------------------------------------------------------------
-
-    int addMapLayer( MapLayer mapLayer );
-
-    void updateMapLayer( MapLayer mapLayer );
-
-    void deleteMapLayer( MapLayer mapLayer );
-
-    MapLayer getMapLayer( int id );
-
-    MapLayer getMapLayer( String uid );
-
-    MapLayer getMapLayerByName( String name );
-
-    Collection<MapLayer> getMapLayersByType( String type );
-
-    MapLayer getMapLayerByMapSource( String mapSource );
-
-    Collection<MapLayer> getAllMapLayers();
-}
\ No newline at end of file

=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java	2012-03-19 22:10:02 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java	2012-03-22 12:34:46 +0000
@@ -56,7 +56,6 @@
 
 /**
  * @author Jan Henrik Overland
- * @version $Id$
  */
 @Transactional
 public class DefaultMappingService
@@ -66,11 +65,32 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
-    private MappingStore mappingStore;
-
-    public void setMappingStore( MappingStore mappingStore )
-    {
-        this.mappingStore = mappingStore;
+    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;
@@ -275,40 +295,40 @@
             mapLegend.setColor( color );
             mapLegend.setImage( image );
 
-            mappingStore.updateMapLegend( mapLegend );
+            mapLegendStore.update( mapLegend );
         }
         else
         {
             mapLegend = new MapLegend( name, startValue, endValue, color, image );
 
-            mappingStore.addMapLegend( mapLegend );
+            mapLegendStore.save( mapLegend );
         }
     }
 
     public void deleteMapLegend( MapLegend mapLegend )
     {
-        mappingStore.deleteMapLegend( mapLegend );
+        mapLegendStore.delete( mapLegend );
     }
 
     public MapLegend getMapLegend( int id )
     {
-        return mappingStore.getMapLegend( id );
+        return mapLegendStore.get( id );
     }
 
     @Override
     public MapLegend getMapLegend( String uid )
     {
-        return mappingStore.getMapLegend( uid );
+        return mapLegendStore.getByUid( uid );
     }
 
     public MapLegend getMapLegendByName( String name )
     {
-        return mappingStore.getMapLegendByName( name );
+        return mapLegendStore.getByName( name );
     }
 
     public Collection<MapLegend> getAllMapLegends()
     {
-        return mappingStore.getAllMapLegends();
+        return mapLegendStore.getAll();
     }
 
     // -------------------------------------------------------------------------
@@ -317,12 +337,12 @@
 
     public int addMapLegendSet( MapLegendSet mapLegendSet )
     {
-        return mappingStore.addMapLegendSet( mapLegendSet );
+        return mapLegendSetStore.save( mapLegendSet );
     }
 
     public void updateMapLegendSet( MapLegendSet mapLegendSet )
     {
-        mappingStore.updateMapLegendSet( mapLegendSet );
+        mapLegendSetStore.update( mapLegendSet );
     }
 
     public void addOrUpdateMapLegendSet( String name, String type, String symbolizer, Set<MapLegend> mapLegends )
@@ -341,47 +361,47 @@
             mapLegendSet.setIndicators( indicators );
             mapLegendSet.setDataElements( dataElements );
 
-            this.mappingStore.updateMapLegendSet( mapLegendSet );
+            mapLegendSetStore.update( mapLegendSet );
         }
         else
         {
             mapLegendSet = new MapLegendSet( name, type, symbolizer, mapLegends, indicators, dataElements );
 
-            this.mappingStore.addMapLegendSet( mapLegendSet );
+            mapLegendSetStore.save( mapLegendSet );
         }
     }
 
     public void deleteMapLegendSet( MapLegendSet mapLegendSet )
     {
-        mappingStore.deleteMapLegendSet( mapLegendSet );
+        mapLegendSetStore.delete( mapLegendSet );
     }
 
     public MapLegendSet getMapLegendSet( int id )
     {
-        return mappingStore.getMapLegendSet( id );
+        return mapLegendSetStore.get( id );
     }
 
     @Override
     public MapLegendSet getMapLegendSet( String uid )
     {
-        return mappingStore.getMapLegendSet( uid );
+        return mapLegendSetStore.getByUid( uid );
     }
 
     public MapLegendSet getMapLegendSetByName( String name )
     {
-        return mappingStore.getMapLegendSetByName( name );
+        return mapLegendSetStore.getByName( name );
     }
 
     public Collection<MapLegendSet> getMapLegendSetsByType( String type )
     {
-        return this.mappingStore.getMapLegendSetsByType( type );
+        return mapLegendSetStore.getMapLegendSetsByType( type );
     }
 
     public MapLegendSet getMapLegendSetByIndicator( int indicatorId )
     {
         Indicator indicator = indicatorService.getIndicator( indicatorId );
 
-        Collection<MapLegendSet> mapLegendSets = mappingStore.getAllMapLegendSets();
+        Collection<MapLegendSet> mapLegendSets = mapLegendSetStore.getAll();
 
         for ( MapLegendSet mapLegendSet : mapLegendSets )
         {
@@ -398,7 +418,7 @@
     {
         DataElement dataElement = dataElementService.getDataElement( dataElementId );
 
-        Collection<MapLegendSet> mapLegendSets = mappingStore.getAllMapLegendSets();
+        Collection<MapLegendSet> mapLegendSets = mapLegendSetStore.getAll();
 
         for ( MapLegendSet mapLegendSet : mapLegendSets )
         {
@@ -413,14 +433,14 @@
 
     public Collection<MapLegendSet> getAllMapLegendSets()
     {
-        return mappingStore.getAllMapLegendSets();
+        return mapLegendSetStore.getAll();
     }
 
     public boolean indicatorHasMapLegendSet( int indicatorId )
     {
         Indicator indicator = indicatorService.getIndicator( indicatorId );
 
-        Collection<MapLegendSet> mapLegendSets = mappingStore.getAllMapLegendSets();
+        Collection<MapLegendSet> mapLegendSets = mapLegendSetStore.getAll();
 
         for ( MapLegendSet mapLegendSet : mapLegendSets )
         {
@@ -439,7 +459,7 @@
 
     public int addMapView( MapView mapView )
     {
-        return mappingStore.addMapView( mapView );
+        return mapViewStore.save( mapView );
     }
 
     public void addMapView( String name, boolean system, String mapValueType, Integer indicatorGroupId,
@@ -489,17 +509,17 @@
 
     public void updateMapView( MapView mapView )
     {
-        mappingStore.updateMapView( mapView );
+        mapViewStore.update( mapView );
     }
 
-    public void deleteMapView( MapView view )
+    public void deleteMapView( MapView mapView )
     {
-        mappingStore.deleteMapView( view );
+        mapViewStore.delete( mapView );
     }
 
     public MapView getMapView( int id )
     {
-        MapView mapView = mappingStore.getMapView( id );
+        MapView mapView = mapViewStore.get( id );
 
         setMapViewLevel( mapView );
 
@@ -508,7 +528,7 @@
 
     public MapView getMapView( String uid )
     {
-        MapView mapView = mappingStore.getByUid( uid );
+        MapView mapView = mapViewStore.getByUid( uid );
 
         setMapViewLevel( mapView );
 
@@ -526,7 +546,7 @@
 
     public MapView getMapViewByName( String name )
     {
-        return mappingStore.getMapViewByName( name );
+        return mapViewStore.getByName( name );
     }
 
     public MapView getIndicatorLastYearMapView( String indicatorUid, String organisationUnitUid, int level )
@@ -553,7 +573,7 @@
     {
         User user = currentUserService.getCurrentUser();
 
-        Collection<MapView> mapViews = mappingStore.getAllMapViews( user );
+        Collection<MapView> mapViews = mapViewStore.getAll();
 
         if ( mapViews.size() > 0 )
         {
@@ -571,7 +591,7 @@
     {
         User user = currentUserService.getCurrentUser();
 
-        Collection<MapView> mapViews = mappingStore.getMapViewsByFeatureType( featureType, user );
+        Collection<MapView> mapViews = mapViewStore.getMapViewsByFeatureType( featureType, user );
 
         for ( MapView mapView : mapViews )
         {
@@ -588,18 +608,18 @@
 
     public int addMapLayer( MapLayer mapLayer )
     {
-        return mappingStore.addMapLayer( mapLayer );
+        return mapLayerStore.save( mapLayer );
     }
 
     public void updateMapLayer( MapLayer mapLayer )
     {
-        mappingStore.updateMapLayer( 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 = mappingStore.getMapLayerByName( name );
+        MapLayer mapLayer = mapLayerStore.getByName( name );
 
         if ( mapLayer != null )
         {
@@ -623,37 +643,37 @@
 
     public void deleteMapLayer( MapLayer mapLayer )
     {
-        mappingStore.deleteMapLayer( mapLayer );
+        mapLayerStore.delete( mapLayer );
     }
 
     public MapLayer getMapLayer( int id )
     {
-        return mappingStore.getMapLayer( id );
+        return mapLayerStore.get( id );
     }
 
     @Override
     public MapLayer getMapLayer( String uid )
     {
-        return mappingStore.getMapLayer( uid );
+        return mapLayerStore.getByUid( uid );
     }
 
     public MapLayer getMapLayerByName( String name )
     {
-        return mappingStore.getMapLayerByName( name );
+        return mapLayerStore.getByName( name );
     }
 
     public Collection<MapLayer> getMapLayersByType( String type )
     {
-        return mappingStore.getMapLayersByType( type );
+        return mapLayerStore.getMapLayersByType( type );
     }
 
     public MapLayer getMapLayerByMapSource( String mapSource )
     {
-        return mappingStore.getMapLayerByMapSource( mapSource );
+        return mapLayerStore.getMapLayerByMapSource( mapSource );
     }
 
     public Collection<MapLayer> getAllMapLayers()
     {
-        return mappingStore.getAllMapLayers();
+        return mapLayerStore.getAll();
     }
 }

=== added 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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapLayerStore.java	2012-03-22 12:34:46 +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-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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapLegendSetStore.java	2012-03-22 12:34:46 +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-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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapLegendStore.java	2012-03-22 12:34:46 +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-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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapViewStore.java	2012-03-22 12:34:46 +0000
@@ -0,0 +1,72 @@
+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> 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 file 'dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java	2012-03-19 22:10:02 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java	1970-01-01 00:00:00 +0000
@@ -1,363 +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.Criterion;
-import org.hibernate.criterion.Restrictions;
-import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
-import org.hisp.dhis.mapping.*;
-import org.hisp.dhis.user.User;
-
-import java.util.Collection;
-
-/**
- * @author Jan Henrik Overland
- * @version $Id$
- */
-public class HibernateMappingStore
-    extends HibernateIdentifiableObjectStore<MapView>
-    implements MappingStore
-{
-
-    // -------------------------------------------------------------------------
-    // MapLegend
-    // -------------------------------------------------------------------------
-
-    public int addMapLegend( MapLegend legend )
-    {
-        Session session = sessionFactory.getCurrentSession();
-        legend.setAutoFields();
-
-        return (Integer) session.save( legend );
-    }
-
-    public void updateMapLegend( MapLegend legend )
-    {
-        Session session = sessionFactory.getCurrentSession();
-        legend.setAutoFields();
-
-        session.update( legend );
-    }
-
-    public void deleteMapLegend( MapLegend legend )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        session.delete( legend );
-    }
-
-    public MapLegend getMapLegend( int id )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        return (MapLegend) session.get( MapLegend.class, id );
-    }
-
-    @Override
-    public MapLegend getMapLegend( String uid )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( MapLegend.class );
-
-        criteria.add( Restrictions.eq( "uid", uid ) );
-
-        return (MapLegend) criteria.uniqueResult();
-    }
-
-    public MapLegend getMapLegendByName( String name )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( MapLegend.class );
-
-        criteria.add( Restrictions.eq( "name", name ) );
-
-        return (MapLegend) criteria.uniqueResult();
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public Collection<MapLegend> getAllMapLegends()
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( MapLegend.class );
-
-        return criteria.list();
-    }
-
-    // -------------------------------------------------------------------------
-    // MapLegendSet
-    // -------------------------------------------------------------------------
-
-    public int addMapLegendSet( MapLegendSet legendSet )
-    {
-        Session session = sessionFactory.getCurrentSession();
-        legendSet.setAutoFields();
-
-        return (Integer) session.save( legendSet );
-    }
-
-    public void updateMapLegendSet( MapLegendSet legendSet )
-    {
-        Session session = sessionFactory.getCurrentSession();
-        legendSet.setAutoFields();
-
-        session.update( legendSet );
-    }
-
-    public void deleteMapLegendSet( MapLegendSet legendSet )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        session.delete( legendSet );
-    }
-
-    public MapLegendSet getMapLegendSet( int id )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        return (MapLegendSet) session.get( MapLegendSet.class, id );
-    }
-
-    @Override
-    public MapLegendSet getMapLegendSet( String uid )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( MapLegendSet.class );
-
-        criteria.add( Restrictions.eq( "uid", uid ) );
-
-        return (MapLegendSet) criteria.uniqueResult();
-    }
-
-    public MapLegendSet getMapLegendSetByName( String name )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( MapLegendSet.class );
-
-        criteria.add( Restrictions.eq( "name", name ) );
-
-        return (MapLegendSet) criteria.uniqueResult();
-    }
-
-    @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();
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public Collection<MapLegendSet> getAllMapLegendSets()
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( MapLegendSet.class );
-
-        return criteria.list();
-    }
-
-    // -------------------------------------------------------------------------
-    // MapView
-    // -------------------------------------------------------------------------
-
-    public int addMapView( MapView view )
-    {
-        return super.save( view );
-    }
-
-    public void updateMapView( MapView view )
-    {
-        super.update( view );
-    }
-
-    public void deleteMapView( MapView view )
-    {
-        super.delete( view );
-    }
-
-    public MapView getMapView( int id )
-    {
-        return super.get( id );
-    }
-
-    public MapView getMapViewByName( String name )
-    {
-        return super.getByName( name );
-    }
-
-    @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> getAllMapViews( User user )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( MapView.class );
-
-        Criterion nullUser = Restrictions.isNull( "user" );
-
-        criteria.add( user != null ? Restrictions.or( Restrictions.eq( "user", user ), nullUser ) : nullUser );
-
-        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();
-    }
-
-    // -------------------------------------------------------------------------
-    // MapLayer
-    // -------------------------------------------------------------------------
-
-    public int addMapLayer( MapLayer mapLayer )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        return (Integer) session.save( mapLayer );
-    }
-
-    public void updateMapLayer( MapLayer mapLayer )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        session.update( mapLayer );
-    }
-
-    public void deleteMapLayer( MapLayer mapLayer )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        session.delete( mapLayer );
-    }
-
-    public MapLayer getMapLayer( int id )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        return (MapLayer) session.get( MapLayer.class, id );
-    }
-
-    @Override
-    public MapLayer getMapLayer( String uid )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( MapLayer.class );
-
-        criteria.add( Restrictions.eq( "uid", uid ) );
-
-        return (MapLayer) criteria.uniqueResult();
-    }
-
-    public MapLayer getMapLayerByName( String name )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( MapLayer.class );
-
-        criteria.add( Restrictions.eq( "name", name ) );
-
-        return (MapLayer) criteria.uniqueResult();
-    }
-
-    @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();
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public Collection<MapLayer> getAllMapLayers()
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( MapLayer.class );
-
-        return criteria.list();
-    }
-}

=== modified 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-01-05 20:39:23 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/resources/META-INF/dhis/beans.xml	2012-03-22 12:34:46 +0000
@@ -1,82 +1,97 @@
 <?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="
+    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="mappingStore"
-      ref="org.hisp.dhis.mapping.MappingStore"/>
-	<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="userSettingService"
-      ref="org.hisp.dhis.user.UserSettingService"/>
-	<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"/>
+      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="userSettingService" ref="org.hisp.dhis.user.UserSettingService" />
+    <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.MappingStore"
-    class="org.hisp.dhis.mapping.hibernate.HibernateMappingStore">
+  <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"/>
+    <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">
+      class="org.hisp.dhis.mapping.MapLegendSetDeletionHandler">
     <property name="mappingService"
-      ref="org.hisp.dhis.mapping.MappingService"/>
+        ref="org.hisp.dhis.mapping.MappingService" />
   </bean>
-    
+
   <bean id="org.hisp.dhis.mapping.MapViewDeletionHandler"
-    class="org.hisp.dhis.mapping.MapViewDeletionHandler">
+      class="org.hisp.dhis.mapping.MapViewDeletionHandler">
     <property name="mappingService"
-      ref="org.hisp.dhis.mapping.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="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"/>
+          <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 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 file 'dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingStoreTest.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingStoreTest.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingStoreTest.java	1970-01-01 00:00:00 +0000
@@ -1,132 +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 org.hisp.dhis.DhisSpringTest;
-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.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.hisp.dhis.user.User;
-import org.junit.Test;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class MappingStoreTest
-    extends DhisSpringTest
-{
-    private MappingStore mappingStore;
-
-    private OrganisationUnit organisationUnit;
-
-    private OrganisationUnitLevel organisationUnitLevel;
-
-    private IndicatorGroup indicatorGroup;
-
-    private IndicatorType indicatorType;
-
-    private Indicator indicator;
-
-    private PeriodType periodType;
-
-    private Period period;
-
-    private MapLegendSet mapLegendSet;
-
-    // -------------------------------------------------------------------------
-    // Fixture
-    // -------------------------------------------------------------------------
-
-    @Override
-    public void setUpTest()
-    {
-        mappingStore = (MappingStore) getBean( MappingStore.ID );
-
-        organisationUnitService = (OrganisationUnitService) getBean( OrganisationUnitService.ID );
-
-        indicatorService = (IndicatorService) getBean( IndicatorService.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 );
-
-        periodType = periodService.getPeriodTypeByName( MonthlyPeriodType.NAME );
-        period = createPeriod( periodType, getDate( 2000, 1, 1 ), getDate( 2000, 2, 1 ) );
-        periodService.addPeriod( period );
-
-        mapLegendSet = createMapLegendSet( 'A', indicator );
-        mappingStore.addMapLegendSet( mapLegendSet );
-    }
-
-    // -------------------------------------------------------------------------
-    // MapView tests
-    // -------------------------------------------------------------------------
-
-    @Test
-    public void testAddGetMapView()
-    {
-        MapView mapView = new MapView( "MapViewA", new User(), MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup,
-            indicator, new DataElementGroup(), new DataElement(), MappingService.MAP_DATE_TYPE_FIXED, periodType,
-            period, organisationUnit, organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A",
-            "B", mapLegendSet, 5, 20, "1", "1", 1 );
-
-        int idA = mappingStore.addMapView( mapView );
-
-        assertEquals( mapView, mappingStore.getMapView( idA ) );
-        assertEquals( indicatorGroup, mappingStore.getMapView( idA ).getIndicatorGroup() );
-        assertEquals( indicator, mappingStore.getMapView( idA ).getIndicator() );
-        assertEquals( periodType, mappingStore.getMapView( idA ).getPeriodType() );
-        assertEquals( period, mappingStore.getMapView( idA ).getPeriod() );
-    }
-}
\ No newline at end of file