dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #28530
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14249: support deletion of TrackedEntityAttribute/TrackedEntityAttributeGroup through web-api
------------------------------------------------------------
revno: 14249
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-03-17 14:17:06 +0100
message:
support deletion of TrackedEntityAttribute/TrackedEntityAttributeGroup through web-api
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityAttributeController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityAttributeGroupController.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/event/TrackedEntityAttributeController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityAttributeController.java 2014-03-17 13:15:21 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityAttributeController.java 2014-03-17 13:17:06 +0000
@@ -162,6 +162,14 @@
@ResponseStatus( value = HttpStatus.NO_CONTENT )
public void deleteObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid ) throws Exception
{
- throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+ TrackedEntityAttribute trackedEntityAttribute = trackedEntityAttributeService.getTrackedEntityAttribute( uid );
+
+ if ( trackedEntityAttribute == null )
+ {
+ ContextUtils.conflictResponse( response, "TrackedEntityAttribute does not exist: " + uid );
+ return;
+ }
+
+ trackedEntityAttributeService.deleteTrackedEntityAttribute( trackedEntityAttribute );
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityAttributeGroupController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityAttributeGroupController.java 2014-03-17 13:15:21 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityAttributeGroupController.java 2014-03-17 13:17:06 +0000
@@ -108,6 +108,14 @@
@ResponseStatus( value = HttpStatus.NO_CONTENT )
public void deleteObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid ) throws Exception
{
- throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+ TrackedEntityAttributeGroup trackedEntityAttributeGroup = trackedEntityAttributeGroupService.getTrackedEntityAttributeGroup( uid );
+
+ if ( trackedEntityAttributeGroup == null )
+ {
+ ContextUtils.conflictResponse( response, "TrackedEntityAttributeGroup does not exist: " + uid );
+ return;
+ }
+
+ trackedEntityAttributeGroupService.deleteTrackedEntityAttributeGroup( trackedEntityAttributeGroup );
}
}