=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java 2012-04-04 09:58:08 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java 2012-04-11 07:28:51 +0000 @@ -37,6 +37,7 @@ import org.hisp.dhis.common.BaseIdentifiableObject; import org.hisp.dhis.common.BaseNameableObject; 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.dataset.DataSet; @@ -262,6 +263,18 @@ } } + public void addDataSet( DataSet dataSet ) + { + dataSets.add( dataSet ); + dataSet.getDataElements().add( this ); + } + + public void removeDataSet( DataSet dataSet ) + { + dataSets.remove( dataSet ); + dataSet.getDataElements().remove( this ); + } + /** * Returns the value type. If value type is int and the number type exists, * the number type is returned, if the type is int and the number type does @@ -585,4 +598,40 @@ { this.optionSet = optionSet; } + + @Override + public void mergeWith( IdentifiableObject other ) + { + super.mergeWith( other ); + + if ( other.getClass().isInstance( this ) ) + { + DataElement dataElement = (DataElement) other; + + formName = dataElement.getFormName() == null ? formName : dataElement.getFormName(); + active = dataElement.isActive(); + zeroIsSignificant = dataElement.isZeroIsSignificant(); + domainType = dataElement.getDomainType() == null ? domainType : dataElement.getDomainType(); + type = dataElement.getType() == null ? type : dataElement.getType(); + numberType = dataElement.getNumberType() == null ? numberType : dataElement.getNumberType(); + aggregationOperator = dataElement.getAggregationOperator() == null ? aggregationOperator : dataElement.getAggregationOperator(); + categoryCombo = dataElement.getCategoryCombo() == null ? categoryCombo : dataElement.getCategoryCombo(); + sortOrder = dataElement.getSortOrder() == null ? sortOrder : dataElement.getSortOrder(); + url = dataElement.getUrl() == null ? url : dataElement.getUrl(); + optionSet = dataElement.getOptionSet() == null ? optionSet : dataElement.getOptionSet(); + + aggregationLevels.addAll( dataElement.getAggregationLevels() ); + attributeValues.addAll( dataElement.getAttributeValues() ); + + for ( DataElementGroup dataElementGroup : dataElement.getGroups() ) + { + addDataElementGroup( dataElementGroup ); + } + + for ( DataSet dataSet : dataElement.getDataSets() ) + { + addDataSet( dataSet ); + } + } + } } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroup.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroup.java 2012-03-27 17:38:48 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroup.java 2012-04-11 07:28:51 +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; @@ -173,4 +174,18 @@ { this.groupSet = groupSet; } + + @Override + public void mergeWith( IdentifiableObject other ) + { + super.mergeWith( other ); + + if ( other.getClass().isInstance( this ) ) + { + DataElementGroup dataElementGroup = (DataElementGroup) other; + + members.addAll( dataElementGroup.getMembers() ); + groupSet = groupSet != null ? groupSet : dataElementGroup.getGroupSet(); + } + } } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroupSet.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroupSet.java 2012-03-27 17:38:48 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroupSet.java 2012-04-11 07:28:51 +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.comparator.IdentifiableObjectNameComparator; import org.hisp.dhis.common.view.DetailedView; import org.hisp.dhis.common.view.ExportView; @@ -243,4 +244,28 @@ { this.members = members; } + + @Override + public void mergeWith( IdentifiableObject other ) + { + super.mergeWith( other ); + + if ( other.getClass().isInstance( this ) ) + { + DataElementGroupSet dataElementGroupSet = (DataElementGroupSet) other; + + description = dataElementGroupSet.getDescription() == null ? description : dataElementGroupSet.getDescription(); + compulsory = dataElementGroupSet.isCompulsory() == null ? compulsory : dataElementGroupSet.isCompulsory(); + + for ( DataElementGroup dataElementGroup : dataElementGroupSet.getMembers() ) + { + members.add( dataElementGroup ); + + if ( dataElementGroup.getGroupSet() == null ) + { + dataElementGroup.setGroupSet( this ); + } + } + } + } } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/Indicator.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/Indicator.java 2012-04-11 04:56:20 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/Indicator.java 2012-04-11 07:28:51 +0000 @@ -363,6 +363,8 @@ explodedDenominator = indicator.getExplodedDenominator() == null ? explodedDenominator : indicator.getExplodedDenominator(); indicatorType = indicator.getIndicatorType() == null ? indicatorType : indicator.getIndicatorType(); + attributeValues.addAll( indicator.getAttributeValues() ); + for ( DataSet dataSet : indicator.getDataSets() ) { addDataSet( dataSet ); @@ -373,10 +375,6 @@ addIndicatorGroup( indicatorGroup ); } - for ( AttributeValue attributeValue : indicator.getAttributeValues() ) - { - attributeValues.add( attributeValue ); - } } } } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLayer.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLayer.java 2012-03-27 17:38:48 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLayer.java 2012-04-11 07:28:51 +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; @@ -217,4 +218,24 @@ { this.strokeWidth = strokeWidth; } + + @Override + public void mergeWith( IdentifiableObject other ) + { + super.mergeWith( other ); + + if ( other.getClass().isInstance( this ) ) + { + MapLayer mapLayer = (MapLayer) other; + + type = mapLayer.getType() == null ? type : mapLayer.getType(); + url = mapLayer.getUrl() == null ? url : mapLayer.getUrl(); + layers = mapLayer.getLayers() == null ? layers : mapLayer.getLayers(); + time = mapLayer.getTime() == null ? time : mapLayer.getTime(); + fillColor = mapLayer.getFillColor() == null ? fillColor : mapLayer.getFillColor(); + fillOpacity = mapLayer.getFillOpacity(); + strokeColor = mapLayer.getStrokeColor() == null ? strokeColor : mapLayer.getStrokeColor(); + strokeWidth = mapLayer.getStrokeWidth(); + } + } } \ No newline at end of file === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegend.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegend.java 2012-03-27 17:38:48 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegend.java 2012-04-11 07:28:51 +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; @@ -152,4 +153,20 @@ { this.image = image; } + + @Override + public void mergeWith( IdentifiableObject other ) + { + super.mergeWith( other ); + + if ( other.getClass().isInstance( this ) ) + { + MapLegend mapLegend = (MapLegend) other; + + startValue = mapLegend.getStartValue() == null ? startValue : mapLegend.getStartValue(); + endValue = mapLegend.getEndValue() == null ? endValue : mapLegend.getEndValue(); + color = mapLegend.getColor() == null ? color : mapLegend.getColor(); + image = mapLegend.getImage() == null ? image : mapLegend.getImage(); + } + } } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendSet.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendSet.java 2012-03-27 17:38:48 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendSet.java 2012-04-11 07:28:51 +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; import org.hisp.dhis.dataelement.DataElement; @@ -182,4 +183,22 @@ { this.dataElements = dataElements; } + + @Override + public void mergeWith( IdentifiableObject other ) + { + super.mergeWith( other ); + + if ( other.getClass().isInstance( this ) ) + { + MapLegendSet mapLegendSet = (MapLegendSet) other; + + type = mapLegendSet.getType() == null ? type : mapLegendSet.getType(); + symbolizer = mapLegendSet.getSymbolizer() == null ? symbolizer : mapLegendSet.getSymbolizer(); + + mapLegends.addAll( mapLegendSet.getMapLegends() ); + indicators.addAll( mapLegendSet.getIndicators() ); + dataElements.addAll( mapLegendSet.getDataElements() ); + } + } } \ No newline at end of file === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java 2012-03-27 17:38:48 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java 2012-04-11 07:28:51 +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.adapter.JacksonPeriodTypeDeserializer; import org.hisp.dhis.common.adapter.JacksonPeriodTypeSerializer; import org.hisp.dhis.common.view.DetailedView; @@ -477,4 +478,38 @@ { this.zoom = zoom; } + + @Override + public void mergeWith( IdentifiableObject other ) + { + super.mergeWith( other ); + + if ( other.getClass().isInstance( this ) ) + { + MapView mapView = (MapView) other; + + user = mapView.getUser() == null ? user : mapView.getUser(); + mapValueType = mapView.getMapValueType() == null ? mapValueType : mapView.getMapValueType(); + indicatorGroup = mapView.getIndicatorGroup() == null ? indicatorGroup : mapView.getIndicatorGroup(); + indicator = mapView.getIndicator() == null ? indicator : mapView.getIndicator(); + dataElementGroup = mapView.getDataElementGroup() == null ? dataElementGroup : mapView.getDataElementGroup(); + dataElement = mapView.getDataElement() == null ? dataElement : mapView.getDataElement(); + periodType = mapView.getPeriodType() == null ? periodType : mapView.getPeriodType(); + period = mapView.getPeriod() == null ? period : mapView.getPeriod(); + parentOrganisationUnit = mapView.getParentOrganisationUnit() == null ? parentOrganisationUnit : mapView.getParentOrganisationUnit(); + organisationUnitLevel = mapView.getOrganisationUnitLevel() == null ? organisationUnitLevel : mapView.getOrganisationUnitLevel(); + mapLegendType = mapView.getMapLegendType() == null ? mapLegendType : mapView.getMapLegendType(); + method = mapView.getMethod() == null ? method : mapView.getMethod(); + classes = mapView.getClasses() == null ? classes : mapView.getClasses(); + bounds = mapView.getBounds() == null ? bounds : mapView.getBounds(); + colorLow = mapView.getColorLow() == null ? colorLow : mapView.getColorLow(); + colorHigh = mapView.getColorHigh() == null ? colorHigh : mapView.getColorHigh(); + mapLegendSet = mapView.getMapLegendSet() == null ? mapLegendSet : mapView.getMapLegendSet(); + radiusLow = mapView.getRadiusLow() == null ? radiusLow : mapView.getRadiusLow(); + radiusHigh = mapView.getRadiusHigh() == null ? radiusHigh : mapView.getRadiusHigh(); + longitude = mapView.getLongitude() == null ? longitude : mapView.getLongitude(); + latitude = mapView.getLatitude() == null ? latitude : mapView.getLatitude(); + zoom = mapView.getZoom() == null ? zoom : mapView.getZoom(); + } + } } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageConversation.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageConversation.java 2012-03-27 17:38:48 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageConversation.java 2012-04-11 07:28:51 +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; import org.hisp.dhis.user.User; @@ -360,4 +361,22 @@ { this.lastSenderFirstname = lastSenderFirstname; } + + @Override + public void mergeWith( IdentifiableObject other ) + { + super.mergeWith( other ); + + if ( other.getClass().isInstance( this ) ) + { + MessageConversation messageConversation = (MessageConversation) other; + + subject = messageConversation.getSubject() == null ? subject : messageConversation.getSubject(); + lastSender = messageConversation.getLastSender() == null ? lastSender : messageConversation.getLastSender(); + lastMessage = messageConversation.getLastMessage() == null ? lastMessage : messageConversation.getLastMessage(); + + userMessages.addAll( messageConversation.getUserMessages() ); + messages.addAll( messageConversation.getMessages() ); + } + } } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java 2012-03-27 17:38:48 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java 2012-04-11 07:28:51 +0000 @@ -37,6 +37,7 @@ import org.hisp.dhis.attribute.AttributeValue; import org.hisp.dhis.common.BaseIdentifiableObject; import org.hisp.dhis.common.Dxf2Namespace; +import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.common.IdentifiableObjectUtils; import org.hisp.dhis.common.view.DetailedView; import org.hisp.dhis.common.view.ExportView; @@ -349,4 +350,28 @@ { this.attributeValues = attributeValues; } + + @Override + public void mergeWith( IdentifiableObject other ) + { + super.mergeWith( other ); + + if ( other.getClass().isInstance( this ) ) + { + User user = (User) other; + + surname = user.getSurname() == null ? surname : user.getSurname(); + firstName = user.getFirstName() == null ? firstName : user.getFirstName(); + email = user.getEmail() == null ? email : user.getEmail(); + phoneNumber = user.getPhoneNumber() == null ? phoneNumber : user.getPhoneNumber(); + userCredentials = user.getUserCredentials() == null ? userCredentials : user.getUserCredentials(); + + attributeValues.addAll( user.getAttributeValues() ); + + for ( OrganisationUnit organisationUnit : user.getOrganisationUnits() ) + { + addOrganisationUnit( organisationUnit ); + } + } + } } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserAuthorityGroup.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserAuthorityGroup.java 2012-03-28 07:40:14 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserAuthorityGroup.java 2012-04-11 07:28:51 +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; import org.hisp.dhis.dataset.DataSet; @@ -96,6 +97,22 @@ } // ------------------------------------------------------------------------- + // Logic + // ------------------------------------------------------------------------- + + public void addUserCredentials( UserCredentials userCredentials ) + { + members.add( userCredentials ); + userCredentials.getUserAuthorityGroups().add( this ); + } + + public void removeUserCredentials( UserCredentials userCredentials ) + { + members.remove( userCredentials ); + userCredentials.getUserAuthorityGroups().remove( this ); + } + + // ------------------------------------------------------------------------- // Getters and setters // ------------------------------------------------------------------------- @@ -150,4 +167,25 @@ { this.dataSets = dataSets; } + + @Override + public void mergeWith( IdentifiableObject other ) + { + super.mergeWith( other ); + + if ( other.getClass().isInstance( this ) ) + { + UserAuthorityGroup userAuthorityGroup = (UserAuthorityGroup) other; + + description = userAuthorityGroup.getDescription() == null ? description : userAuthorityGroup.getDescription(); + + authorities.addAll( authorities ); + dataSets.addAll( userAuthorityGroup.getDataSets() ); + + for ( UserCredentials userCredentials : userAuthorityGroup.getMembers() ) + { + addUserCredentials( userCredentials ); + } + } + } } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroup.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroup.java 2012-03-27 17:38:48 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroup.java 2012-04-11 07:28:51 +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; @@ -123,4 +124,17 @@ { this.members = members; } + + @Override + public void mergeWith( IdentifiableObject other ) + { + super.mergeWith( other ); + + if ( other.getClass().isInstance( this ) ) + { + UserGroup userGroup = (UserGroup) other; + + members.addAll( userGroup.getMembers() ); + } + } }