sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1795382 - in /sis/trunk: ./ core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
Date Tue, 16 May 2017 22:12:46 GMT
Author: desruisseaux
Date: Tue May 16 22:12:46 2017
New Revision: 1795382

URL: http://svn.apache.org/viewvc?rev=1795382&view=rev
Log:
Merge from JDK7 branch.

Modified:
    sis/trunk/   (props changed)
    sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java
    sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java

Propchange: sis/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue May 16 22:12:46 2017
@@ -1,5 +1,5 @@
 /sis/branches/Android:1430670-1480699
 /sis/branches/JDK6:1394364-1758914
-/sis/branches/JDK7:1394913-1795335
-/sis/branches/JDK8:1584960-1795334
+/sis/branches/JDK7:1394913-1795380
+/sis/branches/JDK8:1584960-1795379
 /sis/branches/JDK9:1773327-1789983

Modified: sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java?rev=1795382&r1=1795381&r2=1795382&view=diff
==============================================================================
--- sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java [UTF-8]
(original)
+++ sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java [UTF-8]
Tue May 16 22:12:46 2017
@@ -363,7 +363,7 @@ public abstract class AbstractFeature im
      * }
      *
      * @param  name  the name of the operation to execute. The caller is responsible to ensure
that the
-     *               property type for that name is an instance of {@link Operation}.
+     *               property type for that name is an instance of {@link AbstractOperation}.
      * @return the result value of the given operation, or {@code null} if none.
      *
      * @since 0.8
@@ -390,7 +390,7 @@ public abstract class AbstractFeature im
      * but the {@linkplain FeatureOperations#link link} operation for instance does.
      *
      * @param  name   the name of the operation to execute. The caller is responsible to
ensure that the
-     *                property type for that name is an instance of {@link Operation}.
+     *                property type for that name is an instance of {@link AbstractOperation}.
      * @param  value  the value to assign to the result of the named operation.
      * @throws IllegalStateException if the operation of the given name does not accept assignment.
      *

Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java?rev=1795382&r1=1795381&r2=1795382&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
[UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
[UTF-8] Tue May 16 22:12:46 2017
@@ -266,6 +266,17 @@ public class MetadataSource implements A
     private transient volatile ObjectConverter<?,?> lastConverter;
 
     /**
+     * The last "method name to column name" map returned by {@link #asNameMap(Class)}.
+     * Cached on assumption that the same map will be used more than once before to move
to another metadata object.
+     */
+    private transient Map<String,String> lastNameMap;
+
+    /**
+     * The {@code type} argument in the last call to {@link #asNameMap(Class)}.
+     */
+    private transient Class<?> lastNameMapType;
+
+    /**
      * Where to report the warnings. This is not necessarily a logger, since users can register
listeners.
      *
      * @see #getValue(Class, Method, Dispatcher)
@@ -544,18 +555,6 @@ public class MetadataSource implements A
     }
 
     /**
-     * Returns the column name for the specified method.
-     */
-    private static String getColumnName(final Method method) {
-        final UML annotation = method.getAnnotation(UML.class);
-        if (annotation == null) {
-            return method.getName();
-        }
-        final String name = annotation.identifier();
-        return name.substring(name.lastIndexOf('.') + 1);
-    }
-
-    /**
      * If the given metadata is a proxy generated by this {@code MetadataSource}, returns
the
      * identifier of that proxy. Such metadata do not need to be inserted again in the database.
      *
@@ -567,6 +566,25 @@ public class MetadataSource implements A
     }
 
     /**
+     * Maps method names to the name of columns in the table for the given metadata. The
values in the
+     * returned map must be the same than the keys in the map returned by {@link #asValueMap(Object)}.
+     *
+     * @param  type  the type of metadata object for which to get column names.
+     * @return a map from method names to column names.
+     * @throws ClassCastException if the metadata object type does not extend a metadata
interface
+     *         of the expected package.
+     */
+    @SuppressWarnings("ReturnOfCollectionOrArrayField")
+    private Map<String,String> asNameMap(final Class<?> type) throws ClassCastException
{
+        assert Thread.holdsLock(this);
+        if (type != lastNameMapType) {
+            lastNameMapType = type;
+            lastNameMap = standard.asNameMap(type, KeyNamePolicy.METHOD_NAME, KeyNamePolicy.UML_IDENTIFIER);
+        }
+        return lastNameMap;
+    }
+
+    /**
      * Returns a view of the given metadata as a map. This method returns always a map using
UML identifier
      * and containing all entries including the null ones because the {@code MetadataSource}
implementation
      * assumes so.
@@ -837,10 +855,11 @@ public class MetadataSource implements A
         final Class<?> elementType    = wantCollection ? Classes.boundOfParameterizedProperty(method)
: returnType;
         final boolean  isMetadata     = standard.isMetadata(elementType);
         final String   tableName      = getTableName(type);
-        final String   columnName     = getColumnName(method);
+        final String   columnName;
         final boolean  isArray;
         Object value;
         synchronized (this) {
+            columnName = asNameMap(type).get(method.getName());
             if (!getExistingColumns(tableName).contains(columnName)) {
                 value   = null;
                 isArray = false;



Mime
View raw message