← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18316: Added interface VersionedObject to program, data set, option set.

 

------------------------------------------------------------
revno: 18316
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-02-18 14:39:52 +0100
message:
  Added interface VersionedObject to program, data set, option set.
added:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/VersionedObject.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionSet.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/RemoveDataElementAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/UpdateDataElementAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/AddSectionAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/RemoveSectionAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/SaveSectionGreyStatusAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/SaveSectionSortOrderAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/UpdateSectionAction.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
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/VersionedObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/VersionedObject.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/VersionedObject.java	2015-02-18 13:39:52 +0000
@@ -0,0 +1,45 @@
+package org.hisp.dhis.common;
+
+/*
+ * Copyright (c) 2004-2015, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Lars Helge Overland
+ */
+public interface VersionedObject
+{
+    /**
+     * Returns the current version.
+     */
+    int getVersion();
+    
+    /**
+     * Increases the version and returns its new version.
+     */
+    int increaseVersion();
+}

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java	2015-02-05 06:53:38 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java	2015-02-18 13:39:52 +0000
@@ -35,12 +35,14 @@
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+
 import org.hisp.dhis.attribute.AttributeValue;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.BaseNameableObject;
 import org.hisp.dhis.common.DxfNamespaces;
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.common.MergeStrategy;
+import org.hisp.dhis.common.VersionedObject;
 import org.hisp.dhis.common.adapter.JacksonPeriodTypeDeserializer;
 import org.hisp.dhis.common.adapter.JacksonPeriodTypeSerializer;
 import org.hisp.dhis.common.annotation.Scanned;
@@ -72,6 +74,7 @@
 @JacksonXmlRootElement( localName = "dataSet", namespace = DxfNamespaces.DXF_2_0 )
 public class DataSet
     extends BaseNameableObject
