=== 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 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 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 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 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 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 mapViews = mappingService.getAllMapViews().iterator(); + + while ( mapViews.hasNext() ) { + MapView mapView = mapViews.next(); + if ( mapView.getLegendSet() != null && mapView.getLegendSet().equals( mapLegendSet ) ) { + mapViews.remove(); mappingService.deleteMapView( mapView ); } }