← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8843: Fix to MapViewDeletionHandler

 

------------------------------------------------------------
revno: 8843
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2012-11-03 21:55:45 +0300
message:
  Fix to MapViewDeletionHandler
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/MapViewDeletionHandler.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-core/src/main/java/org/hisp/dhis/mapping/MapViewDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/MapViewDeletionHandler.java	2012-10-25 10:22:15 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/MapViewDeletionHandler.java	2012-11-03 18:55:45 +0000
@@ -83,10 +83,15 @@
     @Override
     public void deleteIndicatorGroup( IndicatorGroup indicatorGroup )
     {
-        for ( MapView mapView : mappingService.getAllMapViews() )
+        Iterator<MapView> mapViews = mappingService.getAllMapViews().iterator();
+        
+        while ( mapViews.hasNext() )
         {
+            MapView mapView = mapViews.next();
+            
             if ( mapView.getIndicatorGroup() != null && mapView.getIndicatorGroup().equals( indicatorGroup ) )
             {
+                mapViews.remove();
                 mappingService.deleteMapView( mapView );
             }
         }
@@ -95,10 +100,15 @@
     @Override
     public void deleteIndicator( Indicator indicator )
     {
-        for ( MapView mapView : mappingService.getAllMapViews() )
+        Iterator<MapView> mapViews = mappingService.getAllMapViews().iterator();
+        
+        while ( mapViews.hasNext() )
         {
+            MapView mapView = mapViews.next();
+            
             if ( mapView.getIndicator() != null && mapView.getIndicator().equals( indicator ) )
             {
+                mapViews.remove();
                 mappingService.deleteMapView( mapView );
             }
         }
@@ -107,10 +117,15 @@
     @Override
     public void deleteDataElementGroup( DataElementGroup dataElementGroup )
     {
-        for ( MapView mapView : mappingService.getAllMapViews() )
+        Iterator<MapView> mapViews = mappingService.getAllMapViews().iterator();
+        
+        while ( mapViews.hasNext() )
         {
+            MapView mapView = mapViews.next();
+            
             if ( mapView.getDataElementGroup() != null && mapView.getDataElementGroup().equals( dataElementGroup ) )
             {
+                mapViews.remove();
                 mappingService.deleteMapView( mapView );
             }
         }
@@ -119,10 +134,15 @@
     @Override
     public void deleteDataElement( DataElement dataElement )
     {
-        for ( MapView mapView : mappingService.getAllMapViews() )
+        Iterator<MapView> mapViews = mappingService.getAllMapViews().iterator();
+        
+        while ( mapViews.hasNext() )
         {
+            MapView mapView = mapViews.next();
+            
             if ( mapView.getDataElement() != null && mapView.getDataElement().equals( dataElement ) )
             {
+                mapViews.remove();
                 mappingService.deleteMapView( mapView );
             }
         }
@@ -131,10 +151,15 @@
     @Override
     public void deleteOrganisationUnit( OrganisationUnit organisationUnit )
     {
-        for ( MapView mapView : mappingService.getAllMapViews() )
+        Iterator<MapView> mapViews = mappingService.getAllMapViews().iterator();
+        
+        while ( mapViews.hasNext() )
         {
+            MapView mapView = mapViews.next();
+            
             if ( mapView.getParentOrganisationUnit() != null && mapView.getParentOrganisationUnit().equals( organisationUnit ) )
             {
+                mapViews.remove();
                 mappingService.deleteMapView( mapView );
             }
         }
@@ -143,10 +168,15 @@
     @Override
     public void deleteMapLegendSet( MapLegendSet mapLegendSet )
     {
-        for ( MapView mapView : mappingService.getAllMapViews() )
+        Iterator<MapView> mapViews = mappingService.getAllMapViews().iterator();
+        
+        while ( mapViews.hasNext() )
         {
+            MapView mapView = mapViews.next();
+            
             if ( mapView.getLegendSet() != null && mapView.getLegendSet().equals( mapLegendSet ) )
             {
+                mapViews.remove();
                 mappingService.deleteMapView( mapView );
             }
         }