← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18320: Program. Updating version when data entry form is added/changed/deleted.

 

------------------------------------------------------------
revno: 18320
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-02-18 15:35:39 +0100
message:
  Program. Updating version when data entry form is added/changed/deleted.
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/dataentryform/RemoveDataEntryFormAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/dataentryform/RemoveTrackedEntityFormAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/dataentryform/SaveDataEntryFormAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/dataentryform/SaveTrackedEntityFormAction.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-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/dataentryform/RemoveDataEntryFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/dataentryform/RemoveDataEntryFormAction.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/dataentryform/RemoveDataEntryFormAction.java	2015-02-18 14:35:39 +0000
@@ -106,11 +106,11 @@
     {
         DataEntryForm dataEntryForm = dataEntryFormService.getDataEntryForm( id );
 
-        Program currentProgram = programStageService.getProgramStage( programStageId ).getProgram();
-
-        programId = currentProgram.getId();
-
-        Set<ProgramStage> programStages = currentProgram.getProgramStages();
+        Program program = programStageService.getProgramStage( programStageId ).getProgram();
+
+        programId = program.getId();
+
+        Set<ProgramStage> programStages = program.getProgramStages();
 
         for ( ProgramStage programStage : programStages )
         {
@@ -124,6 +124,8 @@
             }
         }
 
+        program.increaseVersion();
+                
         dataEntryFormService.deleteDataEntryForm( dataEntryForm );
 
         return SUCCESS;

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/dataentryform/RemoveTrackedEntityFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/dataentryform/RemoveTrackedEntityFormAction.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/dataentryform/RemoveTrackedEntityFormAction.java	2015-02-18 14:35:39 +0000
@@ -87,6 +87,8 @@
             Program program = programService.getProgram( id );
 
             registrationForm = formService.getFormsWithProgram( program );
+            
+            program.increaseVersion();
         }
         else
         {

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/dataentryform/SaveDataEntryFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/dataentryform/SaveDataEntryFormAction.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/dataentryform/SaveDataEntryFormAction.java	2015-02-18 14:35:39 +0000
@@ -28,10 +28,9 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.dataentryform.DataEntryForm;
 import org.hisp.dhis.dataentryform.DataEntryFormService;
+import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.program.ProgramStageService;
 
@@ -45,8 +44,6 @@
 public class SaveDataEntryFormAction
     implements Action
 {
-    Log logger = LogFactory.getLog( getClass() );
-
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -64,7 +61,7 @@
     {
         this.programStageService = programStageService;
     }
-
+    
     // -------------------------------------------------------------------------
     // Getters & Setters
     // -------------------------------------------------------------------------
@@ -114,7 +111,9 @@
     {
         ProgramStage programStage = programStageService.getProgramStage( programStageId );
         
-        programId = programStage.getProgram().getId();
+        Program program = programStage.getProgram();
+        
+        programId = program.getId();
         
         DataEntryForm dataEntryForm = null;
 
@@ -135,24 +134,31 @@
         // Save data-entry-form
         // ---------------------------------------------------------------------
 
+        if ( dataEntryForm == null || dataEntryForm.getHtmlCode() != designTextarea )
+        {
+            program.increaseVersion();
+        }
+        
         designTextarea = dataEntryFormService.prepareDataEntryFormForSave( designTextarea );
 
         if ( dataEntryForm == null )
         {
+            program.increaseVersion();
+            
             dataEntryForm = new DataEntryForm( name, designTextarea );
             dataEntryFormService.addDataEntryForm( dataEntryForm );
         }
         else
         {
+            
             dataEntryForm.setName( name );
             dataEntryForm.setHtmlCode( designTextarea );
             dataEntryFormService.updateDataEntryForm( dataEntryForm );
         }            
-        
+
         programStage.setDataEntryForm( dataEntryForm );
         programStageService.updateProgramStage( programStage );
 
         return SUCCESS;
     }
-    
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/dataentryform/SaveTrackedEntityFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/dataentryform/SaveTrackedEntityFormAction.java	2015-02-18 13:39:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/dataentryform/SaveTrackedEntityFormAction.java	2015-02-18 14:35:39 +0000
@@ -28,8 +28,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.dataentryform.DataEntryForm;
 import org.hisp.dhis.dataentryform.DataEntryFormService;
 import org.hisp.dhis.program.Program;
@@ -47,8 +45,6 @@
 public class SaveTrackedEntityFormAction
     implements Action
 {
-    Log logger = LogFactory.getLog( getClass() );
-
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -169,5 +165,4 @@
 
         return SUCCESS;
     }
-
 }