db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r581500 - in /db/ddlutils/trunk/src: java/org/apache/ddlutils/alteration/ java/org/apache/ddlutils/model/ java/org/apache/ddlutils/platform/ java/org/apache/ddlutils/platform/db2/ java/org/apache/ddlutils/platform/firebird/ java/org/apache/...
Date Wed, 03 Oct 2007 05:29:44 GMT
Author: tomdz
Date: Tue Oct  2 22:29:42 2007
New Revision: 581500

URL: http://svn.apache.org/viewvc?rev=581500&view=rev
Log:
Refactored change classes

Added:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnChangeImplBase.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ForeignKeyChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ForeignKeyChangeImplBase.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/IndexChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/IndexChangeImplBase.java
Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddColumnChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddForeignKeyChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddIndexChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddPrimaryKeyChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddTableChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnAutoIncrementChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDataTypeChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDefaultValueChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnRequiredChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnSizeChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ModelComparator.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/PrimaryKeyChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveColumnChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveForeignKeyChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveIndexChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemovePrimaryKeyChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveTableChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/TableChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/TableChangeImplBase.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Table.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SqlBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2Builder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mckoi/MckoiBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Builder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sapdb/SapDbBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/alteration/TestModelComparator.java

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddColumnChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddColumnChange.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddColumnChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddColumnChange.java Tue Oct  2 22:29:42 2007
@@ -111,12 +111,13 @@
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database, boolean caseSensitive)
+    public void apply(Database model, boolean caseSensitive)
     {
         Column newColumn = null;
 
         try
         {
+        	// TODO: Cloning should not be necessary
             newColumn = (Column)_newColumn.clone();
         }
         catch (CloneNotSupportedException ex)
@@ -124,8 +125,9 @@
             throw new DdlUtilsException(ex);
         }
 
-        Table table = database.findTable(getChangedTable().getName(), caseSensitive);
+        Table table = findChangedTable(model, caseSensitive);
 
