← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4408: GIS: improved MapViewDeletionHandler

 

------------------------------------------------------------
revno: 4408
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2011-08-21 12:33:32 +0200
message:
  GIS: improved MapViewDeletionHandler
modified:
  dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/MapViewDeletionHandler.java
  dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/MapViewDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/MapViewDeletionHandler.java	2011-01-24 19:52:30 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/MapViewDeletionHandler.java	2011-08-21 10:33:32 +0000
@@ -27,8 +27,11 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementGroup;
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.indicator.IndicatorGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.system.deletion.DeletionHandler;
 
@@ -99,6 +102,42 @@
     }
     
     @Override
+    public void deleteDataElementGroup( DataElementGroup dataElementGroup )
+    {
+        for ( MapView mapView : mappingService.getAllMapViews() )
+        {
+            if ( mapView.getDataElementGroup() != null && mapView.getDataElementGroup().equals( dataElementGroup ) )
+            {
+                mappingService.deleteMapView( mapView );
+            }
+        }
+    }
+    
+    @Override
+    public void deleteDataElement( DataElement dataElement )
+    {
+        for ( MapView mapView : mappingService.getAllMapViews() )
+        {
+            if ( mapView.getDataElement() != null && mapView.getDataElement().equals( dataElement ) )
+            {
+                mappingService.deleteMapView( mapView );
+            }
+        }
+    }
+    
+    @Override
+    public void deleteOrganisationUnit( OrganisationUnit organisationUnit )
+    {
+        for ( MapView mapView : mappingService.getAllMapViews() )
+        {
+            if ( mapView.getParentOrganisationUnit() != null && mapView.getParentOrganisationUnit().equals( organisationUnit ) )
+            {
+                mappingService.deleteMapView( mapView );
+            }
+        }
+    }
+    
+    @Override
     public void deleteMapLegendSet( MapLegendSet mapLegendSet )
     {
         for ( MapView mapView : mappingService.getAllMapViews() )
@@ -109,4 +148,5 @@
             }
         }
     }
+    
 }

=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java	2011-08-11 21:14:57 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java	2011-08-21 10:33:32 +0000
@@ -494,10 +494,10 @@
         overlayLayers.add( mapLayer2 );
         overlayLayers.add( mapLayer3 );
 
-        int idA = mappingService.addMapLayer( mapLayer1 );
-        int idB = mappingService.addMapLayer( mapLayer2 );
-        int idC = mappingService.addMapLayer( mapLayer3 );
-        int idD = mappingService.addMapLayer( mapLayer4 );
+        mappingService.addMapLayer( mapLayer1 );
+        mappingService.addMapLayer( mapLayer2 );
+        mappingService.addMapLayer( mapLayer3 );
+        mappingService.addMapLayer( mapLayer4 );
 
         assertEquals( baseLayers, mappingService.getMapLayersByType( MappingService.MAP_LAYER_TYPE_BASELAYER ) );
         assertEquals( overlayLayers, mappingService.getMapLayersByType( MappingService.MAP_LAYER_TYPE_OVERLAY ) );