db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r382177 - in /db/ddlutils/trunk/src/java/org/apache/ddlutils: PlatformUtils.java task/DatabaseCommand.java task/DatabaseTaskBase.java task/PlatformConfiguration.java task/WriteSchemaSqlToFileCommand.java task/WriteSchemaToDatabaseCommand.java
Date Wed, 01 Mar 2006 22:16:32 GMT
Author: tomdz
Date: Wed Mar  1 14:16:28 2006
New Revision: 382177

URL: http://svn.apache.org/viewcvs?rev=382177&view=rev
Log:
Added the ability to specifiy the catalog and schema patterns for the tasks (which e.g. is
necessary for Oracle)

Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformUtils.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DatabaseCommand.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DatabaseTaskBase.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/task/PlatformConfiguration.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteSchemaSqlToFileCommand.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteSchemaToDatabaseCommand.java

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformUtils.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformUtils.java?rev=382177&r1=382176&r2=382177&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformUtils.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformUtils.java Wed Mar  1 14:16:28
2006
@@ -254,7 +254,7 @@
         }
         catch (SQLException ex)
         {
-            throw new DynaSqlException("Error while reading the database metadata", ex);
+            throw new DynaSqlException("Error while reading the database metadata: " + ex.getMessage(),
ex);
         }
         finally
         {

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DatabaseCommand.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DatabaseCommand.java?rev=382177&r1=382176&r2=382177&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DatabaseCommand.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DatabaseCommand.java Wed Mar  1 14:16:28
2006
@@ -54,6 +54,26 @@
     }
 
     /**
+     * Returns the catalog pattern if any.
+     * 
+     * @return The catalog pattern
+     */
+    public String getCatalogPattern()
+    {
+        return _platformConf.getCatalogPattern();
+    }
+
+    /**
+     * Returns the schema pattern if any.
+     * 
+     * @return The schema pattern
+     */
+    public String getSchemaPattern()
+    {
+        return _platformConf.getSchemaPattern();
+    }
+
+    /**
      * Sets the platform configuration.
      * 
      * @param platformConf The platform configuration

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DatabaseTaskBase.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DatabaseTaskBase.java?rev=382177&r1=382176&r2=382177&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DatabaseTaskBase.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DatabaseTaskBase.java Wed Mar  1 14:16:28
2006
@@ -57,7 +57,10 @@
      */
     public void setDatabaseType(String type)
     {
-        _platformConf.setDatabaseType(type);
+        if ((type != null) && (type.length() > 0))
+        {
+            _platformConf.setDatabaseType(type);
+        }
     }
 
     /**
@@ -78,6 +81,26 @@
     public void addConfiguredDatabase(BasicDataSource dataSource)
     {
         _platformConf.setDataSource(dataSource);
+    }
+
+    /**
+     * Sets the catalog pattern.
+     * 
+     * @param catalogPattern The catalog pattern
+     */
+    public void setCatalogPattern(String catalogPattern)
+    {
+        _platformConf.setCatalogPattern(catalogPattern);
+    }
+    
+    /**
+     * Sets the schema pattern.
+     * 
+     * @param schemaPattern The schema pattern
+     */
+    public void setSchemaPattern(String schemaPattern)
+    {
+        _platformConf.setSchemaPattern(schemaPattern);
     }
 
     /**

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/task/PlatformConfiguration.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/task/PlatformConfiguration.java?rev=382177&r1=382176&r2=382177&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/task/PlatformConfiguration.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/task/PlatformConfiguration.java Wed Mar
 1 14:16:28 2006
@@ -36,6 +36,10 @@
     private BasicDataSource _dataSource;
     /** Whether to use delimited SQL identifiers. */
     private boolean _useDelimitedSqlIdentifiers = true;
+    /** The catalog pattern. */
+    private String _catalogPattern;
+    /** The schema pattern. */
+    private String _schemaPattern;
 
     /**
      * Returns the database type.
@@ -75,6 +79,46 @@
     public void setDataSource(BasicDataSource dataSource)
     {
         _dataSource = dataSource;
+    }
+
+    /**
+     * Returns the catalog pattern if any.
+     * 
+     * @return The catalog pattern
+     */
+    public String getCatalogPattern()
+    {
+        return _catalogPattern;
+    }
+
+    /**
+     * Sets the catalog pattern.
+     * 
+     * @param catalogPattern The catalog pattern
+     */
+    public void setCatalogPattern(String catalogPattern)
+    {
+        _catalogPattern = catalogPattern;
+    }
+
+    /**
+     * Returns the schema pattern if any.
+     * 
+     * @return The schema pattern
+     */
+    public String getSchemaPattern()
+    {
+        return _schemaPattern;
+    }
+
+    /**
+     * Sets the schema pattern.
+     * 
+     * @param schemaPattern The schema pattern
+     */
+    public void setSchemaPattern(String schemaPattern)
+    {
+        _schemaPattern = schemaPattern;
     }
 
     /**

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteSchemaSqlToFileCommand.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteSchemaSqlToFileCommand.java?rev=382177&r1=382176&r2=382177&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteSchemaSqlToFileCommand.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteSchemaSqlToFileCommand.java Wed
Mar  1 14:16:28 2006
@@ -119,7 +119,9 @@
             platform.getSqlBuilder().setWriter(writer);
             if (isAlterDatabase() && (getDataSource() != null))
             {
-                Database currentModel = platform.readModelFromDatabase(null);
+                Database currentModel = (getCatalogPattern() != null) || (getSchemaPattern()
!= null) ?
+                                             platform.readModelFromDatabase(null, getCatalogPattern(),
getSchemaPattern(), null) :
+                                             platform.readModelFromDatabase(null);
 
                 platform.getSqlBuilder().alterDatabase(currentModel, model, params, _doDrops,
true);
             }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteSchemaToDatabaseCommand.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteSchemaToDatabaseCommand.java?rev=382177&r1=382176&r2=382177&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteSchemaToDatabaseCommand.java
(original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteSchemaToDatabaseCommand.java
Wed Mar  1 14:16:28 2006
@@ -96,11 +96,32 @@
         {
             if (isAlterDatabase())
             {
-                platform.alterTables(model, params, _doDrops, true, true);
+                if ((getCatalogPattern() != null) || (getSchemaPattern() != null))
+                {
+                    platform.alterTables(getCatalogPattern(),
+                                         getSchemaPattern(),
+                                         null,
+                                         model,
+                                         params,
+                                         _doDrops,
+                                         true,
+                                         true);
+                }
+                else
+                {
+                    platform.alterTables(model,
+                                         params,
+                                         _doDrops,
+                                         true,
+                                         true);
+                }
             }
             else
             {
-                platform.createTables(model, params, _doDrops, true);
+                platform.createTables(model,
+                                      params,
+                                      _doDrops,
+                                      true);
             }
 
             task.log("Written schema to database", Project.MSG_INFO);



Mime
View raw message