← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8687: Web api, impl delete of map legend sets

 

------------------------------------------------------------
revno: 8687
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-10-24 12:22:27 +0200
message:
  Web api, impl delete of map legend sets
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapLegendSetController.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-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java	2012-10-24 10:17:56 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java	2012-10-24 10:22:27 +0000
@@ -187,7 +187,7 @@
     @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
     @ResponseStatus( value = HttpStatus.NO_CONTENT )
     @PreAuthorize( "hasRole('ALL')" )
-    public void deleteObject( @PathVariable( "uid" ) String uid ) throws Exception
+    public void deleteObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid ) throws Exception
     {
         throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
     }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapLegendSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapLegendSetController.java	2012-10-24 10:17:56 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapLegendSetController.java	2012-10-24 10:22:27 +0000
@@ -111,4 +111,29 @@
         
         mappingService.updateMapLegendSet( legendSet );
     }
+
+    @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
+    @ResponseStatus( value = HttpStatus.NO_CONTENT )
+    @PreAuthorize( "hasRole('ALL') or hasRole('ALL')" )
+    public void deleteObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid ) throws Exception
+    {
+        MapLegendSet legendSet = mappingService.getMapLegendSet( uid );
+        
+        if ( legendSet == null )
+        {
+            ContextUtils.notFoundResponse( response, "Map legend set does not exist: " + uid );
+            return;
+        }
+
+        Iterator<MapLegend> legends = legendSet.getMapLegends().iterator();
+
+        while ( legends.hasNext() )
+        {
+            MapLegend legend = legends.next();            
+            legends.remove();            
+            mappingService.deleteMapLegend( legend );
+        }
+        
+        mappingService.deleteMapLegendSet( legendSet );
+    }
 }