+        // TODO: change this !
         if ((_previousColumn != null) && (_nextColumn != null))
         {
             int idx = table.getColumnIndex(_previousColumn) + 1;

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddForeignKeyChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddForeignKeyChange.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddForeignKeyChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddForeignKeyChange.java Tue Oct  2 22:29:42 2007
@@ -67,6 +67,7 @@
 
         try
         {
+        	// TODO: we should not have to clone here
             newFK = (ForeignKey)_newForeignKey.clone();
             newFK.setForeignTable(database.findTable(_newForeignKey.getForeignTableName(), caseSensitive));
         }
@@ -74,7 +75,7 @@
         {
             throw new DdlUtilsException(ex);
         }
-        database.findTable(getChangedTable().getName()).addForeignKey(newFK);
+        findChangedTable(database, caseSensitive).addForeignKey(newFK);
     }
 
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddIndexChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddIndexChange.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddIndexChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddIndexChange.java Tue Oct  2 22:29:42 2007
@@ -59,7 +59,7 @@
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database, boolean caseSensitive)
+    public void apply(Database model, boolean caseSensitive)
     {
         Index newIndex = null;
 
@@ -71,6 +71,6 @@
         {
             throw new DdlUtilsException(ex);
         }
-        database.findTable(getChangedTable().getName(), caseSensitive).addIndex(newIndex);
+        findChangedTable(model, caseSensitive).addIndex(newIndex);
     }
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddPrimaryKeyChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddPrimaryKeyChange.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddPrimaryKeyChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddPrimaryKeyChange.java Tue Oct  2 22:29:42 2007
@@ -58,9 +58,9 @@
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database, boolean caseSensitive)
+    public void apply(Database model, boolean caseSensitive)
     {
-        Table table = database.findTable(getChangedTable().getName(), caseSensitive);
+        Table table = findChangedTable(model, caseSensitive);
 
         for (int idx = 0; idx < _primaryKeyColumns.length; idx++)
         {

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddTableChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddTableChange.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddTableChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddTableChange.java Tue Oct  2 22:29:42 2007
@@ -63,6 +63,7 @@
     {
         try
         {
+        	// TODO: we shouldn't have to clone here
             database.addTable((Table)_newTable.clone());
         }
         catch (CloneNotSupportedException ex)

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnAutoIncrementChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnAutoIncrementChange.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnAutoIncrementChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnAutoIncrementChange.java Tue Oct  2 22:29:42 2007
@@ -29,11 +29,8 @@
  * 
  * @version $Revision: $
  */
-public class ColumnAutoIncrementChange extends TableChangeImplBase
+public class ColumnAutoIncrementChange extends ColumnChangeImplBase
 {
-    /** The column. */
-    private Column _column;
-
     /**
      * Creates a new change object.
      * 
@@ -42,28 +39,14 @@
      */
     public ColumnAutoIncrementChange(Table table, Column column)
     {
-        super(table);
-        _column = column;
-    }
-
-    /**
-     * Returns the column.
-     *
-     * @return The column
-     */
-    public Column getColumn()
-    {
-        return _column;
+        super(table, column);
     }
 
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database, boolean caseSensitive)
+    public void apply(Database model, boolean caseSensitive)
     {
-        Table  table  = database.findTable(getChangedTable().getName(), caseSensitive);
-        Column column = table.findColumn(_column.getName(), caseSensitive);
-
-        column.setAutoIncrement(!_column.isAutoIncrement());
+        findChangedColumn(model, caseSensitive).setAutoIncrement(!getChangedColumn().isAutoIncrement());
     }
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnChange.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnChange.java Tue Oct  2 22:29:42 2007
@@ -20,6 +20,7 @@
  */
 
 import org.apache.ddlutils.model.Column;
+import org.apache.ddlutils.model.Database;
 
 /**
  * Represents a change to a column of a table.
@@ -34,4 +35,13 @@
      * @return The affected column
      */
     public Column getChangedColumn();
+
+    /**
+     * Finds the column object corresponding to the changed column in the given database model.
+     * 
+     * @param model         The database model
+     * @param caseSensitive Whether identifiers are case sensitive
+     * @return The column object or <code>null</code> if it could not be found
+     */
+    public Column findChangedColumn(Database model, boolean caseSensitive);
 }

Added: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnChangeImplBase.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnChangeImplBase.java?rev=581500&view=auto
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnChangeImplBase.java (added)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnChangeImplBase.java Tue Oct  2 22:29:42 2007
@@ -0,0 +1,42 @@
+package org.apache.ddlutils.alteration;
+
+import org.apache.ddlutils.model.Column;
+import org.apache.ddlutils.model.Database;
+import org.apache.ddlutils.model.Table;
+
+public abstract class ColumnChangeImplBase extends    TableChangeImplBase
+                                           implements ColumnChange
+{
+    /** The column. */
+    private Column _column;
+
+    /**
+     * Creates a new change object.
+     * 
+     * @param table  The table to remove the column from
+     * @param column The column
+     */
+    public ColumnChangeImplBase(Table table, Column column)
+    {
+        super(table);
+        _column = column;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Column getChangedColumn()
+    {
+        return _column;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Column findChangedColumn(Database model, boolean caseSensitive)
+    {
+    	Table table = findChangedTable(model, caseSensitive);
+
+    	return table == null ? null : table.findColumn(_column.getName(), caseSensitive);
+    }
+}

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDataTypeChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDataTypeChange.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDataTypeChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDataTypeChange.java Tue Oct  2 22:29:42 2007
@@ -28,10 +28,8 @@
  * 
  * @version $Revision: $
  */
-public class ColumnDataTypeChange extends TableChangeImplBase implements ColumnChange
+public class ColumnDataTypeChange extends ColumnChangeImplBase
 {
-    /** The column. */
-    private Column _column;
     /** The JDBC type code of the new type. */
     private int _newTypeCode;
 
@@ -44,22 +42,11 @@
      */
     public ColumnDataTypeChange(Table table, Column column, int newTypeCode)
     {
-        super(table);
-        _column      = column;
+        super(table, column);
         _newTypeCode = newTypeCode;
     }
 
     /**
-     * Returns the column.
-     *
-     * @return The column
-     */
-    public Column getChangedColumn()
-    {
-        return _column;
-    }
-
-    /**
      * Returns the JDBC type code of the new type.
      *
      * @return The type code
@@ -72,11 +59,8 @@
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database, boolean caseSensitive)
+    public void apply(Database model, boolean caseSensitive)
     {
-        Table  table  = database.findTable(getChangedTable().getName(), caseSensitive);
-        Column column = table.findColumn(_column.getName(), caseSensitive);
-
-        column.setTypeCode(_newTypeCode);
+        findChangedColumn(model, caseSensitive).setTypeCode(_newTypeCode);
     }
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDefaultValueChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDefaultValueChange.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDefaultValueChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDefaultValueChange.java Tue Oct  2 22:29:42 2007
@@ -28,10 +28,8 @@
  * 
  * @version $Revision: $
  */
-public class ColumnDefaultValueChange extends TableChangeImplBase implements ColumnChange
+public class ColumnDefaultValueChange extends ColumnChangeImplBase
 {
-    /** The column. */
-    private Column _column;
     /** The new default value. */
     private String _newDefaultValue;
 
@@ -44,22 +42,11 @@
      */
     public ColumnDefaultValueChange(Table table, Column column, String newDefaultValue)
     {
-        super(table);
-        _column          = column;
+        super(table, column);
         _newDefaultValue = newDefaultValue;
     }
 
     /**
-     * Returns the column.
-     *
-     * @return The column
-     */
-    public Column getChangedColumn()
-    {
-        return _column;
-    }
-
-    /**
      * Returns the new default value.
      *
      * @return The new default value
@@ -72,11 +59,8 @@
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database, boolean caseSensitive)
+    public void apply(Database model, boolean caseSensitive)
     {
-        Table  table  = database.findTable(getChangedTable().getName(), caseSensitive);
-        Column column = table.findColumn(_column.getName(), caseSensitive);
-
-        column.setDefaultValue(_newDefaultValue);
+        findChangedColumn(model, caseSensitive).setDefaultValue(_newDefaultValue);
     }
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnRequiredChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnRequiredChange.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnRequiredChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnRequiredChange.java Tue Oct  2 22:29:42 2007
@@ -29,11 +29,8 @@
  * 
  * @version $Revision: $
  */
-public class ColumnRequiredChange extends TableChangeImplBase implements ColumnChange
+public class ColumnRequiredChange extends ColumnChangeImplBase
 {
-    /** The column. */
-    private Column _column;
-
     /**
      * Creates a new change object.
      * 
@@ -42,28 +39,14 @@
      */
     public ColumnRequiredChange(Table table, Column column)
     {
-        super(table);
-        _column = column;
-    }
-
-    /**
-     * Returns the column.
-     *
-     * @return The column
-     */
-    public Column getChangedColumn()
-    {
-        return _column;
+        super(table, column);
     }
 
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database, boolean caseSensitive)
+    public void apply(Database model, boolean caseSensitive)
     {
-        Table  table  = database.findTable(getChangedTable().getName(), caseSensitive);
-        Column column = table.findColumn(_column.getName(), caseSensitive);
-
-        column.setRequired(!_column.isRequired());
+        findChangedColumn(model, caseSensitive).setRequired(!getChangedColumn().isRequired());
     }
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnSizeChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnSizeChange.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnSizeChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnSizeChange.java Tue Oct  2 22:29:42 2007
@@ -28,10 +28,8 @@
  * 
  * @version $Revision: $
  */
-public class ColumnSizeChange extends TableChangeImplBase implements ColumnChange
+public class ColumnSizeChange extends ColumnChangeImplBase
 {
-    /** The column. */
-    private Column _column;
     /** The new size. */
     private int _newSize;
     /** The new scale. */
@@ -47,23 +45,12 @@
      */
     public ColumnSizeChange(Table table, Column column, int newSize, int newScale)
     {
-        super(table);
-        _column   = column;
+        super(table, column);
         _newSize  = newSize;
         _newScale = newScale;
     }
 
     /**
-     * Returns the column.
-     *
-     * @return The column
-     */
-    public Column getChangedColumn()
-    {
-        return _column;
-    }
-
-    /**
      * Returns the new size of the column.
      *
      * @return The new size
@@ -86,11 +73,8 @@
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database, boolean caseSensitive)
+    public void apply(Database model, boolean caseSensitive)
     {
-        Table  table  = database.findTable(getChangedTable().getName(), caseSensitive);
-        Column column = table.findColumn(_column.getName(), caseSensitive);
-
-        column.setSizeAndScale(_newSize, _newScale);
+        findChangedColumn(model, caseSensitive).setSizeAndScale(_newSize, _newScale);
     }
 }

Added: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ForeignKeyChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ForeignKeyChange.java?rev=581500&view=auto
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ForeignKeyChange.java (added)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ForeignKeyChange.java Tue Oct  2 22:29:42 2007
@@ -0,0 +1,47 @@
+package org.apache.ddlutils.alteration;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.ddlutils.model.Database;
+import org.apache.ddlutils.model.ForeignKey;
+
+/**
+ * Represents a change to a foreign key of a table.
+ * 
+ * @version $Revision: $
+ */
+public interface ForeignKeyChange extends TableChange
+{
+    /**
+     * Returns the affected foreign key from the original model.
+     * 
+     * @return The affected foreign key
+     */
+    public ForeignKey getChangedForeignKey();
+
+    /**
+     * Finds the foreign key object corresponding to the changed foreign key in the given database model.
+     * 
+     * @param model         The database model
+     * @param caseSensitive Whether identifiers are case sensitive
+     * @return The foreign key object or <code>null</code> if it could not be found
+     */
+    public ForeignKey findChangedForeignKey(Database model, boolean caseSensitive);
+}

Added: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ForeignKeyChangeImplBase.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ForeignKeyChangeImplBase.java?rev=581500&view=auto
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ForeignKeyChangeImplBase.java (added)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ForeignKeyChangeImplBase.java Tue Oct  2 22:29:42 2007
@@ -0,0 +1,55 @@
+package org.apache.ddlutils.alteration;
+
+import org.apache.ddlutils.model.Database;
+import org.apache.ddlutils.model.ForeignKey;
+import org.apache.ddlutils.model.Table;
+
+public abstract class ForeignKeyChangeImplBase extends    TableChangeImplBase
+                                               implements ForeignKeyChange
+{
+    /** The foreign key. */
+    private ForeignKey _foreignKey;
+
+    /**
+     * Creates a new change object.
+     * 
+     * @param table      The table
+     * @param foreignKey The foreign key
+     */
+    public ForeignKeyChangeImplBase(Table table, ForeignKey foreignKey)
+    {
+        super(table);
+        _foreignKey = foreignKey;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public ForeignKey getChangedForeignKey()
+    {
+        return _foreignKey;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public ForeignKey findChangedForeignKey(Database model, boolean caseSensitive)
+    {
+    	Table table = findChangedTable(model, caseSensitive);
+
+    	if (table != null)
+    	{
+            for (int fkIdx = 0; fkIdx < table.getForeignKeyCount(); fkIdx++)
+            {
+                ForeignKey curFk = table.getForeignKey(fkIdx);
+
+                if ((caseSensitive  && _foreignKey.equals(curFk)) ||
+                    (!caseSensitive && _foreignKey.equalsIgnoreCase(curFk)))
+                {
+                    return curFk;
+                }
+            }
+    	}
+        return null;
+    }
+}

Added: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/IndexChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/IndexChange.java?rev=581500&view=auto
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/IndexChange.java (added)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/IndexChange.java Tue Oct  2 22:29:42 2007
@@ -0,0 +1,47 @@
+package org.apache.ddlutils.alteration;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.ddlutils.model.Database;
+import org.apache.ddlutils.model.Index;
+
+/**
+ * Represents a change to a index of a table.
+ * 
+ * @version $Revision: $
+ */
+public interface IndexChange extends TableChange
+{
+    /**
+     * Returns the affected index from the original model.
+     * 
+     * @return The affected index
+     */
+    public Index getChangedIndex();
+
+    /**
+     * Finds the index object corresponding to the changed index in the given database model.
+     * 
+     * @param model         The database model
+     * @param caseSensitive Whether identifiers are case sensitive
+     * @return The index object or <code>null</code> if it could not be found
+     */
+    public Index findChangedIndex(Database model, boolean caseSensitive);
+}

Added: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/IndexChangeImplBase.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/IndexChangeImplBase.java?rev=581500&view=auto
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/IndexChangeImplBase.java (added)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/IndexChangeImplBase.java Tue Oct  2 22:29:42 2007
@@ -0,0 +1,55 @@
+package org.apache.ddlutils.alteration;
+
+import org.apache.ddlutils.model.Database;
+import org.apache.ddlutils.model.Index;
+import org.apache.ddlutils.model.Table;
+
+public abstract class IndexChangeImplBase extends    TableChangeImplBase
+                                          implements IndexChange
+{
+    /** The index. */
+    private Index _index;
+
+    /**
+     * Creates a new change object.
+     * 
+     * @param table The table
+     * @param index The index
+     */
+    public IndexChangeImplBase(Table table, Index index)
+    {
+        super(table);
+        _index = index;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Index getChangedIndex()
+    {
+        return _index;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Index findChangedIndex(Database model, boolean caseSensitive)
+    {
+    	Table table = findChangedTable(model, caseSensitive);
+
+    	if (table != null)
+    	{
+            for (int indexIdx = 0; indexIdx < table.getIndexCount(); indexIdx++)
+            {
+                Index curIndex = table.getIndex(indexIdx);
+
+                if ((caseSensitive  && _index.equals(curIndex)) ||
+                    (!caseSensitive && _index.equalsIgnoreCase(curIndex)))
+                {
+                    return curIndex;
+                }
+            }
+    	}
+        return null;
+    }
+}

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ModelComparator.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ModelComparator.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ModelComparator.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ModelComparator.java Tue Oct  2 22:29:42 2007
@@ -297,7 +297,7 @@
                 {
                     _log.info("The primary key of table " + sourceTable.getName() + " needs to be changed");
                 }
-                changes.add(new PrimaryKeyChange(sourceTable, sourcePK, targetPK));
+                changes.add(new PrimaryKeyChange(sourceTable, targetPK));
             }
         }
         

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/PrimaryKeyChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/PrimaryKeyChange.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/PrimaryKeyChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/PrimaryKeyChange.java Tue Oct  2 22:29:42 2007
@@ -39,13 +39,12 @@
      * Creates a new change object.
      * 
      * @param table                The table whose primary key is to be changed
-     * @param oldPrimaryKeyColumns The columns making up the original primary key
      * @param newPrimaryKeyColumns The columns making up the new primary key
      */
-    public PrimaryKeyChange(Table table, Column[] oldPrimaryKeyColumns, Column[] newPrimaryKeyColumns)
+    public PrimaryKeyChange(Table table, Column[] newPrimaryKeyColumns)
     {
         super(table);
-        _oldPrimaryKeyColumns = oldPrimaryKeyColumns;
+        _oldPrimaryKeyColumns = table.getPrimaryKeyColumns();
         _newPrimaryKeyColumns = newPrimaryKeyColumns;
     }
 
@@ -72,9 +71,9 @@
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database, boolean caseSensitive)
+    public void apply(Database model, boolean caseSensitive)
     {
-        Table table = database.findTable(getChangedTable().getName(), caseSensitive);
+        Table table = findChangedTable(model, caseSensitive);
 
         for (int idx = 0; idx < _oldPrimaryKeyColumns.length; idx++)
         {

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveColumnChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveColumnChange.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveColumnChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveColumnChange.java Tue Oct  2 22:29:42 2007
@@ -28,11 +28,8 @@
  * 
  * @version $Revision: $
  */
-public class RemoveColumnChange extends TableChangeImplBase
+public class RemoveColumnChange extends ColumnChangeImplBase
 {
-    /** The column. */
-    private Column _column;
-
     /**
      * Creates a new change object.
      * 
@@ -41,28 +38,14 @@
      */
     public RemoveColumnChange(Table table, Column column)
     {
-        super(table);
-        _column = column;
-    }
-
-    /**
-     * Returns the column.
-     *
-     * @return The column
-     */
-    public Column getColumn()
-    {
-        return _column;
+        super(table, column);
     }
 
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database, boolean caseSensitive)
+    public void apply(Database model, boolean caseSensitive)
     {
-        Table  table  = database.findTable(getChangedTable().getName(), caseSensitive);
-        Column column = table.findColumn(_column.getName(), caseSensitive);
-
-        table.removeColumn(column);
+        findChangedTable(model, caseSensitive).removeColumn(findChangedColumn(model, caseSensitive));
     }
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveForeignKeyChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveForeignKeyChange.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveForeignKeyChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveForeignKeyChange.java Tue Oct  2 22:29:42 2007
@@ -30,11 +30,8 @@
  * 
  * @version $Revision: $
  */
-public class RemoveForeignKeyChange extends TableChangeImplBase
+public class RemoveForeignKeyChange extends ForeignKeyChangeImplBase
 {
-    /** The foreign key. */
-    private ForeignKey _foreignKey;
-
     /**
      * Creates a new change object.
      * 
@@ -43,27 +40,14 @@
      */
     public RemoveForeignKeyChange(Table table, ForeignKey foreignKey)
     {
-        super(table);
-        _foreignKey = foreignKey;
-    }
-
-    /**
-     * Returns the foreign key to be removed.
-     *
-     * @return The foreign key
-     */
-    public ForeignKey getForeignKey()
-    {
-        return _foreignKey;
+        super(table, foreignKey);
     }
 
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database, boolean caseSensitive)
+    public void apply(Database model, boolean caseSensitive)
     {
-        Table table = database.findTable(getChangedTable().getName(), caseSensitive);
-
-        table.removeForeignKey(_foreignKey);
+        findChangedTable(model, caseSensitive).removeForeignKey(findChangedForeignKey(model, caseSensitive));
     }
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveIndexChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveIndexChange.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveIndexChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveIndexChange.java Tue Oct  2 22:29:42 2007
@@ -28,11 +28,8 @@
  * 
  * @version $Revision: $
  */
-public class RemoveIndexChange extends TableChangeImplBase
+public class RemoveIndexChange extends IndexChangeImplBase
 {
-    /** The index to be removed. */
-    private Index _index;
-
     /**
      * Creates a new change object.
      * 
@@ -41,28 +38,14 @@
      */
     public RemoveIndexChange(Table table, Index index)
     {
-        super(table);
-        _index = index;
-    }
-
-    /**
-     * Returns the index.
-     *
-     * @return The index
-     */
-    public Index getIndex()
-    {
-        return _index;
+        super(table, index);
     }
 
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database, boolean caseSensitive)
+    public void apply(Database model, boolean caseSensitive)
     {
-        Table table = database.findTable(getChangedTable().getName(), caseSensitive);
-        Index index = table.findIndex(_index.getName(), caseSensitive);
-
-        table.removeIndex(index);
+        findChangedTable(model, caseSensitive).removeIndex(findChangedIndex(model, caseSensitive));
     }
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemovePrimaryKeyChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemovePrimaryKeyChange.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemovePrimaryKeyChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemovePrimaryKeyChange.java Tue Oct  2 22:29:42 2007
@@ -58,9 +58,9 @@
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database, boolean caseSensitive)
+    public void apply(Database model, boolean caseSensitive)
     {
-        Table table = database.findTable(getChangedTable().getName(), caseSensitive);
+        Table table = findChangedTable(model, caseSensitive);
 
         for (int idx = 0; idx < _primaryKeyColumns.length; idx++)
         {

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveTableChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveTableChange.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveTableChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/RemoveTableChange.java Tue Oct  2 22:29:42 2007
@@ -42,10 +42,10 @@
     /**
      * {@inheritDoc}
      */
-    public void apply(Database database, boolean caseSensitive)
+    public void apply(Database model, boolean caseSensitive)
     {
-        Table table = database.findTable(getChangedTable().getName(), caseSensitive);
+        Table table = findChangedTable(model, caseSensitive);
 
-        database.removeTable(table);
+        model.removeTable(table);
     }
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/TableChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/TableChange.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/TableChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/TableChange.java Tue Oct  2 22:29:42 2007
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import org.apache.ddlutils.model.Database;
 import org.apache.ddlutils.model.Table;
 
 /**
@@ -34,4 +35,13 @@
      * @return The affected table
      */
     public Table getChangedTable();
+
+    /**
+     * Finds the table object corresponding to the changed table in the given database model.
+     * 
+     * @param model         The database model
+     * @param caseSensitive Whether identifiers are case sensitive
+     * @return The table object or <code>null</code> if it could not be found
+     */
+    public Table findChangedTable(Database model, boolean caseSensitive);
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/TableChangeImplBase.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/TableChangeImplBase.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/TableChangeImplBase.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/TableChangeImplBase.java Tue Oct  2 22:29:42 2007
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import org.apache.ddlutils.model.Database;
 import org.apache.ddlutils.model.Table;
 
 /**
@@ -42,12 +43,18 @@
     }
 
     /**
-     * Returns the affected table.
-     * 
-     * @return The table
+     * {@inheritDoc}
      */
     public Table getChangedTable()
     {
         return _table;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Table findChangedTable(Database model, boolean caseSensitive)
+    {
+    	return model.findTable(_table.getName(), caseSensitive);
     }
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Table.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Table.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Table.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Table.java Tue Oct  2 22:29:42 2007
@@ -49,7 +49,7 @@
     private String _schema = null;
     /** The name. */
     private String _name = null;
-    /** A desription of the table. */
+    /** A description of the table. */
     private String _description = null;
     /** The table's type as read from the database. */
     private String _type = null;

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SqlBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SqlBuilder.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SqlBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SqlBuilder.java Tue Oct  2 22:29:42 2007
@@ -618,7 +618,7 @@
                                  CreationParameters     params,
                                  RemoveForeignKeyChange change) throws IOException
     {
-        writeExternalForeignKeyDropStmt(change.getChangedTable(), change.getForeignKey());
+        writeExternalForeignKeyDropStmt(change.getChangedTable(), change.getChangedForeignKey());
         change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
     }
 
@@ -636,7 +636,7 @@
                                  CreationParameters params,
                                  RemoveIndexChange  change) throws IOException
     {
-        writeExternalIndexDropStmt(change.getChangedTable(), change.getIndex());
+        writeExternalIndexDropStmt(change.getChangedTable(), change.getChangedIndex());
         change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
     }
 

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2Builder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2Builder.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2Builder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2Builder.java Tue Oct  2 22:29:42 2007
@@ -227,7 +227,7 @@
         printlnIdentifier(getTableName(change.getChangedTable()));
         printIndent();
         print("DROP COLUMN ");
-        printIdentifier(getColumnName(change.getColumn()));
+        printIdentifier(getColumnName(change.getChangedColumn()));
         printEndOfStatement();
         change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdBuilder.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdBuilder.java Tue Oct  2 22:29:42 2007
@@ -257,7 +257,7 @@
             	// TODO: we cannot drop primary key columns this way
             	//       because we would have to drop the pk first and then
             	//       add a new one afterwards which is not supported yet
-            	if (!removeColumnChange.getColumn().isPrimaryKey())
+            	if (!removeColumnChange.getChangedColumn().isPrimaryKey())
             	{
 	            	processChange(currentModel, desiredModel, removeColumnChange);
 	                changeIt.remove();
@@ -336,15 +336,15 @@
                                  Database           desiredModel,
                                  RemoveColumnChange change) throws IOException
     {
-        if (change.getColumn().isAutoIncrement())
+        if (change.getChangedColumn().isAutoIncrement())
         {
-            writeAutoIncrementDropStmts(change.getChangedTable(), change.getColumn());
+            writeAutoIncrementDropStmts(change.getChangedTable(), change.getChangedColumn());
         }
         print("ALTER TABLE ");
         printlnIdentifier(getTableName(change.getChangedTable()));
         printIndent();
         print("DROP ");
-        printIdentifier(getColumnName(change.getColumn()));
+        printIdentifier(getColumnName(change.getChangedColumn()));
         printEndOfStatement();
         change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbBuilder.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbBuilder.java Tue Oct  2 22:29:42 2007
@@ -87,7 +87,7 @@
             TableChange change = (TableChange)changeIt.next();
 
             if ((change instanceof RemoveColumnChange) && 
-                ((RemoveColumnChange)change).getColumn().isPrimaryKey())
+                ((RemoveColumnChange)change).getChangedColumn().isPrimaryKey())
             {
                 return;
             }
@@ -172,7 +172,7 @@
         printlnIdentifier(getTableName(change.getChangedTable()));
         printIndent();
         print("DROP COLUMN ");
-        printIdentifier(getColumnName(change.getColumn()));
+        printIdentifier(getColumnName(change.getChangedColumn()));
         printEndOfStatement();
         change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseBuilder.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseBuilder.java Tue Oct  2 22:29:42 2007
@@ -257,7 +257,7 @@
                 // TODO: we cannot drop primary key columns this way
                 //       because we would have to drop the pk first and then
                 //       add a new one afterwards which is not supported yet
-                if (!removeColumnChange.getColumn().isPrimaryKey())
+                if (!removeColumnChange.getChangedColumn().isPrimaryKey())
                 {
                     processChange(currentModel, desiredModel, removeColumnChange);
                     changeIt.remove();
@@ -336,15 +336,15 @@
                                  Database           desiredModel,
                                  RemoveColumnChange change) throws IOException
     {
-        if (change.getColumn().isAutoIncrement())
+        if (change.getChangedColumn().isAutoIncrement())
         {
-            writeAutoIncrementDropStmts(change.getChangedTable(), change.getColumn());
+            writeAutoIncrementDropStmts(change.getChangedTable(), change.getChangedColumn());
         }
         print("ALTER TABLE ");
         printlnIdentifier(getTableName(change.getChangedTable()));
         printIndent();
         print("DROP ");
-        printIdentifier(getColumnName(change.getColumn()));
+        printIdentifier(getColumnName(change.getChangedColumn()));
         printEndOfStatement();
         change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mckoi/MckoiBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mckoi/MckoiBuilder.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mckoi/MckoiBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mckoi/MckoiBuilder.java Tue Oct  2 22:29:42 2007
@@ -189,7 +189,7 @@
 
             if (change instanceof ColumnAutoIncrementChange)
             {
-                Column column = ((ColumnAutoIncrementChange)change).getColumn();
+                Column column = ((ColumnAutoIncrementChange)change).getChangedColumn();
 
                 // we have to defer removal of the sequences until they are no longer used
                 if (!column.isAutoIncrement())
@@ -197,7 +197,7 @@
                     ColumnAutoIncrementChange autoIncrChange = (ColumnAutoIncrementChange)change;
 
                     createAutoIncrementSequence(autoIncrChange.getChangedTable(),
-                                                autoIncrChange.getColumn());
+                                                autoIncrChange.getChangedColumn());
                 }
             }
             else if (change instanceof AddColumnChange)
@@ -221,24 +221,24 @@
     
             if (change instanceof ColumnAutoIncrementChange)
             {
-                Column column = ((ColumnAutoIncrementChange)change).getColumn();
+                Column column = ((ColumnAutoIncrementChange)change).getChangedColumn();
     
                 if (column.isAutoIncrement())
                 {
                     ColumnAutoIncrementChange autoIncrChange = (ColumnAutoIncrementChange)change;
         
                     dropAutoIncrementSequence(autoIncrChange.getChangedTable(),
-                                              autoIncrChange.getColumn());
+                                              autoIncrChange.getChangedColumn());
                 }
             }
             else if (change instanceof RemoveColumnChange)
             {
                 RemoveColumnChange removeColumnChange = (RemoveColumnChange)change;
 
-                if (removeColumnChange.getColumn().isAutoIncrement())
+                if (removeColumnChange.getChangedColumn().isAutoIncrement())
                 {
                     dropAutoIncrementSequence(removeColumnChange.getChangedTable(),
-                                              removeColumnChange.getColumn());
+                                              removeColumnChange.getChangedColumn());
                 }
             }
         }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlBuilder.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlBuilder.java Tue Oct  2 22:29:42 2007
@@ -413,11 +413,11 @@
 
             if (change instanceof RemoveIndexChange)
             {
-                removedIndexes.add(((RemoveIndexChange)change).getIndex());
+                removedIndexes.add(((RemoveIndexChange)change).getChangedIndex());
             }
             else if (change instanceof RemoveForeignKeyChange)
             {
-                removedForeignKeys.add(((RemoveForeignKeyChange)change).getForeignKey());
+                removedForeignKeys.add(((RemoveForeignKeyChange)change).getChangedForeignKey());
             }
             else if (change instanceof RemovePrimaryKeyChange)
             {
@@ -626,7 +626,7 @@
         printlnIdentifier(getTableName(change.getChangedTable()));
         printIndent();
         print("DROP COLUMN ");
-        printIdentifier(getColumnName(change.getColumn()));
+        printIdentifier(getColumnName(change.getChangedColumn()));
         printEndOfStatement();
         change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlBuilder.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlBuilder.java Tue Oct  2 22:29:42 2007
@@ -284,7 +284,7 @@
         printlnIdentifier(getTableName(change.getChangedTable()));
         printIndent();
         print("DROP COLUMN ");
-        printIdentifier(getColumnName(change.getColumn()));
+        printIdentifier(getColumnName(change.getChangedColumn()));
         printEndOfStatement();
         change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Builder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Builder.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Builder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Builder.java Tue Oct  2 22:29:42 2007
@@ -489,16 +489,16 @@
                                  Database           desiredModel,
                                  RemoveColumnChange change) throws IOException
     {
-        if (change.getColumn().isAutoIncrement())
+        if (change.getChangedColumn().isAutoIncrement())
         {
-            dropAutoIncrementTrigger(change.getChangedTable(), change.getColumn());
-            dropAutoIncrementSequence(change.getChangedTable(), change.getColumn());
+            dropAutoIncrementTrigger(change.getChangedTable(), change.getChangedColumn());
+            dropAutoIncrementSequence(change.getChangedTable(), change.getChangedColumn());
         }
         print("ALTER TABLE ");
         printlnIdentifier(getTableName(change.getChangedTable()));
         printIndent();
         print("DROP COLUMN ");
-        printIdentifier(getColumnName(change.getColumn()));
+        printIdentifier(getColumnName(change.getChangedColumn()));
         printEndOfStatement();
         change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlBuilder.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlBuilder.java Tue Oct  2 22:29:42 2007
@@ -250,11 +250,11 @@
         printlnIdentifier(getTableName(change.getChangedTable()));
         printIndent();
         print("DROP COLUMN ");
-        printIdentifier(getColumnName(change.getColumn()));
+        printIdentifier(getColumnName(change.getChangedColumn()));
         printEndOfStatement();
-        if (change.getColumn().isAutoIncrement())
+        if (change.getChangedColumn().isAutoIncrement())
         {
-            dropAutoIncrementSequence(change.getChangedTable(), change.getColumn());
+            dropAutoIncrementSequence(change.getChangedTable(), change.getChangedColumn());
         }
         change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sapdb/SapDbBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sapdb/SapDbBuilder.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sapdb/SapDbBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sapdb/SapDbBuilder.java Tue Oct  2 22:29:42 2007
@@ -273,7 +273,7 @@
         printlnIdentifier(getTableName(change.getChangedTable()));
         printIndent();
         print("DROP ");
-        printIdentifier(getColumnName(change.getColumn()));
+        printIdentifier(getColumnName(change.getChangedColumn()));
         print(" RELEASE SPACE");
         printEndOfStatement();
         change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseBuilder.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseBuilder.java Tue Oct  2 22:29:42 2007
@@ -550,7 +550,7 @@
         printlnIdentifier(getTableName(change.getChangedTable()));
         printIndent();
         print("DROP ");
-        printIdentifier(getColumnName(change.getColumn()));
+        printIdentifier(getColumnName(change.getChangedColumn()));
         printEndOfStatement();
         change.apply(currentModel, getPlatform().isDelimitedIdentifierModeOn());
     }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/alteration/TestModelComparator.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/alteration/TestModelComparator.java?rev=581500&r1=581499&r2=581500&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/alteration/TestModelComparator.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/alteration/TestModelComparator.java Tue Oct  2 22:29:42 2007
@@ -298,7 +298,7 @@
         RemoveForeignKeyChange change = (RemoveForeignKeyChange)changes.get(0);
 
         assertEquals("TestFK",
-                     change.getForeignKey().getName());
+                     change.getChangedForeignKey().getName());
     }
 
     /**
@@ -346,7 +346,7 @@
         AddForeignKeyChange    change2 = (AddForeignKeyChange)changes.get(1);
 
         assertEquals("TestFK",
-                     change1.getForeignKey().getName());
+                     change1.getChangedForeignKey().getName());
         assertEquals("TESTFK",
                      change2.getNewForeignKey().getName());
     }
@@ -402,7 +402,7 @@
         AddForeignKeyChange    change2 = (AddForeignKeyChange)changes.get(1);
 
         assertEquals("TestFK",
-                     change1.getForeignKey().getName());
+                     change1.getChangedForeignKey().getName());
         assertEquals("TestFK",
                      change2.getNewForeignKey().getName());
     }
@@ -528,7 +528,7 @@
         RemoveIndexChange change = (RemoveIndexChange)changes.get(0);
 
         assertEquals("TestIndex",
-                     change.getIndex().getName());
+                     change.getChangedIndex().getName());
     }
 
     /**
@@ -570,7 +570,7 @@
         AddIndexChange    change2 = (AddIndexChange)changes.get(1);
 
         assertEquals("TestIndex",
-                     change1.getIndex().getName());
+                     change1.getChangedIndex().getName());
         assertEquals("TestIndex",
                      change2.getNewIndex().getName());
     }
@@ -618,7 +618,7 @@
         AddIndexChange    change2 = (AddIndexChange)changes.get(1);
 
         assertEquals("TestIndex",
-                     change1.getIndex().getName());
+                     change1.getChangedIndex().getName());
         assertEquals("TestIndex",
                      change2.getNewIndex().getName());
     }
@@ -665,7 +665,7 @@
         AddIndexChange    change2 = (AddIndexChange)changes.get(1);
 
         assertEquals("TestIndex",
-                     change1.getIndex().getName());
+                     change1.getChangedIndex().getName());
         assertEquals("TestIndex",
                      change2.getNewIndex().getName());
     }
@@ -712,7 +712,7 @@
         AddIndexChange    change2 = (AddIndexChange)changes.get(1);
 
         assertEquals("TestIndex",
-                     change1.getIndex().getName());
+                     change1.getChangedIndex().getName());
         assertEquals("TestIndex",
                      change2.getNewIndex().getName());
     }
@@ -982,7 +982,7 @@
         RemoveColumnChange change = (RemoveColumnChange)changes.get(0);
 
         assertEquals("Col1",
-                     change.getColumn().getName());
+                     change.getChangedColumn().getName());
     }
 
     /**
@@ -1306,6 +1306,6 @@
         ColumnAutoIncrementChange change = (ColumnAutoIncrementChange)changes.get(0);
 
         assertEquals("Col",
-                     change.getColumn().getName());
+                     change.getChangedColumn().getName());
     }
 }



Mime
View raw message