← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16002: Data set resource, updating version of data set when updating custom form

 

------------------------------------------------------------
revno: 16002
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-07-07 17:02:50 +0200
message:
  Data set resource, updating version of data set when updating custom form
modified:
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/SpringDataValueSetStore.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataSetController.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/SaveDataEntryFormAction.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/datavalueset/SpringDataValueSetStore.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/SpringDataValueSetStore.java	2014-07-07 11:22:34 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/SpringDataValueSetStore.java	2014-07-07 15:02:50 +0000
@@ -69,6 +69,7 @@
     // DataValueSetStore implementation
     //--------------------------------------------------------------------------
 
+    @Override
     public void writeDataValueSetXml( DataSet dataSet, Date completeDate, Period period, OrganisationUnit orgUnit,
         Set<DataElement> dataElements, Set<Period> periods, Set<OrganisationUnit> orgUnits, OutputStream out )
     {
@@ -80,7 +81,8 @@
     }
 
     @Override
-    public void writeDataValueSetJson( DataSet dataSet, Date completeDate, Period period, OrganisationUnit orgUnit, Set<DataElement> dataElements, Set<Period> periods, Set<OrganisationUnit> orgUnits, OutputStream outputStream )
+    public void writeDataValueSetJson( DataSet dataSet, Date completeDate, Period period, OrganisationUnit orgUnit, 
+        Set<DataElement> dataElements, Set<Period> periods, Set<OrganisationUnit> orgUnits, OutputStream outputStream )
     {
         DataValueSet dataValueSet = new StreamingJsonDataValueSet( outputStream );
 
@@ -89,6 +91,7 @@
         StreamUtils.closeOutputStream( outputStream );
     }
 
+    @Override
     public void writeDataValueSetCsv( Set<DataElement> dataElements, Set<Period> periods, Set<OrganisationUnit> orgUnits, Writer writer )
     {
         DataValueSet dataValueSet = new StreamingCsvDataValueSet( new CsvWriter( writer, CSV_DELIM ) );
@@ -96,6 +99,10 @@
         writeDataValueSet( null, null, null, null, dataElements, periods, orgUnits, dataValueSet );
     }
 
+    //--------------------------------------------------------------------------
+    // Supportive methods
+    //--------------------------------------------------------------------------
+
     private void writeDataValueSet( DataSet dataSet, Date completeDate, Period period, OrganisationUnit orgUnit,
         Set<DataElement> dataElements, Set<Period> periods, Set<OrganisationUnit> orgUnits, DataValueSet dataValueSet )
     {

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataSetController.java	2014-06-11 20:27:54 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataSetController.java	2014-07-07 15:02:50 +0000
@@ -250,15 +250,16 @@
         {
             form = new DataEntryForm( dataSet.getName(), DataEntryForm.STYLE_REGULAR, formContent );
             dataEntryFormService.addDataEntryForm( form );
-
             dataSet.setDataEntryForm( form );
-            dataSetService.updateDataSet( dataSet );
         }
         else
         {
             form.setHtmlCode( formContent );
             dataEntryFormService.updateDataEntryForm( form );
         }
+
+        dataSet.increaseVersion(); 
+        dataSetService.updateDataSet( dataSet );        
     }
 
     /**

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/SaveDataEntryFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/SaveDataEntryFormAction.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/SaveDataEntryFormAction.java	2014-07-07 15:02:50 +0000
@@ -99,24 +99,24 @@
     public String execute()
         throws Exception
     {
-        DataSet dataset = dataSetService.getDataSet( dataSetIdField );
+        DataSet dataSet = dataSetService.getDataSet( dataSetIdField );
 
         designTextarea = dataEntryFormService.prepareDataEntryFormForSave( designTextarea );
         
-        DataEntryForm form = dataset.getDataEntryForm();
+        DataEntryForm form = dataSet.getDataEntryForm();
 
         if ( form == null || form.getHtmlCode() == null ||
             ( form.getStyle() != null && !form.getStyle().equals( style ) ) ||
             ( form.getHtmlCode() != null && !form.getHtmlCode().equals( designTextarea ) ) )
         {
-            dataset.increaseVersion(); // Check if version must be updated
+            dataSet.increaseVersion(); // Check if version must be updated
         }
         
         if ( form == null )
         {
             form = new DataEntryForm( nameField, style, dataEntryFormService.prepareDataEntryFormForSave( designTextarea ) );
             dataEntryFormService.addDataEntryForm( form );
-            dataset.setDataEntryForm( form );
+            dataSet.setDataEntryForm( form );
         }
         else
         {
@@ -126,7 +126,7 @@
             dataEntryFormService.updateDataEntryForm( form );
         }
         
-        dataSetService.updateDataSet( dataset );
+        dataSetService.updateDataSet( dataSet );
 
         return SUCCESS;
     }