sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1795670 - in /sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql: MetadataSource.java MetadataWriter.java
Date Sat, 20 May 2017 15:50:09 GMT
Author: desruisseaux
Date: Sat May 20 15:50:08 2017
New Revision: 1795670

URL: http://svn.apache.org/viewvc?rev=1795670&view=rev
Log:
Allow to specify the database catalog.

Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataWriter.java

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java?rev=1795670&r1=1795669&r2=1795670&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
[UTF-8] Sat May 20 15:50:08 2017
@@ -95,6 +95,7 @@ import org.apache.sis.util.iso.Types;
  * <table class="sis">
  *   <caption>Optional properties at construction time</caption>
  *   <tr><th>Key</th>                     <th>Value type</th>
         <th>Description</th></tr>
+ *   <tr><td>{@code "catalog"}</td>       <td>{@link String}</td>
     <td>The database catalog where the metadata schema is stored.</td></tr>
  *   <tr><td>{@code "classloader"}</td>   <td>{@link ClassLoader}</td>
<td>The class loader to use for creating {@link Proxy} instances.</td></tr>
  *   <tr><td>{@code "maxStatements"}</td> <td>{@link Integer}</td>
    <td>Maximal number of {@link PreparedStatement}s that can be kept simultaneously
open.</td></tr>
  * </table>
@@ -112,12 +113,6 @@ import org.apache.sis.util.iso.Types;
  */
 public class MetadataSource implements AutoCloseable {
     /**
-     * The catalog, set to {@code null} for now. This is defined as a constant in order
to make easier
-     * to spot the places where catalog would be used, if we want to use it in a future version.
-     */
-    static final String CATALOG = null;
-
-    /**
      * The column name used for the identifiers. We do not quote this identifier;
      * we will let the database uses its own lower-case / upper-case convention.
      */
@@ -206,6 +201,11 @@ public class MetadataSource implements A
     private final CachedStatement[] statements;
 
     /**
+     * The catalog, or {@code null} if none.
+     */
+    final String catalog;
+
+    /**
      * The database schema where metadata are stored, or {@code null} if none. In the metadata
source
      * {@linkplain #getProvided() provided by SIS}, this is {@code "metadata"} or {@code
"METADATA"},
      * depending on the database convention regarding lower case / upper case identifiers.
@@ -353,8 +353,12 @@ public class MetadataSource implements A
     {
         ArgumentChecks.ensureNonNull("standard",   standard);
         ArgumentChecks.ensureNonNull("dataSource", dataSource);
-        ClassLoader classloader   = Containers.property(properties, "classloader",   ClassLoader.class);
-        Integer     maxStatements = Containers.property(properties, "maxStatements", Integer.class);
+        ClassLoader classloader;
+        Integer maxStatements;
+
+        catalog       = Containers.property(properties, "catalog",       String.class);;
+        classloader   = Containers.property(properties, "classloader",   ClassLoader.class);
+        maxStatements = Containers.property(properties, "maxStatements", Integer.class);
         if (classloader == null) {
             classloader = getClass().getClassLoader();
         }
@@ -390,6 +394,7 @@ public class MetadataSource implements A
         ArgumentChecks.ensureNonNull("source", source);
         standard     = source.standard;
         dataSource   = source.dataSource;
+        catalog      = source.catalog;
         schema       = source.schema;
         quoteSchema  = source.quoteSchema;
         statements   = new CachedStatement[source.statements.length];
@@ -420,7 +425,7 @@ public class MetadataSource implements A
                 schema = schema.toLowerCase(Locale.US);
             }
             quoteSchema = false;
-            try (ResultSet result = md.getTables(CATALOG, schema, "CI_Citation", null)) {
+            try (ResultSet result = md.getTables(catalog, schema, "CI_Citation", null)) {
                 if (result.next()) {
                     return;
                 }
@@ -775,7 +780,7 @@ public class MetadataSource implements A
              * on the search path specified in the database environment variables.
              */
             final DatabaseMetaData md = connection().getMetaData();
-            try (ResultSet rs = md.getColumns(CATALOG, schema, table, null)) {
+            try (ResultSet rs = md.getColumns(catalog, schema, table, null)) {
                 while (rs.next()) {
                     if (!columns.add(rs.getString("COLUMN_NAME"))) {
                         // Paranoiac check, but should never happen.

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataWriter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataWriter.java?rev=1795670&r1=1795669&r2=1795670&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataWriter.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataWriter.java
[UTF-8] Sat May 20 15:50:08 2017
@@ -71,6 +71,10 @@ import org.apache.sis.internal.metadata.
  *     <th>Value type</th>
  *     <th>Description</th>
  *   </tr><tr>
+ *     <td>{@code "catalog"}</td>
+ *     <td>{@link String}</td>
+ *     <td>The database catalog where the metadata schema is stored.</td>
+ *   </tr><tr>
  *     <td>{@code "classloader"}</td>
  *     <td>{@link ClassLoader}</td>
  *     <td>The class loader to use for creating {@link java.lang.reflect.Proxy} instances.</td>
@@ -418,10 +422,10 @@ public class MetadataWriter extends Meta
                                  */
                                 if (referencedTables == null) {
                                     referencedTables = new HashMap<>();
-                                    try (ResultSet rs = stmt.getConnection().getMetaData().getImportedKeys(CATALOG,
schema(), table)) {
+                                    try (ResultSet rs = stmt.getConnection().getMetaData().getImportedKeys(catalog,
schema(), table)) {
                                         while (rs.next()) {
                                             if ((schema() == null || schema().equals(rs.getString("PKTABLE_SCHEM")))
&&
-                                                (CATALOG  == null || CATALOG.equals(rs.getString("PKTABLE_CAT"))))
+                                                (catalog  == null || catalog.equals(rs.getString("PKTABLE_CAT"))))
                                             {
                                                 referencedTables.put(rs.getString("FKCOLUMN_NAME"),
                                                             new FKey(rs.getString("PKTABLE_NAME"),
null,



Mime
View raw message