dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #42540
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21752: minor fix, add mergeWith to Translation
------------------------------------------------------------
revno: 21752
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2016-01-15 15:41:23 +0700
message:
minor fix, add mergeWith to Translation
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/translation/Translation.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/translation/Translation.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/translation/Translation.java 2016-01-11 17:18:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/translation/Translation.java 2016-01-15 08:41:23 +0000
@@ -34,6 +34,8 @@
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
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 java.util.Objects;
@@ -64,11 +66,11 @@
/**
* TODO find some consistent order across object, service, HBM.
- *
+ *
* @param className the class name of the translated object.
- * @param locale the locale.
- * @param property the property name.
- * @param value the translation.
+ * @param locale the locale.
+ * @param property the property name.
+ * @param value the translation.
* @param objectUid the UID of the translated object.
*/
public Translation( String className, String locale, String property, String value, String objectUid )
@@ -203,4 +205,33 @@
return sb.toString();
}
+
+ @Override
+ public void mergeWith( IdentifiableObject other, MergeStrategy strategy )
+ {
+ super.mergeWith( other, strategy );
+
+ if ( other.getClass().isInstance( this ) )
+ {
+ Translation translation = (Translation) other;
+
+ if ( strategy.isReplace() )
+ {
+ objectUid = translation.getObjectUid();
+ className = translation.getClassName();
+ locale = translation.getLocale();
+ property = translation.getProperty();
+ value = translation.getValue();
+ }
+ else if ( strategy.isMerge() )
+ {
+ objectUid = translation.getObjectUid() == null ? objectUid : translation.getObjectUid();
+ className = translation.getClassName() == null ? className : translation.getClassName();
+ locale = translation.getLocale() == null ? locale : translation.getLocale();
+ property = translation.getProperty() == null ? property : translation.getProperty();
+ value = translation.getValue() == null ? value : translation.getValue();
+ }
+ }
+ }
+ }
}
\ No newline at end of file