]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-2932: Moved utility routine to return primary value from a multivalued list...
authorAron Roberts <aron@socrates.berkeley.edu>
Mon, 8 Nov 2010 23:11:13 +0000 (23:11 +0000)
committerAron Roberts <aron@socrates.berkeley.edu>
Mon, 8 Nov 2010 23:11:13 +0000 (23:11 +0000)
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java
services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java

index b3019c2cbd63b2ee82341a585e774c81818574c3..83750d475d7d015ea39152f7e71f772328c97815 100644 (file)
@@ -462,4 +462,43 @@ public abstract class RemoteDocumentModelHandlerImpl<T, TL>
         return ilistItem;
     }
 
+    /**
+     * Returns the primary value from a list of values.
+     *
+     * Assumes that the first value is the primary value.
+     * This assumption may change when and if the primary value
+     * is identified explicitly.
+     *
+     * @param values a list of values.
+     * @param propertyName the name of a property through
+     *     which the value can be extracted.
+     * @return the primary value.
+     */
+    protected String primaryValueFromMultivalue(List<Object> values, String propertyName) {
+        String primaryValue = "";
+        if (values == null || values.size() == 0) {
+            return primaryValue;
+        }
+        Object value = values.get(0);
+        if (value instanceof String) {
+            if (value != null) {
+                primaryValue = (String) value;
+            }
+       // Multivalue group of fields
+       } else if (value instanceof Map) {
+            if (value != null) {
+                Map map = (Map) value;
+                if (map.values().size() > 0) {
+                    if (map.get(propertyName) != null) {
+                      primaryValue = (String) map.get(propertyName);
+                    }
+                }
+            }
+       } else {
+            logger.warn("Unexpected type for property " + propertyName
+                    + " in multivalue list: not String or Map.");
+       }
+       return primaryValue;
+    }
+
 }
index 10d70b1bb981c29161e1cf9c6ba07902970e0694..5b660abff2a22915967ff1c2cc4af8007028f454 100644 (file)
@@ -187,40 +187,5 @@ public class OrganizationDocumentModelHandler
         return OrganizationConstants.NUXEO_SCHEMA_NAME + ":" + prop;
     }
 
-    /**
-     * Returns the primary value from a list of values.
-     *
-     * Assumes that the first value is the primary value.
-     * This assumption may change when and if the primary value
-     * is identified explicitly.
-     *
-     * @param values a list of values.
-     * @param propertyName the name of a property through
-     *     which the value can be extracted.
-     * @return the primary value.
-     */
-    private String primaryValueFromMultivalue(List<Object> values, String propertyName) {
-        String primaryValue = "";
-        if (values == null || values.size() == 0) {
-            return primaryValue;
-        }
-        Object value = values.get(0);
-        if (value instanceof String) {
-            if (value != null) {
-                primaryValue = (String) value;
-            }
-       // Multivalue group of fields
-       } else if (value instanceof Map) {
-            if (value != null) {
-                Map map = (Map) value;
-                if (map.values().size() > 0) {
-                    if (map.get(propertyName) != null) {
-                      primaryValue = (String) map.get(propertyName);
-                    }
-                }
-            }
-       }
-       return primaryValue;
-    }
 }