← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 482: (GIS) Object MapLayer added.

 

------------------------------------------------------------
revno: 482
committer: Jan Henrik Overland janhenrik.overland@xxxxxxxxx
branch nick: trunk
timestamp: Thu 2009-08-20 20:52:55 +0200
message:
  (GIS) Object MapLayer added.
added:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLayer.java
  dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLayer.hbm.xml
  gis/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddOrUpdateMapLayerAction.java
  gis/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/DeleteMapLayerAction.java
  gis/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetAllMapLayersAction.java
  gis/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapLayers.vm
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java
  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/DefaultMappingService.java
  dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java
  gis/dhis-web-mapping/pom.xml
  gis/dhis-web-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.
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLayer.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLayer.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLayer.java	2009-08-20 18:52:55 +0000
@@ -0,0 +1,118 @@
+package org.hisp.dhis.mapping;
+
+/*
+ * Copyright (c) 2004-2007, 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.
+ */
+
+/**
+ * @author Jan Henrik Overland
+ * @version $Id$
+ */
+public class MapLayer
+{
+    private int id;
+
+    private String name;
+    
+    private String mapSource;
+    
+    public MapLayer()
+    {
+    }
+
+    public MapLayer( String name, String mapSource )
+    {
+        this.name = name;
+        this.mapSource = mapSource;
+    }
+    
+    // -------------------------------------------------------------------------
+    // hashCode, equals and toString
+    // -------------------------------------------------------------------------
+    
+    @Override
+    public int hashCode()
+    {
+        return name.hashCode();
+    }
+
+    @Override
+    public boolean equals( Object object )
+    {
+        if ( this == object )
+        {
+            return true;
+        }
+        
+        if ( object == null )
+        {
+            return false;
+        }
+        
+        if ( getClass() != object.getClass() )
+        {
+            return false;
+        }
+        
+        final MapLayer other = (MapLayer) object;
+        
+        return name.equals( other.name );
+    }
+    
+    // -------------------------------------------------------------------------
+    // Getters and setters
+    // -------------------------------------------------------------------------
+
+    public int getId()
+    {
+        return id;
+    }
+
+    public void setId( int id )
+    {
+        this.id = id;
+    }
+
+    public String getName()
+    {
+        return name;
+    }
+
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+    public String getMapSource()
+    {
+        return mapSource;
+    }
+
+    public void setMapSource( String mapSource )
+    {
+        this.mapSource = mapSource;
+    }
+}
\ No newline at end of file

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java	2009-07-13 20:00:15 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java	2009-08-20 18:52:55 +0000
@@ -337,4 +337,24 @@
     MapView getMapViewByName( String name );
 
     Collection<MapView> getAllMapViews();
+    
+    // -------------------------------------------------------------------------
+    // MapLayer
+    // -------------------------------------------------------------------------
+
+    int addMapLayer( MapLayer mapLayer );
+    
+    void updateMapLayer( MapLayer mapLayer );
+    
+    void addOrUpdateMapLayer( String name, String mapSource );
+    
+    void deleteMapLayer( MapLayer mapLayer );
+    
+    MapLayer getMapLayer( int id );
+    
+    MapLayer getMapLayerByName( String name );
+    
+    MapLayer getMapLayerByMapSource( String mapSource );
+    
+    Collection<MapLayer> getAllMapLayers();
 }
\ No newline at end of file

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingStore.java	2009-05-29 12:05:15 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingStore.java	2009-08-20 18:52:55 +0000
@@ -221,4 +221,22 @@
     MapView getMapViewByName( String name );
     
     Collection<MapView> getAllMapViews();
-}
+    
+    // -------------------------------------------------------------------------
+    // MapLayer
+    // -------------------------------------------------------------------------
+
+    int addMapLayer( MapLayer mapLayer );
+    
+    void updateMapLayer( MapLayer mapLayer );
+    
+    void deleteMapLayer( MapLayer mapLayer );
+    
+    MapLayer getMapLayer( int id );
+    
+    MapLayer getMapLayerByName( String name );
+    
+    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	2009-08-04 07:36:02 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java	2009-08-20 18:52:55 +0000
@@ -196,9 +196,9 @@
     public Collection<Map> getAllGeneratedMaps()
     {
         List<OrganisationUnitLevel> organisationUnitLevels = organisationUnitService.getOrganisationUnitLevels();
-        
+
         List<Map> maps = new ArrayList<Map>();
-        
+
         for ( OrganisationUnitLevel organisationUnitLevel : organisationUnitLevels )
         {
             Map map = new Map();
@@ -207,17 +207,17 @@
             map.setOrganisationUnitLevel( organisationUnitLevel );
             maps.add( map );
         }
-        
+
         return maps;
     }
 
     public Collection<Map> getAllUserMaps()
     {
         String type = (String) userSettingService.getUserSetting( KEY_MAP_SOURCE_TYPE, MAP_SOURCE_TYPE_DATABASE );
-        
+
         return type != null && type.equals( MAP_SOURCE_TYPE_DATABASE ) ? getAllGeneratedMaps() : getAllMaps();
     }