+    implements VersionedObject
 {
     public static final String TYPE_DEFAULT = "default";
     public static final String TYPE_SECTION = "section";
@@ -139,7 +142,7 @@
     /**
      * Indicating version number.
      */
-    private Integer version;
+    private int version;
 
     /**
      * How many days after period is over will this dataSet auto-lock
@@ -397,10 +400,9 @@
         return dataElements;
     }
 
-    public DataSet increaseVersion()
+    public int increaseVersion()
     {
-        version = version != null ? version + 1 : 1;
-        return this;
+        return ++version;
     }
 
     /**
@@ -576,12 +578,12 @@
     @JsonProperty
     @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
-    public Integer getVersion()
+    public int getVersion()
     {
         return version;
     }
 
-    public void setVersion( Integer version )
+    public void setVersion( int version )
     {
         this.version = version;
     }
@@ -815,12 +817,12 @@
             fieldCombinationRequired = dataSet.isFieldCombinationRequired();
             mobile = dataSet.isMobile();
             validCompleteOnly = dataSet.isValidCompleteOnly();
+            version = dataSet.getVersion();
 
             if ( MergeStrategy.MERGE_ALWAYS.equals( strategy ) )
             {
                 periodType = dataSet.getPeriodType();
                 dataEntryForm = dataSet.getDataEntryForm();
-                version = dataSet.getVersion();
                 legendSet = dataSet.getLegendSet();
                 notificationRecipients = dataSet.getNotificationRecipients();
             }
@@ -828,7 +830,6 @@
             {
                 periodType = dataSet.getPeriodType() == null ? periodType : dataSet.getPeriodType();
                 dataEntryForm = dataSet.getDataEntryForm() == null ? dataEntryForm : dataSet.getDataEntryForm();
-                version = dataSet.getVersion() == null ? version : dataSet.getVersion();
                 legendSet = dataSet.getLegendSet() == null ? legendSet : dataSet.getLegendSet();
                 notificationRecipients = dataSet.getNotificationRecipients() == null ? notificationRecipients : dataSet.getNotificationRecipients();
             }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionSet.java	2015-02-05 06:53:38 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionSet.java	2015-02-18 13:39:52 +0000
@@ -28,24 +28,26 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonView;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.DxfNamespaces;
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.common.MergeStrategy;
+import org.hisp.dhis.common.VersionedObject;
 import org.hisp.dhis.common.annotation.Scanned;
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.common.view.ExportView;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 
 /**
  * @author Lars Helge Overland
@@ -53,16 +55,18 @@
 @JacksonXmlRootElement( localName = "optionSet", namespace = DxfNamespaces.DXF_2_0 )
 public class OptionSet
     extends BaseIdentifiableObject
+    implements VersionedObject
 {
     private static final Pattern OPTION_PATTERN = Pattern.compile( "\\[(.*)\\]" );
 
     @Scanned
     private List<Option> options = new ArrayList<>();
 
-    /**
-     * Indicating version number.
-     */
-    private Integer version = 1;
+    private int version;
+
+    // -------------------------------------------------------------------------
+    // Constructors
+    // -------------------------------------------------------------------------
 
     public OptionSet()
     {
@@ -73,11 +77,47 @@
         this.name = name;
     }
 
+    // -------------------------------------------------------------------------
+    // Logic
+    // -------------------------------------------------------------------------
+
     public void removeAllOptions()
     {
         options.clear();
     }
 
+    public int increaseVersion()
+    {
+        return ++version;
+    }
+
+    public static String optionEncode( String option )
+    {
+        return option != null ? ("[" + option.replaceAll( " ", "_" ) + "]") : null;
+    }
+
+    public static String optionDecode( String option )
+    {
+        Matcher matcher = OPTION_PATTERN.matcher( option );
+        return matcher.find() && matcher.groupCount() > 0 ? matcher.group( 1 ).replaceAll( "_", " " ) : null;
+    }
+
+    public List<String> getOptionValues()
+    {
+        List<String> result = new ArrayList<>();
+
+        for ( Option option : options )
+        {
+            result.add( option.getName() );
+        }
+
+        return result;
+    }
+
+    // -------------------------------------------------------------------------
+    // Getters and setters
+    // -------------------------------------------------------------------------
+
     @JsonProperty
     @JsonSerialize( contentAs = BaseIdentifiableObject.class )
     @JsonView( { DetailedView.class, ExportView.class } )
@@ -94,39 +134,20 @@
     }
 
     @JsonProperty
-    @JacksonXmlProperty( localName = "version", namespace = DxfNamespaces.DXF_2_0 )
-    public Integer getVersion()
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    public int getVersion()
     {
         return version;
     }
 
-    public void setVersion( Integer version )
+    public void setVersion( int version )
     {
         this.version = version;
     }
 
-    public static String optionEncode( String option )
-    {
-        return option != null ? ("[" + option.replaceAll( " ", "_" ) + "]") : null;
-    }
-
-    public static String optionDecode( String option )
-    {
-        Matcher matcher = OPTION_PATTERN.matcher( option );
-        return matcher.find() && matcher.groupCount() > 0 ? matcher.group( 1 ).replaceAll( "_", " " ) : null;
-    }
-
-    public List<String> getOptionValues()
-    {
-        List<String> result = new ArrayList<>();
-
-        for ( Option option : options )
-        {
-            result.add( option.getName() );
-        }
-
-        return result;
-    }
+    // -------------------------------------------------------------------------
+    // Merge with
+    // -------------------------------------------------------------------------
 
     @Override
     public void mergeWith( IdentifiableObject other, MergeStrategy strategy )
@@ -137,15 +158,8 @@
         {
             OptionSet optionSet = (OptionSet) other;
 
-            if ( MergeStrategy.MERGE_ALWAYS.equals( strategy ) )
-            {
-                version = optionSet.getVersion();
-            }
-            else if ( MergeStrategy.MERGE_IF_NOT_NULL.equals( strategy ) )
-            {
-                version = optionSet.getVersion() == null ? version : optionSet.getVersion();
-            }
-
+            version = optionSet.getVersion();
+            
             removeAllOptions();
             options.addAll( optionSet.getOptions() );
         }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java	2015-02-05 06:53:38 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java	2015-02-18 13:39:52 +0000
