dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41518
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21152: new end point to update comments to enrollment. this helps to avoid sending full enrollment detai...
------------------------------------------------------------
revno: 21152
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2015-11-21 12:27:07 +0100
message:
new end point to update comments to enrollment. this helps to avoid sending full enrollment details and and attribute checking
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/EnrollmentService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/JacksonEnrollmentService.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EnrollmentController.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/enrollment/AbstractEnrollmentService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java 2015-11-20 11:38:58 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java 2015-11-21 11:27:07 +0000
@@ -398,6 +398,33 @@
return importSummary;
}
+
+ @Override
+ public ImportSummary updateEnrollmentForNote( Enrollment enrollment )
+ {
+ ImportSummary importSummary = new ImportSummary();
+
+ if ( enrollment == null || enrollment.getEnrollment() == null )
+ {
+ return new ImportSummary( ImportStatus.ERROR, "No enrollment or enrollment ID was supplied" ).incrementIgnored();
+ }
+
+ ProgramInstance programInstance = programInstanceService.getProgramInstance( enrollment.getEnrollment() );
+
+ if ( programInstance == null )
+ {
+ return new ImportSummary( ImportStatus.ERROR, "Enrollment ID was not valid." ).incrementIgnored();
+ }
+
+ Set<ImportConflict> importConflicts = new HashSet<>();
+
+ saveTrackedEntityComment( programInstance, enrollment );
+
+ importSummary.setReference( enrollment.getEnrollment() );
+ importSummary.getImportCount().incrementUpdated();
+
+ return importSummary;
+ }
// -------------------------------------------------------------------------
// DELETE
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/EnrollmentService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/EnrollmentService.java 2015-10-23 05:12:02 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/EnrollmentService.java 2015-11-21 11:27:07 +0000
@@ -71,12 +71,16 @@
// -------------------------------------------------------------------------
ImportSummary updateEnrollmentJson( String id, InputStream inputStream ) throws IOException;
+
+ ImportSummary updateEnrollmentForNoteJson( String id, InputStream inputStream ) throws IOException;
ImportSummary updateEnrollmentXml( String id, InputStream inputStream ) throws IOException;
ImportSummaries updateEnrollments( List<Enrollment> enrollments );
ImportSummary updateEnrollment( Enrollment enrollment );
+
+ ImportSummary updateEnrollmentForNote( Enrollment enrollment );
// -------------------------------------------------------------------------
// DELETE
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/JacksonEnrollmentService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/JacksonEnrollmentService.java 2015-10-23 07:11:19 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/JacksonEnrollmentService.java 2015-11-21 11:27:07 +0000
@@ -198,6 +198,15 @@
return updateEnrollment( enrollment );
}
+
+ @Override
+ public ImportSummary updateEnrollmentForNoteJson( String id, InputStream inputStream ) throws IOException
+ {
+ Enrollment enrollment = fromJson( inputStream, Enrollment.class );
+ enrollment.setEnrollment( id );
+
+ return updateEnrollmentForNote( enrollment );
+ }
@Override
public ImportSummary updateEnrollmentXml( String id, InputStream inputStream ) throws IOException
=== 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-10-23 05:12:02 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EnrollmentController.java 2015-11-21 11:27:07 +0000
@@ -29,11 +29,13 @@
*/
import com.google.common.collect.Lists;
+
import org.hisp.dhis.common.OrganisationUnitSelectionMode;
import org.hisp.dhis.commons.util.TextUtils;
import org.hisp.dhis.dxf2.common.ImportOptions;
import org.hisp.dhis.dxf2.events.enrollment.Enrollment;
import org.hisp.dhis.dxf2.events.enrollment.EnrollmentService;
+import org.hisp.dhis.dxf2.events.event.Event;
import org.hisp.dhis.dxf2.importsummary.ImportStatus;
import org.hisp.dhis.dxf2.importsummary.ImportSummaries;
import org.hisp.dhis.dxf2.importsummary.ImportSummary;
@@ -67,6 +69,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
@@ -234,6 +237,14 @@
ImportSummary importSummary = enrollmentService.updateEnrollmentJson( id, request.getInputStream() );
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')" )
@@ -251,7 +262,7 @@
@RequestMapping( value = "/{id}/completed", method = RequestMethod.PUT )
@PreAuthorize( "hasRole('ALL') or hasRole('F_PROGRAM_UNENROLLMENT')" )
@ResponseStatus( HttpStatus.NO_CONTENT )
- public void completedEnrollment( @PathVariable String id ) throws NotFoundException, WebMessageException
+ public void completeEnrollment( @PathVariable String id ) throws NotFoundException, WebMessageException
{
if ( !programInstanceService.programInstanceExists( id ) )
{