sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1796407 - in /sis/branches/JDK7: ./ core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataWriter.java
Date Sat, 27 May 2017 15:03:35 GMT
Author: desruisseaux
Date: Sat May 27 15:03:34 2017
New Revision: 1796407

URL: http://svn.apache.org/viewvc?rev=1796407&view=rev
Log:
Merge Enum support from JDK8 branch.

Modified:
    sis/branches/JDK7/   (props changed)
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataWriter.java

Propchange: sis/branches/JDK7/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat May 27 15:03:34 2017
@@ -1,5 +1,5 @@
 /sis/branches/Android:1430670-1480699
 /sis/branches/JDK6:1394913-1508480
-/sis/branches/JDK8:1584960-1796396
+/sis/branches/JDK8:1584960-1796404
 /sis/branches/JDK9:1773327-1789983
 /sis/trunk:1394364-1508466,1519089-1519674

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java?rev=1796407&r1=1796406&r2=1796407&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
[UTF-8] Sat May 27 15:03:34 2017
@@ -624,6 +624,8 @@ public class MetadataSource implements A
              */
             if (metadata instanceof ControlledVocabulary) {
                 identifier = Types.getCodeName((ControlledVocabulary) metadata);
+            } else if (metadata instanceof Enum<?>) {
+                identifier = ((Enum<?>) metadata).name();
             } else {
                 final String table;
                 final Map<String,Object> asMap;
@@ -687,6 +689,8 @@ public class MetadataSource implements A
             if (value != null) {
                 if (value instanceof ControlledVocabulary) {
                     value = Types.getCodeName((ControlledVocabulary) value);
+                } else if (value instanceof Enum<?>) {
+                    value = ((Enum<?>) value).name();
                 } else {
                     String dependency = proxy(value);
                     if (dependency != null) {
@@ -801,7 +805,7 @@ public class MetadataSource implements A
      *
      * @param  <T>         the parameterized type of the {@code type} argument.
      * @param  type        the interface to implement (e.g. {@link org.opengis.metadata.citation.Citation}),
-     *                     or the {@link ControlledVocabulary} type ({@link CodeList} or
{@link Enum}).
+     *                     or the {@link ControlledVocabulary} type ({@link CodeList} or
some {@link Enum}).
      * @param  identifier  the identifier of the record for the metadata entity to be created.
      *                     This is usually the primary key of the record to search for.
      * @return an implementation of the required interface, or the code list element.

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataWriter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataWriter.java?rev=1796407&r1=1796406&r2=1796407&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataWriter.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataWriter.java
[UTF-8] Sat May 27 15:03:34 2017
@@ -312,7 +312,7 @@ public class MetadataWriter extends Meta
                  */
                 int maxLength = maximumValueLength;
                 Class<?> rt = colTypes.get(column);
-                final boolean isCodeList = ControlledVocabulary.class.isAssignableFrom(rt);
    // Also enums.
+                final boolean isCodeList = ControlledVocabulary.class.isAssignableFrom(rt);
    // Accept also some enums.
                 if (isCodeList || standard.isMetadata(rt)) {
                     /*
                      * Found a reference to an other metadata. Remind that column for creating
a foreign key
@@ -321,13 +321,15 @@ public class MetadataWriter extends Meta
                      * may happen when the concrete class is not yet available in the GeoAPI
version that we
                      * are using.
                      */
-                    maxLength = maximumIdentifierLength;
                     if (!isCodeList || !Modifier.isAbstract(rt.getModifiers())) {
                         if (foreigners.put(column, new FKey(addTo, rt, null)) != null) {
                             throw new AssertionError(column);                           //
Should never happen.
                         }
                     }
                     rt = null;                                                          //
For forcing VARCHAR type.
+                    maxLength = maximumIdentifierLength;
+                } else if (rt.isEnum()) {
+                    maxLength = maximumIdentifierLength;
                 }
                 stmt.executeUpdate(helper.createColumn(schema(), addTo, column, rt, maxLength));
                 columns.add(column);
@@ -402,6 +404,8 @@ public class MetadataWriter extends Meta
             final Class<?> type = value.getClass();
             if (ControlledVocabulary.class.isAssignableFrom(type)) {
                 value = addCode(stmt, (ControlledVocabulary) value);
+            } else if (type.isEnum()) {
+                value = ((Enum<?>) value).name();
             } else if (standard.isMetadata(type)) {
                 String dependency = proxy(value);
                 if (dependency == null) {



Mime
View raw message