← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10622: added support for completing programs to UploadAnonymousEventAction

 

------------------------------------------------------------
revno: 10622
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-04-18 19:55:29 +0700
message:
  added support for completing programs to UploadAnonymousEventAction
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/UploadAnonymousEventAction.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-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/UploadAnonymousEventAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/UploadAnonymousEventAction.java	2013-04-17 11:03:44 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/UploadAnonymousEventAction.java	2013-04-18 12:55:29 +0000
@@ -137,7 +137,9 @@
             return INPUT;
         }
 
-        ProgramStageInstance programStageInstance = saveExecutionDate( programId, organisationUnitId, date );
+        Boolean completed = (Boolean) executionDate.get( "completed" );
+
+        ProgramStageInstance programStageInstance = saveExecutionDate( programId, organisationUnitId, date, completed );
 
         Map<String, Object> values = (Map<String, Object>) input.get( "values" );
 
@@ -158,7 +160,7 @@
         return SUCCESS;
     }
 
-    private ProgramStageInstance saveExecutionDate( Integer programId, Integer organisationUnitId, Date date )
+    private ProgramStageInstance saveExecutionDate( Integer programId, Integer organisationUnitId, Date date, Boolean completed )
     {
         OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
         Program program = programService.getProgram( programId );
@@ -172,6 +174,13 @@
         programStageInstance.setExecutionDate( date );
         programStageInstance.setOrganisationUnit( organisationUnit );
 
+        if ( completed != null )
+        {
+            programStageInstance.setCompleted( completed );
+            programStageInstance.setCompletedDate( new Date() );
+            programStageInstance.setCompletedUser( currentUserService.getCurrentUsername() );
+        }
+
         programStageInstanceService.addProgramStageInstance( programStageInstance );
 
         message = programStageInstance.getId() + "";