@@ -34,11 +34,13 @@
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+
 import org.hisp.dhis.attribute.AttributeValue;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.DxfNamespaces;
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.common.MergeStrategy;
+import org.hisp.dhis.common.VersionedObject;
 import org.hisp.dhis.common.annotation.Scanned;
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.common.view.ExportView;
@@ -65,6 +67,7 @@
 @JacksonXmlRootElement( localName = "program", namespace = DxfNamespaces.DXF_2_0 )
 public class Program
     extends BaseIdentifiableObject
+    implements VersionedObject
 {
     public static final List<String> TYPE_LOOKUP = Arrays.asList( "", "MULTIPLE_EVENTS_WITH_REGISTRATION",
         "SINGLE_EVENT_WITH_REGISTRATION", "SINGLE_EVENT_WITHOUT_REGISTRATION" );
@@ -75,7 +78,7 @@
 
     private String description;
 
-    private Integer version;
+    private int version;
 
     private String dateOfEnrollmentDescription;
 
@@ -214,12 +217,11 @@
         return null;
     }
 
-    public Program increaseVersion()
+    public int increaseVersion()
     {
-        version = version != null ? version + 1 : 1;
-        return this;
+        return ++version;
     }
-
+    
     // -------------------------------------------------------------------------
     // Getters and setters
     // -------------------------------------------------------------------------
@@ -241,12 +243,12 @@
     @JsonProperty
     @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
-    public Integer getVersion()
+    public int getVersion()
     {
         return version;
     }
 
-    public void setVersion( Integer version )
+    public void setVersion( int version )
     {
         this.version = version;
     }