-    
+
     // -------------------------------------------------------------------------
     // MapOrganisationUnitRelation
     // -------------------------------------------------------------------------
@@ -445,7 +445,7 @@
             .getClass() );
 
         Period period = periodService.getPeriod( periodId );
-        
+
         mapView.setName( name );
         mapView.setIndicatorGroup( indicatorGroup );
         mapView.setIndicator( indicator );
@@ -466,8 +466,8 @@
         mappingStore.updateMapView( mapView );
     }
 
-    public void addOrUpdateMapView( String name, int indicatorGroupId, int indicatorId, String periodTypeName, int periodId,
-        String mapSourceType, String mapSource, int method, int classes, String colorLow, String colorHigh )
+    public void addOrUpdateMapView( String name, int indicatorGroupId, int indicatorId, String periodTypeName,
+        int periodId, String mapSourceType, String mapSource, int method, int classes, String colorLow, String colorHigh )
     {
         IndicatorGroup indicatorGroup = indicatorService.getIndicatorGroup( indicatorGroupId );
 
@@ -498,7 +498,8 @@
         }
         else
         {
-            mapView = new MapView( name, indicatorGroup, indicator, periodType, period, mapSourceType, mapSource, method, classes, colorLow, colorHigh );
+            mapView = new MapView( name, indicatorGroup, indicator, periodType, period, mapSourceType, mapSource,
+                method, classes, colorLow, colorHigh );
 
             addMapView( mapView );
         }
@@ -522,22 +523,79 @@
     public Collection<MapView> getAllMapViews()
     {
         Collection<MapView> selectedMapViews = new ArrayList<MapView>();
-        
+
         Collection<MapView> mapViews = mappingStore.getAllMapViews();
-  
-        String mapSourceType = (String) userSettingService.getUserSetting( KEY_MAP_SOURCE_TYPE, MAP_SOURCE_TYPE_DATABASE );
-        
-        if (mapViews != null)
+
+        String mapSourceType = (String) userSettingService.getUserSetting( KEY_MAP_SOURCE_TYPE,
+            MAP_SOURCE_TYPE_DATABASE );
+
+        if ( mapViews != null )
         {
-            for (MapView mapView : mapViews)
+            for ( MapView mapView : mapViews )
             {
-                if (mapView.getMapSourceType().equals( mapSourceType ))
+                if ( mapView.getMapSourceType().equals( mapSourceType ) )
                 {
                     selectedMapViews.add( mapView );
                 }
             }
         }
-        
+
         return selectedMapViews;
     }
+
+    // -------------------------------------------------------------------------
+    // MapLayer
+    // -------------------------------------------------------------------------
+
+    public int addMapLayer( MapLayer mapLayer )
+    {
+        return mappingStore.addMapLayer( mapLayer );
+    }
+
+    public void updateMapLayer( MapLayer mapLayer )
+    {
+        mappingStore.updateMapLayer( mapLayer );
+    }
+
+    public void addOrUpdateMapLayer( String name, String mapSource )
+    {
+        MapLayer mapLayer = mappingStore.getMapLayerByName( name );
+
+        if ( mapLayer != null )
+        {
+            mapLayer.setName( name );
+            mapLayer.setMapSource( mapSource );
+            
+            updateMapLayer( mapLayer );
+        }
+        else
+        {
+            addMapLayer( new MapLayer( name, mapSource ) );
+        }
+    }
+
+    public void deleteMapLayer( MapLayer mapLayer )
+    {
+        mappingStore.deleteMapLayer( mapLayer );
+    }
+
+    public MapLayer getMapLayer( int id )
+    {
+        return mappingStore.getMapLayer( id );
+    }
+
+    public MapLayer getMapLayerByName( String name )
+    {
+        return mappingStore.getMapLayerByName( name );
+    }
+
+    public MapLayer getMapLayerByMapSource( String mapSource )
+    {
+        return mappingStore.getMapLayerByMapSource( mapSource );
+    }
+
+    public Collection<MapLayer> getAllMapLayers()
+    {
+        return mappingStore.getAllMapLayers();
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java	2009-07-06 17:45:57 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java	2009-08-20 18:52:55 +0000
@@ -35,6 +35,7 @@
 import org.hibernate.SessionFactory;
 import org.hibernate.criterion.Restrictions;
 import org.hisp.dhis.mapping.Map;
+import org.hisp.dhis.mapping.MapLayer;
 import org.hisp.dhis.mapping.MapLegendSet;
 import org.hisp.dhis.mapping.MapOrganisationUnitRelation;
 import org.hisp.dhis.mapping.MapView;
@@ -327,4 +328,68 @@
 
         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 );
