dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #42203
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21559: minor change to web-api end point to reflect RESTful naming conventions.
------------------------------------------------------------
revno: 21559
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2016-01-01 22:05:36 +0100
message:
minor change to web-api end point to reflect RESTful naming conventions.
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EnrollmentController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.java
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js
--
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/webapi/controller/event/EnrollmentController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EnrollmentController.java 2015-12-15 14:46:39 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EnrollmentController.java 2016-01-01 21:05:36 +0000
@@ -214,6 +214,14 @@
webMessageService.send( WebMessageUtils.importSummaries( importSummaries ), response, request );
}
}
+
+ @RequestMapping( value = "/{id}/note", method = RequestMethod.POST, consumes = "application/json" )
+ @PreAuthorize( "hasRole('ALL') or hasRole('F_PROGRAM_UNENROLLMENT')" )
+ public void updateEnrollmentForNoteJson( @PathVariable String id, HttpServletRequest request, HttpServletResponse response ) throws IOException
+ {
+ ImportSummary importSummary = enrollmentService.updateEnrollmentForNoteJson( id, request.getInputStream() );
+ webMessageService.send( WebMessageUtils.importSummary( importSummary ), response, request );
+ }
// -------------------------------------------------------------------------
// UPDATE
@@ -235,14 +243,6 @@
webMessageService.send( WebMessageUtils.importSummary( importSummary ), response, request );
}
- @RequestMapping( value = "/{id}/addNote", method = RequestMethod.PUT, consumes = "application/json" )
- @PreAuthorize( "hasRole('ALL') or hasRole('F_PROGRAM_UNENROLLMENT')" )
- public void updateEnrollmentForNoteJson( @PathVariable String id, HttpServletRequest request, HttpServletResponse response ) throws IOException
- {
- ImportSummary importSummary = enrollmentService.updateEnrollmentForNoteJson( id, request.getInputStream() );
- webMessageService.send( WebMessageUtils.importSummary( importSummary ), response, request );
- }
-
@RequestMapping( value = "/{id}/cancelled", method = RequestMethod.PUT )
@PreAuthorize( "hasRole('ALL') or hasRole('F_PROGRAM_UNENROLLMENT')" )
@ResponseStatus( HttpStatus.NO_CONTENT )
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.java 2015-12-04 05:41:43 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.java 2016-01-01 21:05:36 +0000
@@ -550,6 +550,21 @@
}
}
+ @RequestMapping( value = "/{uid}/note", method = RequestMethod.POST, consumes = "application/json" )
+ @PreAuthorize( "hasRole('ALL') or hasRole('F_TRACKED_ENTITY_DATAVALUE_ADD')" )
+ public void postJsonEventForNote( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid, ImportOptions importOptions ) throws IOException, WebMessageException
+ {
+ if ( !programStageInstanceService.programStageInstanceExists( uid ) )
+ {
+ throw new WebMessageException( WebMessageUtils.notFound( "Event not found for ID " + uid ) );
+ }
+
+ Event event = renderService.fromJson( request.getInputStream(), Event.class );
+ event.setEvent( uid );
+
+ eventService.updateEventForNote( event );
+ webMessageService.send( WebMessageUtils.ok( "Event updated: " + uid ), response, request );
+ }
@RequestMapping( method = RequestMethod.POST, consumes = { "application/csv", "text/csv" } )
@PreAuthorize( "hasRole('ALL') or hasRole('F_TRACKED_ENTITY_DATAVALUE_ADD')" )
@@ -634,23 +649,7 @@
webMessageService.send( WebMessageUtils.importSummary( importSummary ), response, request );
}
- @RequestMapping( value = "/{uid}/addNote", method = RequestMethod.PUT, consumes = "application/json" )
- @PreAuthorize( "hasRole('ALL') or hasRole('F_TRACKED_ENTITY_DATAVALUE_ADD')" )
- public void putJsonEventForNote( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid, ImportOptions importOptions ) throws IOException, WebMessageException
- {
- if ( !programStageInstanceService.programStageInstanceExists( uid ) )
- {
- throw new WebMessageException( WebMessageUtils.notFound( "Event not found for ID " + uid ) );
- }
-
- Event updatedEvent = renderService.fromJson( request.getInputStream(), Event.class );
- updatedEvent.setEvent( uid );
-
- eventService.updateEventForNote( updatedEvent );
- webMessageService.send( WebMessageUtils.ok( "Event updated: " + uid ), response, request );
- }
-
- @RequestMapping( value = "/{uid}/updateEventDate", method = RequestMethod.PUT, consumes = "application/json" )
+ @RequestMapping( value = "/{uid}/eventDate", method = RequestMethod.PUT, consumes = "application/json" )
@PreAuthorize( "hasRole('ALL') or hasRole('F_TRACKED_ENTITY_DATAVALUE_ADD')" )
public void putJsonEventForEventDate( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid, ImportOptions importOptions ) throws IOException, WebMessageException
{
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2015-12-28 20:34:02 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2016-01-01 21:05:36 +0000
@@ -628,7 +628,7 @@
return promise;
},
updateForNote: function( enrollment ){
- var promise = $http.put('../api/enrollments/' + enrollment.enrollment + '/addNote', enrollment).then(function(response){
+ var promise = $http.post('../api/enrollments/' + enrollment.enrollment + '/note', enrollment).then(function(response){
return response.data;
});
return promise;
@@ -1060,13 +1060,13 @@
return promise;
},
updateForNote: function(dhis2Event){
- var promise = $http.put('../api/events/' + dhis2Event.event + '/addNote', dhis2Event).then(function(response){
+ var promise = $http.post('../api/events/' + dhis2Event.event + '/note', dhis2Event).then(function(response){
return response.data;
});
return promise;
},
updateForEventDate: function(dhis2Event){
- var promise = $http.put('../api/events/' + dhis2Event.event + '/updateEventDate', dhis2Event).then(function(response){
+ var promise = $http.put('../api/events/' + dhis2Event.event + '/eventDate', dhis2Event).then(function(response){
return response.data;
});
return promise;