@@ -570,10 +572,11 @@
         {
             Program program = (Program) other;
 
+            version = program.getVersion();
+            
             if ( MergeStrategy.MERGE_ALWAYS.equals( strategy ) )
             {
                 description = program.getDescription();
-                version = program.getVersion();
                 dateOfEnrollmentDescription = program.getDateOfEnrollmentDescription();
                 dateOfIncidentDescription = program.getDateOfIncidentDescription();
                 type = program.getType();
@@ -591,8 +594,7 @@
             }
             else if ( MergeStrategy.MERGE_IF_NOT_NULL.equals( strategy ) )
             {
-                description = program.getDescription() == null ? description : program.getDescription();
-                version = program.getVersion() == null ? version : program.getVersion();
+                description = program.getDescription() == null ? description : program.getDescription();                
                 dateOfEnrollmentDescription = program.getDateOfEnrollmentDescription() == null ? dateOfEnrollmentDescription : program.getDateOfEnrollmentDescription();
                 dateOfIncidentDescription = program.getDateOfIncidentDescription() == null ? dateOfIncidentDescription : program.getDateOfIncidentDescription();
                 type = program.getType() == null ? type : program.getType();

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2015-02-16 14:25:40 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2015-02-18 13:39:52 +0000
@@ -711,7 +711,9 @@
 
         executeSql( "UPDATE dashboard SET publicaccess='--------' WHERE publicaccess is null" );
 
-        executeSql( "UPDATE optionset SET version=1 WHERE version IS NULL" );
+        executeSql( "UPDATE optionset SET version=0 WHERE version IS NULL" );
+        executeSql( "UPDATE dataset SET version=0 WHERE version IS NULL" );
+        executeSql( "UPDATE program SET version=0 WHERE version IS NULL" );
 
         executeSql( "ALTER TABLE datavalue ALTER COLUMN lastupdated TYPE timestamp" );
         executeSql( "ALTER TABLE completedatasetregistration ALTER COLUMN date TYPE timestamp" );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/RemoveDataElementAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/RemoveDataElementAction.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/RemoveDataElementAction.java	2015-02-18 13:39:52 +0000
@@ -105,7 +105,8 @@
             
             for ( DataSet dataSet : dataElement.getDataSets() )
             {
-                dataSetService.updateDataSet( dataSet.increaseVersion() );
+                dataSet.increaseVersion();
+                dataSetService.updateDataSet( dataSet );
             }
             
             dataElementService.deleteDataElement( dataElementService.getDataElement( id ) );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/UpdateDataElementAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/UpdateDataElementAction.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/UpdateDataElementAction.java	2015-02-18 13:39:52 +0000
@@ -325,7 +325,8 @@
 
         for ( DataSet dataSet : dataSets )
         {
-            dataSetService.updateDataSet( dataSet.increaseVersion() );
+            dataSet.increaseVersion();
+            dataSetService.updateDataSet( dataSet );
         }
 
         for ( int i = 0; i < dataElementGroupSets.size(); i++ )

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/AddSectionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/AddSectionAction.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/AddSectionAction.java	2015-02-18 13:39:52 +0000
@@ -170,7 +170,8 @@
         dataSet.getSections().add( section );
         sectionService.addSection( section );
 
-        dataSetService.updateDataSet( dataSet.increaseVersion() );
+        dataSet.increaseVersion();
+        dataSetService.updateDataSet( dataSet );
         
         return SUCCESS;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/RemoveSectionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/RemoveSectionAction.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/RemoveSectionAction.java	2015-02-18 13:39:52 +0000
@@ -79,7 +79,9 @@
         
         DataSet dataSet = section.getDataSet();
 
-        dataSetService.updateDataSet( dataSet.increaseVersion() );
+        dataSet.increaseVersion();
+        
+        dataSetService.updateDataSet( dataSet );
         
         sectionService.deleteSection( section );
         

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/SaveSectionGreyStatusAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/SaveSectionGreyStatusAction.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/SaveSectionGreyStatusAction.java	2015-02-18 13:39:52 +0000
@@ -191,7 +191,10 @@
         sectionService.updateSection( section );       
 
         DataSet dataSet = section.getDataSet();
-        dataSetService.updateDataSet( dataSet.increaseVersion() ); // Update version
+        
+        dataSet.increaseVersion();
+        
+        dataSetService.updateDataSet( dataSet );
         
         return SUCCESS;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/SaveSectionSortOrderAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/SaveSectionSortOrderAction.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/SaveSectionSortOrderAction.java	2015-02-18 13:39:52 +0000
@@ -121,7 +121,9 @@
         
         if ( update )
         {
-            dataSetService.updateDataSet( dataSet.increaseVersion() );
+            dataSet.increaseVersion();
+            
+            dataSetService.updateDataSet( dataSet );
         }
         
         return SUCCESS;

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/UpdateSectionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/UpdateSectionAction.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/UpdateSectionAction.java	2015-02-18 13:39:52 +0000
@@ -156,7 +156,9 @@
             if ( !( equalsNullSafe( sectionName, section.getName() ) && 
                 dataElements.equals( section.getDataElements() ) && indicators.equals( section.getIndicators() ) ) )
             {
-                dataSetService.updateDataSet( dataSet.increaseVersion() );
+                dataSet.increaseVersion();
+                
+                dataSetService.updateDataSet( dataSet );
             }
         }
 

=== 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-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/SaveTrackedEntityFormAction.java	2015-02-18 13:39:52 +0000
@@ -141,6 +141,7 @@
             {
                 registrationForm.setProgram( program );
             }
+            
             formService.saveTrackedEntityForm( registrationForm );
         }
         else
@@ -157,6 +158,7 @@
                 dataEntryForm.setHtmlCode( designTextarea );
                 dataEntryFormService.updateDataEntryForm( dataEntryForm );
             }
+            
             registrationForm.setDataEntryForm( dataEntryForm );
             formService.updateTrackedEntityForm( registrationForm );
         }