+    }
+    
+    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();
+    }
+    
+    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();
+    }
 }

=== added 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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLayer.hbm.xml	2009-08-20 18:52:55 +0000
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd";>
+
+<hibernate-mapping>
+	
+	<class name="org.hisp.dhis.mapping.MapLayer" table="maplayer">
+    
+    	<id name="id" column="maplayerid">
+			<generator class="native"/>
+		</id>
+	
+		<property name="name" column="name" unique="true"/>
+	
+		<property name="mapSource" column="mapsource" unique="true"/>
+		
+	</class>
+	
+</hibernate-mapping>
\ No newline at end of file

=== modified file 'gis/dhis-web-mapping/pom.xml'
--- gis/dhis-web-mapping/pom.xml	2009-06-25 11:18:23 +0000
+++ gis/dhis-web-mapping/pom.xml	2009-08-20 18:52:55 +0000
@@ -73,7 +73,27 @@
 	<dependency>
 	  <groupId>org.hisp.dhis</groupId>
 	  <artifactId>dhis-support-webwork</artifactId>
-	</dependency>  
+	</dependency>
+
+	<!-- Mapfish print module -->
+	  
+	<dependency>
+      <groupId>org.mapfish.print</groupId>
+      <artifactId>print-lib</artifactId>
+      <version>1.2-SNAPSHOT</version>
+    </dependency>
     
   </dependencies>
+	
+  <repositories>
+
+	<!-- Mapfish -->
+	  	      
+	<repository>
+      <id>org.mapfish</id>
+      <url>http://dev.mapfish.org/maven/repository</url>
+    </repository>
+	  
+  </repositories>
+	
 </project>

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

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

=== added file 'gis/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetAllMapLayersAction.java'
--- gis/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetAllMapLayersAction.java	1970-01-01 00:00:00 +0000
+++ gis/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetAllMapLayersAction.java	2009-08-20 18:52:55 +0000
@@ -0,0 +1,77 @@
+package org.hisp.dhis.mapping.action;
+
+/*
+ * Copyright (c) 2004-2007, 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.ArrayList;
+import java.util.List;
+
+import org.hisp.dhis.mapping.MapLayer;
+import org.hisp.dhis.mapping.MappingService;
+
+import com.opensymphony.xwork.Action;
+
+/**
+ * @author Jan Henrik Overland
+ * @version $Id$
+ */
+public class GetAllMapLayersAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private MappingService mappingService;
+
+    public void setMappingService( MappingService mappingService )
+    {
+        this.mappingService = mappingService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    private List<MapLayer> object;
+
+    public List<MapLayer> getObject()
+    {
+        return object;
+    }
+    
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+    {
+        object = new ArrayList<MapLayer>( mappingService.getAllMapLayers() );
+        
+        return SUCCESS;
+    }
+}

=== modified file 'gis/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml'
--- gis/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml	2009-07-13 20:00:15 +0000
+++ gis/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml	2009-08-20 18:52:55 +0000
@@ -195,6 +195,29 @@
     <property name="mappingService"
       ref="org.hisp.dhis.mapping.MappingService"/>
   </bean>
+	
+  <!-- MapLayer -->
+	
+  <bean id="org.hisp.dhis.mapping.action.AddOrUpdateMapLayerAction"
+    class="org.hisp.dhis.mapping.action.AddOrUpdateMapLayerAction"
+    scope="prototype">
+    <property name="mappingService"
+      ref="org.hisp.dhis.mapping.MappingService"/>
+  </bean>
+	
+  <bean id="org.hisp.dhis.mapping.action.DeleteMapLayerAction"
+    class="org.hisp.dhis.mapping.action.DeleteMapLayerAction"
+    scope="prototype">
+    <property name="mappingService"
+      ref="org.hisp.dhis.mapping.MappingService"/>
+  </bean>	
+	
+  <bean id="org.hisp.dhis.mapping.action.GetAllMapLayersAction"
+    class="org.hisp.dhis.mapping.action.GetAllMapLayersAction"
+    scope="prototype">
+    <property name="mappingService"
+      ref="org.hisp.dhis.mapping.MappingService"/>
+  </bean>
   
   <!-- Indicator -->
     

=== added file 'gis/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapLayers.vm'
--- gis/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapLayers.vm	1970-01-01 00:00:00 +0000
+++ gis/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapLayers.vm	2009-08-20 18:52:55 +0000
@@ -0,0 +1,10 @@
+#set( $size = $object.size() )
+{ "mapLayers": [
+#foreach( $mapLayer in $object )
+  {
+    "id": "$!{mapLayer.id}",
+    "name": "$!encoder.jsEncode( ${mapLayer.name} )",
+    "mapSource": "$!encoder.jsEncode( ${mapLayer.mapSource} )"
+  }#if( $velocityCount < $size ),#end
+#end
+] }
\ No newline at end of file