← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6538: more implementations of Mergeable

 

------------------------------------------------------------
revno: 6538
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-04-11 01:32:58 +0300
message:
  more implementations of Mergeable
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/Attribute.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/document/Document.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Report.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlView.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRule.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRuleGroup.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-api/src/main/java/org/hisp/dhis/attribute/Attribute.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/Attribute.java	2012-03-27 17:38:48 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/Attribute.java	2012-04-10 22:32:58 +0000
@@ -33,6 +33,7 @@
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.common.view.ExportView;
 
@@ -80,7 +81,7 @@
 
     @JsonProperty
     @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlProperty(namespace = Dxf2Namespace.NAMESPACE)
+    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
     public String getValueType()
     {
         return valueType;
@@ -93,7 +94,7 @@
 
     @JsonProperty
     @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlProperty(namespace = Dxf2Namespace.NAMESPACE)
+    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
     public boolean isMandatory()
     {
         return mandatory;
@@ -106,7 +107,7 @@
 
     @JsonProperty
     @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlProperty(namespace = Dxf2Namespace.NAMESPACE)
+    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
     public boolean isDataElementAttribute()
     {
         return dataElementAttribute;
@@ -119,7 +120,7 @@
 
     @JsonProperty
     @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlProperty(namespace = Dxf2Namespace.NAMESPACE)
+    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
     public boolean isIndicatorAttribute()
     {
         return indicatorAttribute;
@@ -132,7 +133,7 @@
 
     @JsonProperty
     @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlProperty(namespace = Dxf2Namespace.NAMESPACE)
+    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
     public boolean isOrganisationUnitAttribute()
     {
         return organisationUnitAttribute;
@@ -145,7 +146,7 @@
 
     @JsonProperty
     @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlProperty(namespace = Dxf2Namespace.NAMESPACE)
+    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
     public boolean isUserAttribute()
     {
         return userAttribute;
@@ -175,4 +176,33 @@
     {
         this.sortOrder = sortOrder;
     }
+
+    @Override
+    public void mergeWith( IdentifiableObject other )
+    {
+        super.mergeWith( other );
+
+        if ( other.getClass().isInstance( this ) )
+        {
+            Attribute attribute = (Attribute) other;
+
+            valueType = valueType != null ? valueType : attribute.getValueType();
+            dataElementAttribute = attribute.isDataElementAttribute();
+            indicatorAttribute = attribute.isIndicatorAttribute();
+            organisationUnitAttribute = attribute.isOrganisationUnitAttribute();
+            userAttribute = attribute.isUserAttribute();
+            mandatory = attribute.isMandatory();
+            sortOrder = sortOrder != null ? sortOrder : attribute.getSortOrder();
+
+            for ( AttributeValue attributeValue : attribute.getAttributeValues() )
+            {
+                attributeValues.add( attributeValue );
+
+                if ( attributeValue.getAttribute() == null )
+                {
+                    attributeValue.setAttribute( this );
+                }
+            }
+        }
+    }
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java	2012-03-27 20:10:41 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java	2012-04-10 22:32:58 +0000
@@ -36,6 +36,7 @@
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.common.NameableObject;
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.common.view.ExportView;
@@ -646,4 +647,53 @@
     {
         this.organisationUnit = organisationUnit;
     }
+
+    @Override
+    public void mergeWith( IdentifiableObject other )
+    {
+        super.mergeWith( other );
+
+        if ( other.getClass().isInstance( this ) )
+        {
+            Chart chart = (Chart) other;
+
+            domainAxisLabel = domainAxisLabel != null ? domainAxisLabel : chart.getDomainAxisLabel();
+            rangeAxisLabel = rangeAxisLabel != null ? rangeAxisLabel : chart.getRangeAxisLabel();
+            type = type != null ? type : chart.getType();
+            series = series != null ? series : chart.getSeries();
+            category = category != null ? category : chart.getCategory();
+            filter = filter != null ? filter : chart.getFilter();
+            hideLegend = chart.isHideLegend();
+            regression = chart.isRegression();
+            hideSubtitle = chart.isHideSubtitle();
+            targetLineValue = targetLineValue != null ? targetLineValue : chart.getTargetLineValue();
+            targetLineLabel = targetLineLabel != null ? targetLineLabel : chart.getTargetLineLabel();
+            baseLineValue = baseLineValue != null ? baseLineValue : chart.getBaseLineValue();
+            baseLineLabel = baseLineLabel != null ? baseLineLabel : chart.getBaseLineLabel();
+            relatives = relatives != null ? relatives : chart.getRelatives();
+            userOrganisationUnit = chart.isUserOrganisationUnit();
+            user = user != null ? user : chart.getUser();
+            organisationUnitGroupSet = organisationUnitGroupSet != null ? organisationUnitGroupSet : chart.getOrganisationUnitGroupSet();
+
+            for ( Indicator indicator : chart.getIndicators() )
+            {
+                indicators.add( indicator );
+            }
+
+            for ( DataElement dataElement : chart.getDataElements() )
+            {
+                dataElements.add( dataElement );
+            }
+
+            for ( DataSet dataSet : chart.getDataSets() )
+            {
+                dataSets.add( dataSet );
+            }
+
+            for ( OrganisationUnit organisationUnit : chart.getOrganisationUnits() )
+            {
+                organisationUnits.add( organisationUnit );
+            }
+        }
+    }
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/document/Document.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/document/Document.java	2012-03-27 17:38:48 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/document/Document.java	2012-04-10 22:32:58 +0000
@@ -6,6 +6,7 @@
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.common.view.ExportView;
 
@@ -128,4 +129,19 @@
     {
         this.contentType = contentType;
     }
+
+    @Override
+    public void mergeWith( IdentifiableObject other )
+    {
+        super.mergeWith( other );
+
+        if ( other.getClass().isInstance( this ) )
+        {
+            Document document = (Document) other;
+
+            url = url != null ? url : document.getUrl();
+            contentType = contentType != null ? contentType : document.getContentType();
+            external = document.isExternal();
+        }
+    }
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Report.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Report.java	2012-03-28 09:59:27 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Report.java	2012-04-10 22:32:58 +0000
@@ -34,6 +34,7 @@
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.common.view.ExportView;
 import org.hisp.dhis.reporttable.ReportTable;
@@ -167,4 +168,19 @@
     {
         this.usingOrgUnitGroupSets = usingOrgUnitGroupSets;
     }
+
+    @Override
+    public void mergeWith( IdentifiableObject other )
+    {
+        super.mergeWith( other );
+
+        if ( other.getClass().isInstance( this ) )
+        {
+            Report report = (Report) other;
+
+            designContent = designContent != null ? designContent : report.getDesignContent();
+            reportTable = reportTable != null ? reportTable : report.getReportTable();
+            usingOrgUnitGroupSets = usingOrgUnitGroupSets != null ? usingOrgUnitGroupSets : report.isUsingOrganisationUnitGroupSets();
+        }
+    }
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java	2012-04-05 11:57:23 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java	2012-04-10 22:32:58 +0000
@@ -35,10 +35,7 @@
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import org.apache.commons.lang.StringUtils;
-import org.hisp.dhis.common.BaseIdentifiableObject;
-import org.hisp.dhis.common.CombinationGenerator;
-import org.hisp.dhis.common.Dxf2Namespace;
-import org.hisp.dhis.common.NameableObject;
+import org.hisp.dhis.common.*;
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.common.view.ExportView;
 import org.hisp.dhis.dataelement.DataElement;
@@ -77,33 +74,33 @@
     public static final String DATAELEMENT_ID = "dataelementid";
     public static final String CATEGORYCOMBO_ID = "categoryoptioncomboid";
     public static final String CATEGORYOPTION_ID = "categoryoptionid";
-    
+
     public static final String INDICATOR_ID = "indicatorid";
     public static final String INDICATOR_UID = "indicatoruid";
     public static final String INDICATOR_NAME = "indicatorname";
     public static final String INDICATOR_CODE = "indicatorcode";
     public static final String INDICATOR_DESCRIPTION = "indicatordescription";
-    
+
     public static final String DATASET_ID = "datasetid";
-    
+
     public static final String PERIOD_ID = "periodid";
     public static final String PERIOD_UID = "perioduid";
     public static final String PERIOD_NAME = "periodname";
     public static final String PERIOD_CODE = "periodcode";
     public static final String PERIOD_DESCRIPTION = "perioddescription";
-    
+
     public static final String ORGANISATIONUNIT_ID = "organisationunitid";
     public static final String ORGANISATIONUNIT_UID = "organisationunituid";
     public static final String ORGANISATIONUNIT_NAME = "organisationunitname";
     public static final String ORGANISATIONUNIT_CODE = "organisationunitcode";
     public static final String ORGANISATIONUNIT_DESCRIPTION = "organisationunitdescription";
-    
+
     public static final String ORGANISATIONUNITGROUP_ID = "organisationunitgroupid";
     public static final String ORGANISATIONUNITGROUP_UID = "organisationunitgroupuid";
     public static final String ORGANISATIONUNITGROUP_NAME = "organisationunitgroupname";
     public static final String ORGANISATIONUNITGROUP_CODE = "organisationunitgroupcode";
     public static final String ORGANISATIONUNITGROUP_DESCRIPTION = "organisationunitgroupdescription";
-    
+
     public static final String REPORTING_MONTH_COLUMN_NAME = "reporting_month_name";
     public static final String PARAM_ORGANISATIONUNIT_COLUMN_NAME = "param_organisationunit_name";
     public static final String ORGANISATION_UNIT_IS_PARENT_COLUMN_NAME = "organisation_unit_is_parent";
@@ -123,31 +120,31 @@
     {
         {
             put( CATEGORYCOMBO_ID, "Category combination ID" );
-            
+
             put( INDICATOR_ID, "Indicator ID" );
             put( INDICATOR_UID, "Indicator UID" );
             put( INDICATOR_NAME, "Indicator" );
             put( INDICATOR_CODE, "Indicator code" );
             put( INDICATOR_DESCRIPTION, "Indicator description" );
-            
+
             put( PERIOD_ID, "Period ID" );
             put( PERIOD_UID, "Period UID" );
             put( PERIOD_NAME, "Period" );
             put( PERIOD_CODE, "Period code" );
             put( PERIOD_DESCRIPTION, "Period description" );
-            
+
             put( ORGANISATIONUNIT_ID, "Organisation unit ID" );
             put( ORGANISATIONUNIT_UID, "Organisation unit UID" );
             put( ORGANISATIONUNIT_NAME, "Organisation unit" );
             put( ORGANISATIONUNIT_CODE, "Organisation unit code" );
             put( ORGANISATIONUNIT_DESCRIPTION, "Organisation unit description" );
-            
+
             put( ORGANISATIONUNITGROUP_ID, "Organisation unit group ID" );
             put( ORGANISATIONUNITGROUP_UID, "Organisation unit group UID" );
             put( ORGANISATIONUNITGROUP_NAME, "Organisation unit group" );
             put( ORGANISATIONUNITGROUP_CODE, "Organisation unit group code" );
             put( ORGANISATIONUNITGROUP_DESCRIPTION, "Organisation unit group description" );
-            
+
             put( REPORTING_MONTH_COLUMN_NAME, "Reporting month" );
             put( PARAM_ORGANISATIONUNIT_COLUMN_NAME, "Organisation unit parameter" );
             put( ORGANISATION_UNIT_IS_PARENT_COLUMN_NAME, "Organisation unit is parent" );
@@ -466,19 +463,19 @@
         add( indexColumns, INDICATOR_ID, doIndicators );
         add( indexColumns, PERIOD_ID, doPeriods );
         add( indexColumns, ORGANISATIONUNIT_ID, doUnits );
-        
+
         add( indexUidColumns, INDICATOR_UID, doIndicators );
         add( indexUidColumns, PERIOD_UID, doPeriods );
         add( indexUidColumns, ORGANISATIONUNIT_UID, doUnits );
-        
+
         add( indexNameColumns, INDICATOR_NAME, doIndicators );
         add( indexNameColumns, PERIOD_NAME, doPeriods );
         add( indexNameColumns, ORGANISATIONUNIT_NAME, doUnits );
-        
+
         add( indexCodeColumns, INDICATOR_CODE, doIndicators );
         add( indexCodeColumns, PERIOD_CODE, doPeriods );
         add( indexCodeColumns, ORGANISATIONUNIT_CODE, doUnits );
-        
+
         add( indexDescriptionColumns, INDICATOR_DESCRIPTION, doIndicators );
         add( indexDescriptionColumns, PERIOD_DESCRIPTION, doPeriods );
         add( indexDescriptionColumns, ORGANISATIONUNIT_DESCRIPTION, doUnits );
@@ -1248,4 +1245,56 @@
     {
         this.categoryOptionCombos = categoryOptionCombos;
     }
+
+    @Override
+    public void mergeWith( IdentifiableObject other )
+    {
+        super.mergeWith( other );
+
+        if ( other.getClass().isInstance( this ) )
+        {
+            ReportTable reportTable = (ReportTable) other;
+
+            regression = reportTable.isRegression();
+            cumulative = reportTable.isCumulative();
+            categoryCombo = categoryCombo != null ? categoryCombo : reportTable.getCategoryCombo();
+            doIndicators = reportTable.isDoIndicators();
+            doPeriods = reportTable.isDoPeriods();
+            doUnits = reportTable.isDoUnits();
+            relatives = relatives != null ? relatives : reportTable.getRelatives();
+            reportParams = reportParams != null ? reportParams : reportTable.getReportParams();
+            sortOrder = sortOrder != null ? sortOrder : reportTable.getSortOrder();
+            topLimit = topLimit != null ? topLimit : reportTable.getTopLimit();
+
+            for ( OrganisationUnitGroup organisationUnitGroup : reportTable.getOrganisationUnitGroups() )
+            {
+                organisationUnitGroups.add( organisationUnitGroup );
+            }
+
+            for ( OrganisationUnit organisationUnit : reportTable.getUnits() )
+            {
+                units.add( organisationUnit );
+            }
+
+            for ( Period period : reportTable.getPeriods() )
+            {
+                periods.add( period );
+            }
+
+            for ( DataSet dataSet : reportTable.getDataSets() )
+            {
+                dataSets.add( dataSet );
+            }
+
+            for ( Indicator indicator : reportTable.getIndicators() )
+            {
+                indicators.add( indicator );
+            }
+
+            for ( DataElement dataElement : reportTable.getDataElements() )
+            {
+                dataElements.add( dataElement );
+            }
+        }
+    }
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlView.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlView.java	2012-03-27 17:38:48 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlView.java	2012-04-10 22:32:58 +0000
@@ -33,6 +33,7 @@
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.common.view.ExportView;
 
@@ -113,7 +114,7 @@
 
     @JsonProperty
     @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlProperty(namespace = Dxf2Namespace.NAMESPACE)
+    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
     public String getDescription()
     {
         return description;
@@ -126,7 +127,7 @@
 
     @JsonProperty
     @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlProperty(namespace = Dxf2Namespace.NAMESPACE)
+    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
     public String getSqlQuery()
     {
         return sqlQuery;
@@ -136,4 +137,18 @@
     {
         this.sqlQuery = sqlQuery;
     }
+
+    @Override
+    public void mergeWith( IdentifiableObject other )
+    {
+        super.mergeWith( other );
+
+        if ( other.getClass().isInstance( this ) )
+        {
+            SqlView sqlView = (SqlView) other;
+
+            description = description != null ? description : sqlView.getDescription();
+            sqlQuery = sqlQuery != null ? sqlQuery : sqlView.getSqlQuery();
+        }
+    }
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRule.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRule.java	2012-03-27 17:38:48 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRule.java	2012-04-10 22:32:58 +0000
@@ -36,6 +36,7 @@
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.common.adapter.JacksonPeriodTypeDeserializer;
 import org.hisp.dhis.common.adapter.JacksonPeriodTypeSerializer;
 import org.hisp.dhis.common.view.DetailedView;
@@ -136,6 +137,18 @@
         this.rightSide = null;
     }
 
+    public void addValidationRuleGroup( ValidationRuleGroup validationRuleGroup )
+    {
+        groups.add( validationRuleGroup );
+        validationRuleGroup.getMembers().add( this );
+    }
+
+    public void removeValidationRuleGroup( ValidationRuleGroup validationRuleGroup )
+    {
+        groups.remove( validationRuleGroup );
+        validationRuleGroup.getMembers().remove( this );
+    }
+
     // -------------------------------------------------------------------------
     // Set and get methods
     // -------------------------------------------------------------------------  
@@ -235,4 +248,26 @@
         this.groups = groups;
     }
 
+    @Override
+    public void mergeWith( IdentifiableObject other )
+    {
+        super.mergeWith( other );
+
+        if ( other.getClass().isInstance( this ) )
+        {
+            ValidationRule validationRule = (ValidationRule) other;
+
+            description = description != null ? description : validationRule.getDescription();
+            type = type != null ? type : validationRule.getType();
+            operator = operator != null ? operator : validationRule.getOperator();
+            leftSide = leftSide != null ? leftSide : validationRule.getLeftSide();
+            rightSide = rightSide != null ? rightSide : validationRule.getRightSide();
+            periodType = periodType != null ? periodType : validationRule.getPeriodType();
+
+            for ( ValidationRuleGroup validationRuleGroup : validationRule.getGroups() )
+            {
+                addValidationRuleGroup( validationRuleGroup );
+            }
+        }
+    }
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRuleGroup.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRuleGroup.java	2012-03-27 17:38:48 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRuleGroup.java	2012-04-10 22:32:58 +0000
@@ -35,6 +35,7 @@
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.common.view.ExportView;
 
@@ -73,6 +74,22 @@
     }
 
     // -------------------------------------------------------------------------
+    // Logic
+    // -------------------------------------------------------------------------
+
+    public void addValidationRule( ValidationRule validationRule )
+    {
+        members.add( validationRule );
+        validationRule.getGroups().add( this );
+    }
+
+    public void removeValidationRule( ValidationRule validationRule )
+    {
+        members.remove( validationRule );
+        validationRule.getGroups().remove( this );
+    }
+
+    // -------------------------------------------------------------------------
     // hashCode, equals and toString
     // -------------------------------------------------------------------------     
 
@@ -138,4 +155,22 @@
     {
         this.members = members;
     }
+
+    @Override
+    public void mergeWith( IdentifiableObject other )
+    {
+        super.mergeWith( other );
+
+        if ( other.getClass().isInstance( this ) )
+        {
+            ValidationRuleGroup validationRuleGroup = (ValidationRuleGroup) other;
+
+            description = description != null ? description : validationRuleGroup.getDescription();
+
+            for ( ValidationRule validationRule : validationRuleGroup.getMembers() )
+            {
+                addValidationRule( validationRule );
+            }
+        }
+    }
 }