ref #7508 fix inverse L10n term representation
authorAndreas Müller <a.mueller@bgbm.org>
Mon, 25 Jun 2018 08:36:38 +0000 (10:36 +0200)
committerAndreas Müller <a.mueller@bgbm.org>
Mon, 25 Jun 2018 08:36:38 +0000 (10:36 +0200)
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/json/processor/bean/TermBaseBeanProcessor.java

index 4d600954bc44b7a0961bc83d2e49480497b421a8..9d47503b9c265860f841ee1b44b1ff93fc9d4475 100644 (file)
@@ -70,7 +70,7 @@ public class TermBaseBeanProcessor extends AbstractCdmBeanProcessor<TermBase> {
         }\r
 \r
         ITermRepresentation_L10n representation_L10n = new TermRepresentation_L10n(term, false);\r
-        handleL10nRepresentation(json, representation_L10n);\r
+        handleL10nRepresentation(json, representation_L10n, false);\r
         if(!replaceRepresentations){\r
             json.element("representations", term.getRepresentations(), jsonConfig);\r
         }\r
@@ -79,7 +79,7 @@ public class TermBaseBeanProcessor extends AbstractCdmBeanProcessor<TermBase> {
         if(RelationshipTermBase.class.isAssignableFrom(term.getClass())){\r
             RelationshipTermBase<?> relTerm = (RelationshipTermBase<?>)term;\r
             ITermRepresentation_L10n inverseRepresentation_L10n = new TermRepresentation_L10n(relTerm, true);\r
-            handleL10nRepresentation(json, inverseRepresentation_L10n);\r
+            handleL10nRepresentation(json, inverseRepresentation_L10n, true);\r
             if(!replaceRepresentations){\r
                 json.element("inverseRepresentations", relTerm.getInverseRepresentations(), jsonConfig);\r
             }\r
@@ -91,18 +91,19 @@ public class TermBaseBeanProcessor extends AbstractCdmBeanProcessor<TermBase> {
      * @param json\r
      * @param representation_L10n\r
      */\r
-    private void handleL10nRepresentation(JSONObject json, ITermRepresentation_L10n representation_L10n) {\r
+    private void handleL10nRepresentation(JSONObject json, ITermRepresentation_L10n representation_L10n, boolean isInverse) {\r
+        String baseLabel = isInverse? "inverseRepresentation_L10n" : "representation_L10n";\r
         if (representation_L10n.getLabel() != null) {\r
-            json.element("representation_L10n",representation_L10n.getLabel());\r
+            json.element(baseLabel,representation_L10n.getLabel());\r
         }\r
         if (representation_L10n.getAbbreviatedLabel() != null) {\r
-            json.element("representation_L10n_abbreviatedLabel", representation_L10n.getAbbreviatedLabel());\r
+            json.element(baseLabel + "_abbreviatedLabel", representation_L10n.getAbbreviatedLabel());\r
         }\r
         if (representation_L10n.getAbbreviatedLabel() != null) {\r
-            json.element("representation_L10n_language_iso", representation_L10n.getLanguageIso());\r
+            json.element(baseLabel + "_languageIso", representation_L10n.getLanguageIso());\r
         }\r
         if (representation_L10n.getAbbreviatedLabel() != null) {\r
-            json.element("representation_L10n_language_uuid", representation_L10n.getLanguageUuid());\r
+            json.element(baseLabel + "_languageUuid", representation_L10n.getLanguageUuid());\r
         }\r
     }\r
 \r