dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41418
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21105: add mergeWith to ProgramTrackedEntityAttribute
------------------------------------------------------------
revno: 21105
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-11-18 13:06:06 +0700
message:
add mergeWith to ProgramTrackedEntityAttribute
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramTrackedEntityAttribute.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/program/ProgramTrackedEntityAttribute.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramTrackedEntityAttribute.java 2015-11-17 20:05:06 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramTrackedEntityAttribute.java 2015-11-18 06:06:06 +0000
@@ -36,6 +36,8 @@
import com.google.common.base.MoreObjects;
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.view.DetailedView;
import org.hisp.dhis.common.view.ExportView;
import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
@@ -48,7 +50,7 @@
extends BaseIdentifiableObject
{
private Program program;
-
+
private TrackedEntityAttribute attribute;
private boolean displayInList;
@@ -173,4 +175,31 @@
.add( "allowFutureDate", allowFutureDate )
.toString();
}
+
+ @Override
+ public void mergeWith( IdentifiableObject other, MergeStrategy strategy )
+ {
+ super.mergeWith( other, strategy );
+
+ if ( other.getClass().isInstance( this ) )
+ {
+ ProgramTrackedEntityAttribute programTrackedEntityAttribute = (ProgramTrackedEntityAttribute) other;
+ displayInList = programTrackedEntityAttribute.isDisplayInList();
+
+ if ( strategy.isReplace() )
+ {
+ program = programTrackedEntityAttribute.getProgram();
+ attribute = programTrackedEntityAttribute.getAttribute();
+ mandatory = programTrackedEntityAttribute.isMandatory();
+ allowFutureDate = programTrackedEntityAttribute.getAllowFutureDate();
+ }
+ else if ( strategy.isMerge() )
+ {
+ program = programTrackedEntityAttribute.getProgram() == null ? program : programTrackedEntityAttribute.getProgram();
+ attribute = programTrackedEntityAttribute.getAttribute() == null ? attribute : programTrackedEntityAttribute.getAttribute();
+ mandatory = programTrackedEntityAttribute.isMandatory() == null ? mandatory : programTrackedEntityAttribute.isMandatory();
+ allowFutureDate = programTrackedEntityAttribute.getAllowFutureDate() == null ? allowFutureDate : programTrackedEntityAttribute.getAllowFutureDate();
+ }
+ }
+ }
}