dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #31320
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15941: web api for updating eventdate only -no need to send the entire event
------------------------------------------------------------
revno: 15941
committer: Abyot Asalefew Gizaw abyota@xxxxxxxxx
branch nick: dhis2
timestamp: Wed 2014-07-02 18:24:42 +0200
message:
web api for updating eventdate only -no need to send the entire event
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventService.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.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-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java 2014-06-30 11:45:18 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java 2014-07-02 16:24:42 +0000
@@ -463,6 +463,28 @@
saveTrackedEntityComment( programStageInstance, event, getStoredBy( event, null ) );
}
+
+ public void updateEventForEventDate( Event event )
+ {
+ ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance( event
+ .getEvent() );
+
+ if ( programStageInstance == null )
+ {
+ return;
+ }
+
+ Date executionDate = new Date();
+
+ if ( event.getEventDate() != null )
+ {
+ executionDate = DateUtils.getMediumDate( event.getEventDate() );
+ }
+
+ programStageInstance.setExecutionDate( executionDate );
+ programStageInstanceService.updateProgramStageInstance( programStageInstance );
+
+ }
// -------------------------------------------------------------------------
// DELETE
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventService.java 2014-06-30 11:45:18 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventService.java 2014-07-02 16:24:42 +0000
@@ -100,6 +100,8 @@
void updateEvent( Event event, boolean singleValue, ImportOptions importOptions );
void updateEventForNote( Event event );
+
+ void updateEventForEventDate( Event event );
// -------------------------------------------------------------------------
// DELETE
=== 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 2014-06-30 11:45:18 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.java 2014-07-02 16:24:42 +0000
@@ -426,6 +426,25 @@
eventService.updateEventForNote( updatedEvent );
ContextUtils.okResponse( response, "Event updated: " + uid );
}
+
+ @RequestMapping( value = "/{uid}/updateEventDate", 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
+ {
+ Event event = eventService.getEvent( uid );
+
+ if ( event == null )
+ {
+ ContextUtils.notFoundResponse( response, "Event not found for uid: " + uid );
+ return;
+ }
+
+ Event updatedEvent = JacksonUtils.fromJson( request.getInputStream(), Event.class );
+ updatedEvent.setEvent( uid );
+
+ eventService.updateEventForNote( updatedEvent );
+ ContextUtils.okResponse( response, "Event updated: " + uid );
+ }
// -------------------------------------------------------------------------
// DELETE