You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2010/06/15 12:16:33 UTC

svn commit: r954790 - in /incubator/chemistry/opencmis/trunk: chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apa...

Author: fmui
Date: Tue Jun 15 10:16:32 2010
New Revision: 954790

URL: http://svn.apache.org/viewvc?rev=954790&view=rev
Log:
corrected handling of properties without a property id (-> query)
enhanced property value formating

Modified:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Property.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentPropertyImpl.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/PersistentObjectFactoryImpl.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/data/Properties.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/PropertiesImpl.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Property.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Property.java?rev=954790&r1=954789&r2=954790&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Property.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Property.java Tue Jun 15 10:16:32 2010
@@ -40,4 +40,5 @@ public interface Property<T> extends Pro
 
     String getValueAsString();
 
+    String getValuesAsString();
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentPropertyImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentPropertyImpl.java?rev=954790&r1=954789&r2=954790&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentPropertyImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentPropertyImpl.java Tue Jun 15 10:16:32 2010
@@ -19,6 +19,7 @@
 package org.apache.chemistry.opencmis.client.runtime;
 
 import java.io.Serializable;
+import java.util.GregorianCalendar;
 import java.util.List;
 
 import org.apache.chemistry.opencmis.client.api.Property;
@@ -84,10 +85,39 @@ public class PersistentPropertyImpl<T> e
         if (values.size() == 0) {
             return null;
         }
-        switch (propertyDefinition.getPropertyType()) {
-        default:
-            return values.get(0).toString();
+
+        return formatValue(values.get(0));
+    }
+
+    public String getValuesAsString() {
+        List<T> values = getValues();
+
+        StringBuilder result = new StringBuilder();
+        for (T value : values) {
+            if (result.length() > 0) {
+                result.append(", ");
+            }
+
+            result.append(formatValue(value));
+        }
+
+        return "[" + result.toString() + "]";
+    }
+
+    private String formatValue(T value) {
+        String result;
+
+        if (value == null) {
+            return null;
+        }
+
+        if (value instanceof GregorianCalendar) {
+            result = ((GregorianCalendar) value).getTime().toString();
+        } else {
+            result = value.toString();
         }
+
+        return result;
     }
 
     public boolean isMultiValued() {

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/PersistentObjectFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/PersistentObjectFactoryImpl.java?rev=954790&r1=954789&r2=954790&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/PersistentObjectFactoryImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/PersistentObjectFactoryImpl.java Tue Jun 15 10:16:32 2010
@@ -544,7 +544,7 @@ public class PersistentObjectFactoryImpl
         if ((properties == null) || (properties.getProperties() == null)) {
             throw new IllegalArgumentException("Properties must be set!");
         }
-        return new ArrayList<PropertyData<?>>(properties.getProperties().values());
+        return new ArrayList<PropertyData<?>>(properties.getPropertyList());
     }
 
     // objects

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/data/Properties.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/data/Properties.java?rev=954790&r1=954789&r2=954790&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/data/Properties.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/data/Properties.java Tue Jun 15 10:16:32 2010
@@ -18,9 +18,19 @@
  */
 package org.apache.chemistry.opencmis.commons.data;
 
+import java.util.List;
 import java.util.Map;
 
 public interface Properties extends ExtensionsData {
 
+    /**
+     * Returns a map of properties (property id => property). Should not be used
+     * with queries because some repositories don't set property ids.
+     */
     Map<String, PropertyData<?>> getProperties();
+
+    /**
+     * Returns the list of properties.
+     */
+    List<PropertyData<?>> getPropertyList();
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/PropertiesImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/PropertiesImpl.java?rev=954790&r1=954789&r2=954790&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/PropertiesImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/PropertiesImpl.java Tue Jun 15 10:16:32 2010
@@ -18,6 +18,8 @@
  */
 package org.apache.chemistry.opencmis.commons.impl.dataobjects;
 
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -28,13 +30,11 @@ import org.apache.chemistry.opencmis.com
 
 /**
  * Properties data implementation.
- * 
- * @author <a href="mailto:fmueller@opentext.com">Florian M&uuml;ller</a>
- * 
  */
 public class PropertiesImpl extends AbstractExtensionData implements Properties {
 
-    Map<String, PropertyData<?>> fProperties = new LinkedHashMap<String, PropertyData<?>>();
+    List<PropertyData<?>> propertyList = new ArrayList<PropertyData<?>>();
+    Map<String, PropertyData<?>> properties = new LinkedHashMap<String, PropertyData<?>>();
 
     /**
      * Constructor.
@@ -42,17 +42,13 @@ public class PropertiesImpl extends Abst
     public PropertiesImpl() {
     }
 
-    public PropertiesImpl(Map<String, PropertyData<?>> properties) {
-        fProperties = properties;
-    }
-    
     /**
      * Constructor.
      * 
      * @param properties
-     *            initial list of properties
+     *            initial collection of properties
      */
-    public PropertiesImpl(List<PropertyData<?>> properties) {
+    public PropertiesImpl(Collection<PropertyData<?>> properties) {
         if (properties != null) {
             for (PropertyData<?> prop : properties) {
                 addProperty(prop);
@@ -61,7 +57,11 @@ public class PropertiesImpl extends Abst
     }
 
     public Map<String, PropertyData<?>> getProperties() {
-        return Collections.unmodifiableMap(fProperties);
+        return Collections.unmodifiableMap(properties);
+    }
+
+    public List<PropertyData<?>> getPropertyList() {
+        return Collections.unmodifiableList(propertyList);
     }
 
     /**
@@ -75,17 +75,13 @@ public class PropertiesImpl extends Abst
             return;
         }
 
-        fProperties.put(property.getId(), property);
+        propertyList.add(property);
+        properties.put(property.getId(), property);
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.lang.Object#toString()
-     */
     @Override
     public String toString() {
-        return "Properties Data [properties=" + fProperties + "]" + super.toString();
+        return "Properties Data [properties=" + propertyList + "]" + super.toString();
     }
 
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java?rev=954790&r1=954789&r2=954790&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/types/PropertyCreationHelper.java Tue Jun 15 10:16:32 2010
@@ -269,7 +269,7 @@ public class PropertyCreationHelper {
 
         }
 
-        Properties props = new PropertiesImpl(mappedProperties);
+        Properties props = new PropertiesImpl(mappedProperties.values());
         return props;
     }