Revision: 6156
http://squirrel-sql.svn.sourceforge.net/squirrel-sql/?rev=6156&view=rev
Author: manningr
Date: 2011-02-13 17:01:24 +0000 (Sun, 13 Feb 2011)
Log Message:
-----------
Added new mode (side-by-side table definition comparison using internal/external diff tool). Uses components from JMeld to perform internal table definition comparison. Old tabular comparison is still supported via configuration. Default is internal side-by-side comparison.
Modified Paths:
--------------
trunk/sql12/plugins/dbdiff/pom.xml
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/ColumnDifference.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/DBDiffPlugin.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/DBDiffPluginResources.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/DBDiffPluginSessionCallback.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/SessionInfoProvider.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/TableDiffExecutor.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/actions/CompareAction.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/actions/SelectAction.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/commands/CompareCommand.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/commands/SelectCommand.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/gui/ColumnDiffDialog.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/util/AbstractDifference.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/util/DBUtil.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/util/TableColumnDifference.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/util/TableDifference.java
trunk/sql12/plugins/dbdiff/src/main/resources/doc/changes.txt
trunk/sql12/plugins/dbdiff/src/test/java/net/sourceforge/squirrel_sql/plugins/dbdiff/ColumnDifferenceTest.java
trunk/sql12/plugins/dbdiff/src/test/java/net/sourceforge/squirrel_sql/plugins/dbdiff/DBDiffPluginResourcesTest.java
trunk/sql12/plugins/dbdiff/src/test/java/net/sourceforge/squirrel_sql/plugins/dbdiff/DBDiffPluginTest.java
trunk/sql12/plugins/dbdiff/src/test/java/net/sourceforge/squirrel_sql/plugins/dbdiff/util/AbstractDifferenceTest.java
Added Paths:
-----------
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/IScriptFileManager.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/ScriptFileManager.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/actions/AbstractDiffAction.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/commands/AbstractDiffCommand.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/gui/AbstractDiffPresentation.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/gui/AbstractSideBySideDiffPresentation.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/gui/DiffPresentationFactoryImpl.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/gui/ExternalToolSideBySideDiffPresentation.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/gui/IDiffPresentation.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/gui/IDiffPresentationFactory.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/gui/JMeldDiffPresentation.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/gui/TabularDiffPresentation.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/prefs/
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/prefs/DBDiffPreferenceBean.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/prefs/DBDiffPreferencesPanel.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/prefs/DefaultPluginGlobalPreferencesTab.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/prefs/DefaultPluginPreferencesManager.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/prefs/IPluginPreferenceBean.java
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/prefs/IPluginPreferencesManager.java
trunk/sql12/plugins/dbdiff/src/main/resources/net/sourceforge/squirrel_sql/plugins/dbdiff/prefs/
trunk/sql12/plugins/dbdiff/src/main/resources/net/sourceforge/squirrel_sql/plugins/dbdiff/prefs/I18NStrings.properties
trunk/sql12/plugins/dbdiff/src/test/java/net/sourceforge/squirrel_sql/plugins/dbdiff/gui/
trunk/sql12/plugins/dbdiff/src/test/java/net/sourceforge/squirrel_sql/plugins/dbdiff/gui/AbstractSideBySideDiffPresentationTest.java
trunk/sql12/plugins/dbdiff/src/test/java/net/sourceforge/squirrel_sql/plugins/dbdiff/gui/DiffPresentationFactoryImplTest.java
trunk/sql12/plugins/dbdiff/src/test/java/net/sourceforge/squirrel_sql/plugins/dbdiff/prefs/
trunk/sql12/plugins/dbdiff/src/test/java/net/sourceforge/squirrel_sql/plugins/dbdiff/prefs/DBDiffPreferencesPanelTestUI.java
Removed Paths:
-------------
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/DiffExecutor.java
Modified: trunk/sql12/plugins/dbdiff/pom.xml
===================================================================
--- trunk/sql12/plugins/dbdiff/pom.xml 2011-02-13 16:04:52 UTC (rev 6155)
+++ trunk/sql12/plugins/dbdiff/pom.xml 2011-02-13 17:01:24 UTC (rev 6156)
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.sf.squirrel-sql.plugins</groupId>
@@ -83,6 +84,31 @@
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.jmeld</groupId>
+ <artifactId>jmeld</artifactId>
+ <version>2.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.eclipse.ui</groupId>
+ <artifactId>forms</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.eclipse</groupId>
+ <artifactId>compare</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.swt.win32.win32</groupId>
+ <artifactId>x86</artifactId>
+ <version>3.3.0-v3346</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mod4j.org.eclipse.compare</groupId>
+ <artifactId>core</artifactId>
+ <version>3.5.0</version>
+ </dependency>
</dependencies>
<properties>
<pluginClassName>net.sourceforge.squirrel_sql.plugins.dbdiff.DBDiffPlugin</pluginClassName>
@@ -92,7 +118,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
- </plugin>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
Modified: trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/ColumnDifference.java
===================================================================
--- trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/ColumnDifference.java 2011-02-13 16:04:52 UTC (rev 6155)
+++ trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/ColumnDifference.java 2011-02-13 17:01:24 UTC (rev 6156)
@@ -1,4 +1,3 @@
-package net.sourceforge.squirrel_sql.plugins.dbdiff;
/*
* Copyright (C) 2007 Rob Manning
* man...@us...
@@ -17,262 +16,309 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
+package net.sourceforge.squirrel_sql.plugins.dbdiff;
+
import net.sourceforge.squirrel_sql.fw.sql.TableColumnInfo;
-
/**
- * This class is responsible for identifying and storing differences between
- * columns in a table.
+ * This class is responsible for identifying and storing differences between columns in a table.
*
* @author manningr
*/
-public class ColumnDifference {
+public class ColumnDifference
+{
- private String tableName = "";
- private String columnName = "";
+ private String tableName = "";
- private int col1Type = -1;
- private int col2Type = -1;
-
- private int col1Length = 0;
- private int col2Length = 0;
-
- private boolean col1IsNullable = false;
- private boolean col2IsNullable = false;
-
- private boolean col1Exists = true;
- private boolean col2Exists = true;
-
- private String col1remarks = "";
- private String col2remarks = "";
-
- private String col1default = "";
- private String col2default = "";
-
- public ColumnDifference() {}
-
- public void setColumns(TableColumnInfo c1, TableColumnInfo c2) {
- if (c1 == null || c2 == null) {
- throw new IllegalArgumentException("c1, c2 cannot be null");
- }
- if (!c1.getTableName().equals(c2.getTableName())) {
- throw new IllegalArgumentException(
- "Columns to be compared must be from the same table");
- }
- if (!c1.getColumnName().equals(c2.getColumnName())) {
- throw new IllegalArgumentException(
- "Columns to be compared must have the same column name");
- }
- setColumn1(c1);
- setColumn2(c2);
- }
+ private String columnName = "";
- public void setColumn1(TableColumnInfo c1) {
- col1Type = c1.getDataType();
- col1Length = c1.getColumnSize();
- col1IsNullable = c1.isNullable().equalsIgnoreCase("NO") ? false : true;
- tableName = c1.getTableName();
- columnName = c1.getColumnName();
- col1remarks = c1.getRemarks();
- col1default = c1.getDefaultValue();
- }
+ private int col1Type = -1;
- public void setColumn2(TableColumnInfo c2) {
- col2Type = c2.getDataType();
- col2Length = c2.getColumnSize();
- col2IsNullable = c2.isNullable().equalsIgnoreCase("NO") ? false : true;
- tableName = c2.getTableName();
- columnName = c2.getColumnName();
- col2remarks = c2.getRemarks();
- col2default = c2.getDefaultValue();
- }
-
- public int getCol1Type() {
- return col1Type;
- }
-
- public int getCol1Length() {
- return col1Length;
- }
-
- public boolean col1AllowsNull() {
- return col1IsNullable;
- }
+ private int col2Type = -1;
- public int getCol2Type() {
- return col2Type;
- }
-
- public int getCol2Length() {
- return col2Length;
- }
-
- public boolean col2AllowsNull() {
- return col2IsNullable;
- }
-
- public String getCol1Remarks() {
- return col1remarks;
- }
-
- public String getCol2Remarks() {
- return col2remarks;
- }
+ private int col1Length = 0;
- public String getCol1Default() {
- return col1default;
- }
-
- public String getCol2Default() {
- return col2default;
- }
-
- /**
- * Returns a boolean indicating whether or not the two columns are different
- * in any aspect.
- *
- * @return
- */
- public boolean execute() {
- if (!col1Exists || !col2Exists) {
- return true;
- }
- if (col1Type != col2Type) {
- return true;
- }
- if (col1Length != col2Length) {
- return true;
- }
- if (col1IsNullable != col2IsNullable) {
- return true;
- }
- if (!remarksEqual()) {
- return true;
- }
- return false;
- }
+ private int col2Length = 0;
- /**
- * @param tableName the tableName to set
- */
- public void setTableName(String tableName) {
- this.tableName = tableName;
- }
+ private boolean col1IsNullable = false;
- /**
- * @return the tableName
- */
- public String getTableName() {
- return tableName;
- }
+ private boolean col2IsNullable = false;
- /**
- * @param columnName the columnName to set
- */
- public void setColumnName(String columnName) {
- this.columnName = columnName;
- }
+ private boolean col1Exists = true;
- /**
- * @return the columnName
- */
- public String getColumnName() {
- return columnName;
- }
+ private boolean col2Exists = true;
- /**
- * @param col1Exists the col1Exists to set
- */
- public void setCol1Exists(boolean col1Exists) {
- this.col1Exists = col1Exists;
- }
+ private String col1remarks = "";
- /**
- * @return the col1Exists
- */
- public boolean isCol1Exists() {
- return col1Exists;
- }
+ private String col2remarks = "";
- /**
- * @param col2Exists the col2Exists to set
- */
- public void setCol2Exists(boolean col2Exists) {
- this.col2Exists = col2Exists;
- }
+ private String col1default = "";
- /**
- * @return the col2Exists
- */
- public boolean isCol2Exists() {
- return col2Exists;
- }
-
- public boolean defaultsEqual() {
- if (col1default == null && col2default == null) {
- return true;
- }
- if ((col1default == null && col2default != null)
- || (col1default != null && col2default == null)) {
- return false;
- }
- return col1default.equals(col2default);
- }
-
- public boolean remarksEqual() {
- if (col1remarks == null && col2remarks == null) {
- return true;
- }
- if ((col1remarks == null && col2remarks != null)
- || (col1remarks != null && col2remarks == null)) {
- return false;
- }
- return col1remarks.equals(col2remarks);
- }
-
- public boolean typesEqual() {
- return col1Type == col2Type;
- }
-
- public boolean lengthsEqual() {
- return col1Length == col2Length;
- }
-
- public boolean nullableEqual() {
- return col1IsNullable == col2IsNullable;
- }
-
- public String toString() {
- StringBuilder result = new StringBuilder();
- result.append("TABLE: ");
- result.append(tableName);
- result.append(" COLUMN: ");
- result.append(columnName);
- result.append("\n");
- result.append("source colType: ");
- result.append(col1Type);
- result.append("\n");
-
- result.append("dest colType: ");
- result.append(col2Type);
- result.append("\n");
+ private String col2default = "";
- result.append("source colLength: ");
- result.append(col1Length);
- result.append("\n");
+ public ColumnDifference()
+ {
+ }
- result.append("dest colLength: ");
- result.append(col2Length);
- result.append("\n");
+ public void setColumns(TableColumnInfo c1, TableColumnInfo c2)
+ {
+ if (c1 == null || c2 == null)
+ {
+ throw new IllegalArgumentException("c1, c2 cannot be null");
+ }
+ if (!c1.getColumnName().equals(c2.getColumnName()))
+ {
+ throw new IllegalArgumentException("Columns to be compared must have the same column name");
+ }
+ setColumn1(c1);
+ setColumn2(c2);
+ }
- result.append("source IsNullable: ");
- result.append(col1IsNullable);
- result.append("\n");
+ public void setColumn1(TableColumnInfo c1)
+ {
+ col1Type = c1.getDataType();
+ col1Length = c1.getColumnSize();
+ col1IsNullable = c1.isNullable().equalsIgnoreCase("NO") ? false : true;
+ tableName = c1.getTableName();
+ columnName = c1.getColumnName();
+ col1remarks = c1.getRemarks();
+ col1default = c1.getDefaultValue();
+ }
- result.append("dest IsNullable: ");
- result.append(col2IsNullable);
- result.append("\n");
-
- return result.toString();
- }
+ public void setColumn2(TableColumnInfo c2)
+ {
+ col2Type = c2.getDataType();
+ col2Length = c2.getColumnSize();
+ col2IsNullable = c2.isNullable().equalsIgnoreCase("NO") ? false : true;
+ tableName = c2.getTableName();
+ columnName = c2.getColumnName();
+ col2remarks = c2.getRemarks();
+ col2default = c2.getDefaultValue();
+ }
+
+ public int getCol1Type()
+ {
+ return col1Type;
+ }
+
+ public int getCol1Length()
+ {
+ return col1Length;
+ }
+
+ public boolean col1AllowsNull()
+ {
+ return col1IsNullable;
+ }
+
+ public int getCol2Type()
+ {
+ return col2Type;
+ }
+
+ public int getCol2Length()
+ {
+ return col2Length;
+ }
+
+ public boolean col2AllowsNull()
+ {
+ return col2IsNullable;
+ }
+
+ public String getCol1Remarks()
+ {
+ return col1remarks;
+ }
+
+ public String getCol2Remarks()
+ {
+ return col2remarks;
+ }
+
+ public String getCol1Default()
+ {
+ return col1default;
+ }
+
+ public String getCol2Default()
+ {
+ return col2default;
+ }
+
+ /**
+ * Returns a boolean indicating whether or not the two columns are different in any aspect.
+ *
+ * @return
+ */
+ public boolean execute()
+ {
+ if (!col1Exists || !col2Exists)
+ {
+ return true;
+ }
+ if (col1Type != col2Type)
+ {
+ return true;
+ }
+ if (col1Length != col2Length)
+ {
+ return true;
+ }
+ if (col1IsNullable != col2IsNullable)
+ {
+ return true;
+ }
+ if (!remarksEqual())
+ {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @param tableName
+ * the tableName to set
+ */
+ public void setTableName(String tableName)
+ {
+ this.tableName = tableName;
+ }
+
+ /**
+ * @return the tableName
+ */
+ public String getTableName()
+ {
+ return tableName;
+ }
+
+ /**
+ * @param columnName
+ * the columnName to set
+ */
+ public void setColumnName(String columnName)
+ {
+ this.columnName = columnName;
+ }
+
+ /**
+ * @return the columnName
+ */
+ public String getColumnName()
+ {
+ return columnName;
+ }
+
+ /**
+ * @param col1Exists
+ * the col1Exists to set
+ */
+ public void setCol1Exists(boolean col1Exists)
+ {
+ this.col1Exists = col1Exists;
+ }
+
+ /**
+ * @return the col1Exists
+ */
+ public boolean isCol1Exists()
+ {
+ return col1Exists;
+ }
+
+ /**
+ * @param col2Exists
+ * the col2Exists to set
+ */
+ public void setCol2Exists(boolean col2Exists)
+ {
+ this.col2Exists = col2Exists;
+ }
+
+ /**
+ * @return the col2Exists
+ */
+ public boolean isCol2Exists()
+ {
+ return col2Exists;
+ }
+
+ public boolean defaultsEqual()
+ {
+ if (col1default == null && col2default == null)
+ {
+ return true;
+ }
+ if ((col1default == null && col2default != null) || (col1default != null && col2default == null))
+ {
+ return false;
+ }
+ return col1default.equals(col2default);
+ }
+
+ public boolean remarksEqual()
+ {
+ if (col1remarks == null && col2remarks == null)
+ {
+ return true;
+ }
+ if ((col1remarks == null && col2remarks != null) || (col1remarks != null && col2remarks == null))
+ {
+ return false;
+ }
+ return col1remarks.equals(col2remarks);
+ }
+
+ public boolean typesEqual()
+ {
+ return col1Type == col2Type;
+ }
+
+ public boolean lengthsEqual()
+ {
+ return col1Length == col2Length;
+ }
+
+ public boolean nullableEqual()
+ {
+ return col1IsNullable == col2IsNullable;
+ }
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder result = new StringBuilder();
+ result.append("TABLE: ");
+ result.append(tableName);
+ result.append(" COLUMN: ");
+ result.append(columnName);
+ result.append("\n");
+ result.append("source colType: ");
+ result.append(col1Type);
+ result.append("\n");
+
+ result.append("dest colType: ");
+ result.append(col2Type);
+ result.append("\n");
+
+ result.append("source colLength: ");
+ result.append(col1Length);
+ result.append("\n");
+
+ result.append("dest colLength: ");
+ result.append(col2Length);
+ result.append("\n");
+
+ result.append("source IsNullable: ");
+ result.append(col1IsNullable);
+ result.append("\n");
+
+ result.append("dest IsNullable: ");
+ result.append(col2IsNullable);
+ result.append("\n");
+
+ return result.toString();
+ }
}
Modified: trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/DBDiffPlugin.java
===================================================================
--- trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/DBDiffPlugin.java 2011-02-13 16:04:52 UTC (rev 6155)
+++ trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/DBDiffPlugin.java 2011-02-13 17:01:24 UTC (rev 6156)
@@ -1,5 +1,3 @@
-package net.sourceforge.squirrel_sql.plugins.dbdiff;
-
/*
* Copyright (C) 2007 Rob Manning
* man...@us...
@@ -19,6 +17,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+package net.sourceforge.squirrel_sql.plugins.dbdiff;
+
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.SwingUtilities;
@@ -29,14 +29,21 @@
import net.sourceforge.squirrel_sql.client.plugin.PluginException;
import net.sourceforge.squirrel_sql.client.plugin.PluginResources;
import net.sourceforge.squirrel_sql.client.plugin.PluginSessionCallback;
+import net.sourceforge.squirrel_sql.client.preferences.IGlobalPreferencesPanel;
import net.sourceforge.squirrel_sql.client.session.IObjectTreeAPI;
import net.sourceforge.squirrel_sql.client.session.ISession;
import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectType;
import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
+import net.sourceforge.squirrel_sql.fw.util.Utilities;
import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
import net.sourceforge.squirrel_sql.plugins.dbdiff.actions.CompareAction;
import net.sourceforge.squirrel_sql.plugins.dbdiff.actions.SelectAction;
+import net.sourceforge.squirrel_sql.plugins.dbdiff.prefs.DBDiffPreferenceBean;
+import net.sourceforge.squirrel_sql.plugins.dbdiff.prefs.DBDiffPreferencesPanel;
+import net.sourceforge.squirrel_sql.plugins.dbdiff.prefs.DefaultPluginGlobalPreferencesTab;
+import net.sourceforge.squirrel_sql.plugins.dbdiff.prefs.DefaultPluginPreferencesManager;
+import net.sourceforge.squirrel_sql.plugins.dbdiff.prefs.IPluginPreferencesManager;
/**
* The class that sets up the various resources required by SQuirreL to implement a plugin. This plugin
@@ -54,59 +61,70 @@
private ISession diffDestSession = null;
- private IDatabaseObjectInfo[] selectedDatabaseObjects = null;
+ private IDatabaseObjectInfo[] selectedSourceDatabaseObjects = null;
private IDatabaseObjectInfo[] selectedDestDatabaseObjects = null;
+ private IPluginPreferencesManager pluginPreferencesManager = new DefaultPluginPreferencesManager();
+
+ private IScriptFileManager scriptFileManager = new ScriptFileManager();
+
public static final String BUNDLE_BASE_NAME = "net.sourceforge.squirrel_sql.plugins.dbdiff.dbdiff";
- /* (non-Javadoc)
- * @see net.sourceforge.squirrel_sql.client.plugin.ISessionPlugin#sessionStarted(net.sourceforge.squirrel_sql.client.session.ISession)
+ /**
+ * @see net.sourceforge.squirrel_sql.client.plugin.ISessionPlugin#
+ * sessionStarted(net.sourceforge.squirrel_sql.client.session.ISession)
*/
+ @Override
public PluginSessionCallback sessionStarted(final ISession session)
{
addMenuItemsToContextMenu(session);
return new DBDiffPluginSessionCallback(this);
}
- /* (non-Javadoc)
+ /**
* @see net.sourceforge.squirrel_sql.client.plugin.IPlugin#getInternalName()
*/
+ @Override
public String getInternalName()
{
return "dbdiff";
}
- /* (non-Javadoc)
+ /**
* @see net.sourceforge.squirrel_sql.client.plugin.IPlugin#getDescriptiveName()
*/
+ @Override
public String getDescriptiveName()
{
return "DBDiff Plugin";
}
- /* (non-Javadoc)
+ /**
* @see net.sourceforge.squirrel_sql.client.plugin.IPlugin#getAuthor()
*/
+ @Override
public String getAuthor()
{
return "Rob Manning";
}
- /* (non-Javadoc)
+ /**
* @see net.sourceforge.squirrel_sql.client.plugin.DefaultPlugin#getContributors()
*/
+ @Override
public String getContributors()
{
return "";
}
- /* (non-Javadoc)
+ /**
* @see net.sourceforge.squirrel_sql.client.plugin.IPlugin#getVersion()
*/
+ @Override
public String getVersion()
{
- return "0.01";
+ return "0.02";
}
/**
@@ -115,6 +133,7 @@
*
* @return the Help file name or <TT>null</TT> if plugin doesn't have a help file.
*/
+ @Override
public String getHelpFileName()
{
return "readme.html";
@@ -126,6 +145,7 @@
*
* @return the changelog file name or <TT>null</TT> if plugin doesn't have a change log.
*/
+ @Override
public String getChangeLogFileName()
{
return "changes.txt";
@@ -140,6 +160,7 @@
return "licence.txt";
}
+ @Override
public void initialize() throws PluginException
{
super.initialize();
@@ -150,33 +171,53 @@
}
_resources = new DBDiffPluginResources(DBDiffPlugin.BUNDLE_BASE_NAME, this);
+ pluginPreferencesManager.initialize(this, DBDiffPreferenceBean.class);
- IApplication app = getApplication();
- ActionCollection coll = app.getActionCollection();
- coll.add(new SelectAction(app, _resources, this));
- coll.add(new CompareAction(app, _resources, this));
+ final IApplication app = getApplication();
+ final ActionCollection coll = app.getActionCollection();
+ final SelectAction selectAction = new SelectAction(app, _resources, this);
+ selectAction.setPluginPreferencesManager(pluginPreferencesManager);
+ final CompareAction compareAction = new CompareAction(app, _resources, this);
+ compareAction.setPluginPreferencesManager(pluginPreferencesManager);
+
+ coll.add(selectAction);
+ coll.add(compareAction);
+
}
+ /**
+ * Create panel for the Global Properties dialog.
+ *
+ * @return properties panel.
+ */
+ @Override
+ public IGlobalPreferencesPanel[] getGlobalPreferencePanels()
+ {
+ final DBDiffPreferencesPanel preferencesPanel = new DBDiffPreferencesPanel(pluginPreferencesManager);
+ final DefaultPluginGlobalPreferencesTab tab = new DefaultPluginGlobalPreferencesTab(preferencesPanel);
+ return new IGlobalPreferencesPanel[] { tab };
+ }
+
+ @Override
public void unload()
{
super.unload();
- /*
diffSourceSession = null;
- setPasteMenuEnabled(false);
- PreferencesManager.unload();
- */
+ diffDestSession = null;
+ pluginPreferencesManager.unload();
+ scriptFileManager.cleanupScriptFiles();
}
/**
- * @param selectedDatabaseObjects
+ * @param selectedSourceDatabaseObjects
* The selectedDatabaseObjects to set.
*/
public void setSelectedDatabaseObjects(IDatabaseObjectInfo[] dbObjArr)
{
if (dbObjArr != null)
{
- selectedDatabaseObjects = dbObjArr;
+ selectedSourceDatabaseObjects = dbObjArr;
for (int i = 0; i < dbObjArr.length; i++)
{
if (s_log.isDebugEnabled())
@@ -216,10 +257,10 @@
{
// Uses menu.dbdiff.* in dbdiff.properties
- JMenu dbdiffMenu = _resources.createMenu("dbdiff");
+ final JMenu dbdiffMenu = _resources.createMenu("dbdiff");
- JMenuItem selectItem = new JMenuItem(coll.get(SelectAction.class));
- JMenuItem compareItem = new JMenuItem(coll.get(CompareAction.class));
+ final JMenuItem selectItem = new JMenuItem(coll.get(SelectAction.class));
+ final JMenuItem compareItem = new JMenuItem(coll.get(CompareAction.class));
dbdiffMenu.add(selectItem);
dbdiffMenu.add(compareItem);
@@ -230,34 +271,30 @@
}
- /*
- private class DBCopyPluginResources extends PluginResources {
- DBCopyPluginResources(String rsrcBundleBaseName, IPlugin plugin) {
- super(rsrcBundleBaseName, plugin);
- }
- }
- */
public void setCompareMenuEnabled(boolean enabled)
{
final ActionCollection coll = getApplication().getActionCollection();
- CompareAction compareAction = (CompareAction) coll.get(CompareAction.class);
+ final CompareAction compareAction = (CompareAction) coll.get(CompareAction.class);
compareAction.setEnabled(enabled);
}
// Interface SessionInfoProvider implementation
- /* (non-Javadoc)
- * @see net.sourceforge.squirrel_sql.plugins.dbcopy.SessionInfoProvider#getCopySourceSession()
+ /**
+ * @see net.sourceforge.squirrel_sql.plugins.dbdiff.SessionInfoProvider#getSourceSession()
*/
- public ISession getDiffSourceSession()
+ @Override
+ public ISession getSourceSession()
{
return diffSourceSession;
}
- /* (non-Javadoc)
- * @see net.sourceforge.squirrel_sql.plugins.dbcopy.SessionInfoProvider#setCopySourceSession(net.sourceforge.squirrel_sql.client.session.ISession)
+ /**
+ * @see net.sourceforge.squirrel_sql.plugins.dbdiff.SessionInfoProvider#
+ * setSourceSession(net.sourceforge.squirrel_sql.client.session.ISession)
*/
- public void setDiffSourceSession(ISession session)
+ @Override
+ public void setSourceSession(ISession session)
{
if (session != null)
{
@@ -265,40 +302,84 @@
}
}
- /* (non-Javadoc)
- * @see net.sourceforge.squirrel_sql.plugins.dbcopy.SessionInfoProvider#getSelectedDatabaseObjects()
+ /**
+ * @see net.sourceforge.squirrel_sql.plugins.dbdiff.SessionInfoProvider#getSourceSelectedDatabaseObjects()
*/
+ @Override
public IDatabaseObjectInfo[] getSourceSelectedDatabaseObjects()
{
- return selectedDatabaseObjects;
+ return selectedSourceDatabaseObjects;
}
- /* (non-Javadoc)
- * @see net.sourceforge.squirrel_sql.plugins.dbcopy.SessionInfoProvider#getCopyDestSession()
+ /**
+ * @see net.sourceforge.squirrel_sql.plugins.dbdiff.SessionInfoProvider#getDestSession()
*/
- public ISession getDiffDestSession()
+ @Override
+ public ISession getDestSession()
{
return diffDestSession;
}
- /* (non-Javadoc)
- * @see net.sourceforge.squirrel_sql.plugins.dbcopy.SessionInfoProvider#setDestCopySession(net.sourceforge.squirrel_sql.client.session.ISession)
+ /**
+ * @see net.sourceforge.squirrel_sql.plugins.dbdiff.SessionInfoProvider#
+ * setDestSession(net.sourceforge.squirrel_sql.client.session.ISession)
*/
- public void setDestDiffSession(ISession session)
+ @Override
+ public void setDestSession(ISession session)
{
diffDestSession = session;
}
- /* (non-Javadoc)
- * @see net.sourceforge.squirrel_sql.plugins.dbcopy.SessionInfoProvider#getDestSelectedDatabaseObject()
+ /**
+ * @see net.sourceforge.squirrel_sql.plugins.dbdiff.SessionInfoProvider#getDestSelectedDatabaseObjects()
*/
+ @Override
public IDatabaseObjectInfo[] getDestSelectedDatabaseObjects()
{
return selectedDestDatabaseObjects;
}
- public void setDestSelectedDatabaseObjects(IDatabaseObjectInfo[] info)
+ /**
+ * @see net.sourceforge.squirrel_sql.plugins.dbdiff.SessionInfoProvider#
+ * setDestSelectedDatabaseObjects(net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo[])
+ */
+ @Override
+ public void setDestSelectedDatabaseObjects(IDatabaseObjectInfo[] infos)
{
- selectedDestDatabaseObjects = info;
+ selectedDestDatabaseObjects = infos;
}
+
+ @Override
+ public void setSourceSelectedDatabaseObjects(IDatabaseObjectInfo[] infos)
+ {
+ this.selectedSourceDatabaseObjects = infos;
+ }
+
+ /**
+ * @param pluginPreferencesManager
+ * the pluginPreferencesManager to set
+ */
+ public void setPluginPreferencesManager(IPluginPreferencesManager pluginPreferencesManager)
+ {
+ Utilities.checkNull("setPluginPreferencesManager", pluginPreferencesManager, "pluginPreferencesManager");
+ this.pluginPreferencesManager = pluginPreferencesManager;
+ }
+
+ /**
+ * @param scriptFileManager
+ * the scriptFileManager to set
+ */
+ public void setScriptFileManager(IScriptFileManager scriptFileManager)
+ {
+ this.scriptFileManager = scriptFileManager;
+ }
+
+ /**
+ * @return the scriptFileManager
+ */
+ public IScriptFileManager getScriptFileManager()
+ {
+ return scriptFileManager;
+ }
+
}
Modified: trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/DBDiffPluginResources.java
===================================================================
--- trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/DBDiffPluginResources.java 2011-02-13 16:04:52 UTC (rev 6155)
+++ trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/DBDiffPluginResources.java 2011-02-13 17:01:24 UTC (rev 6156)
@@ -16,6 +16,7 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
package net.sourceforge.squirrel_sql.plugins.dbdiff;
import net.sourceforge.squirrel_sql.client.plugin.IPlugin;
Modified: trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/DBDiffPluginSessionCallback.java
===================================================================
--- trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/DBDiffPluginSessionCallback.java 2011-02-13 16:04:52 UTC (rev 6155)
+++ trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/DBDiffPluginSessionCallback.java 2011-02-13 17:01:24 UTC (rev 6156)
@@ -16,6 +16,7 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
package net.sourceforge.squirrel_sql.plugins.dbdiff;
import net.sourceforge.squirrel_sql.client.gui.session.ObjectTreeInternalFrame;
@@ -24,27 +25,27 @@
import net.sourceforge.squirrel_sql.client.session.ISession;
/**
- *
* @author manningr
- *
*/
-public class DBDiffPluginSessionCallback implements PluginSessionCallback {
+public class DBDiffPluginSessionCallback implements PluginSessionCallback
+{
- DBDiffPlugin _plugin = null;
-
- public DBDiffPluginSessionCallback(DBDiffPlugin plugin) {
- _plugin = plugin;
- }
-
- public void sqlInternalFrameOpened(SQLInternalFrame sqlInternalFrame,
- ISession session) {
- // Nothing to do for an SQL internal frame
+ DBDiffPlugin _plugin = null;
- }
+ public DBDiffPluginSessionCallback(DBDiffPlugin plugin)
+ {
+ _plugin = plugin;
+ }
- public void objectTreeInternalFrameOpened(ObjectTreeInternalFrame objectTreeInternalFrame,
- ISession session) {
- _plugin.addMenuItemsToContextMenu(session);
- }
+ public void sqlInternalFrameOpened(SQLInternalFrame sqlInternalFrame, ISession session)
+ {
+ // Nothing to do for an SQL internal frame
+ }
+
+ public void objectTreeInternalFrameOpened(ObjectTreeInternalFrame objectTreeInternalFrame, ISession session)
+ {
+ _plugin.addMenuItemsToContextMenu(session);
+ }
+
}
Deleted: trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/DiffExecutor.java
===================================================================
--- trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/DiffExecutor.java 2011-02-13 16:04:52 UTC (rev 6155)
+++ trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/DiffExecutor.java 2011-02-13 17:01:24 UTC (rev 6156)
@@ -1,282 +0,0 @@
-package net.sourceforge.squirrel_sql.plugins.dbdiff;
-/*
- * Copyright (C) 2007 Rob Manning
- * man...@us...
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.swing.JOptionPane;
-import javax.swing.SwingUtilities;
-
-import net.sourceforge.squirrel_sql.client.gui.mainframe.MainFrame;
-import net.sourceforge.squirrel_sql.client.session.ISession;
-import net.sourceforge.squirrel_sql.fw.dialects.DialectFactory;
-import net.sourceforge.squirrel_sql.fw.gui.GUIUtils;
-import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectType;
-import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
-import net.sourceforge.squirrel_sql.fw.sql.ISQLDatabaseMetaData;
-import net.sourceforge.squirrel_sql.fw.sql.ITableInfo;
-import net.sourceforge.squirrel_sql.fw.util.StringManager;
-import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
-import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
-import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
-import net.sourceforge.squirrel_sql.plugins.dbdiff.gui.ColumnDiffDialog;
-import net.sourceforge.squirrel_sql.plugins.dbdiff.util.DBUtil;
-
-/**
- * This is the class that performs the table copy using database connections
- * to two different database schemas.
- */
-public class DiffExecutor {
-
- /** Logger for this class. */
- private final static ILogger s_log =
- LoggerController.createLogger(DiffExecutor.class);
-
- /** Internationalized strings for this class. */
- private static final StringManager s_stringMgr =
- StringManagerFactory.getStringManager(DiffExecutor.class);
-
- static interface i18n {
- // i18n[DiffExecutor.noDiffsMessage=No differences were detected]
- String NO_DIFFS_MESSAGE =
- s_stringMgr.getString("DiffExecutor.noDiffsMessage");
- }
-
- /** the class that provides out session information */
- SessionInfoProvider prov = null;
-
- /** the source session. This comes from prov */
- ISession sourceSession = null;
-
- /** the destination session. This comes from prov */
- ISession destSession = null;
-
- /** the thread we do the work in */
- private Thread execThread = null;
-
- private List<ColumnDifference> colDifferences =
- new ArrayList<ColumnDifference>();
-
- /**
- * Constructor.
- *
- * @param p the provider of information regarding what to copy where.
- */
- public DiffExecutor(SessionInfoProvider p) {
- prov = p;
- sourceSession = prov.getDiffSourceSession();
- destSession = prov.getDiffDestSession();
- }
-
- /**
- * Starts the thread that executes the copy operation.
- */
- public void execute() {
- Runnable runnable = new Runnable() {
- public void run() {
- try {
- _execute();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- };
- execThread = new Thread(runnable);
- execThread.setName("DBDiff Executor Thread");
- execThread.start();
- }
-
- /**
- * Performs the table diff operation.
- */
- private void _execute() throws SQLException {
- boolean encounteredException = false;
- IDatabaseObjectInfo[] sourceObjs =
- prov.getSourceSelectedDatabaseObjects();
- IDatabaseObjectInfo[] destObjs =
- prov.getDestSelectedDatabaseObjects();
-
- if (!sanityCheck(sourceObjs, destObjs)) {
- return;
- }
-
- ISQLDatabaseMetaData sourceMetaData =
- prov.getDiffSourceSession().getMetaData();
- ISQLDatabaseMetaData destMetaData =
- prov.getDiffDestSession().getMetaData();
-
-
-
- Map<String, ITableInfo> tableMap1 = getTableMap(sourceMetaData, sourceObjs);
- Map<String, ITableInfo> tableMap2 = getTableMap(destMetaData, destObjs);
-
- Set<String> tableNames = getAllTableNames(tableMap1);
- tableNames.addAll(getAllTableNames(tableMap2));
-
- try {
- TableDiffExecutor diff = new TableDiffExecutor(sourceMetaData,
- destMetaData);
- for (String table : tableNames) {
- if (tableMap1.containsKey(table)) {
- if (tableMap2.containsKey(table)) {
- ITableInfo t1 = tableMap1.get(table);
- ITableInfo t2 = tableMap2.get(table);
- diff.setTableInfos(t1, t2);
- diff.execute();
- List<ColumnDifference> columnDiffs =
- diff.getColumnDifferences();
- if (columnDiffs != null && columnDiffs.size() > 0) {
- colDifferences.addAll(columnDiffs);
- for (ColumnDifference colDiff : columnDiffs) {
- System.out.println(colDiff.toString());
- }
- }
- } else {
- // table exists in source db but not dest
- }
- } else {
- // table doesn't exist in source db
- }
-
- }
- final MainFrame frame = sourceSession.getApplication().getMainFrame();
- if (colDifferences != null && colDifferences.size() > 0) {
- GUIUtils.processOnSwingEventThread(new Runnable() {
- public void run() {
- ColumnDiffDialog dialog = new ColumnDiffDialog(frame, false);
- dialog.setColumnDifferences(colDifferences);
- dialog.setSession1Label(sourceSession.getAlias().getName());
- dialog.setSession2Label(destSession.getAlias().getName());
- dialog.setVisible(true);
- }
- });
- } else {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- JOptionPane.showMessageDialog(frame,
- i18n.NO_DIFFS_MESSAGE,
- "DBDiff",
- JOptionPane.INFORMATION_MESSAGE);
- }
- });
- }
- } catch (SQLException e) {
- s_log.error("Encountered unexpected exception while executing " +
- "diff: "+e.getMessage(), e);
- }
-
- if (encounteredException) {
- return;
- }
- }
-
- private Set<String> getAllTableNames(Map<String, ITableInfo> tables) {
- HashSet<String> result = new HashSet<String>();
- result.addAll(tables.keySet());
- return result;
- }
-
- private Map<String, ITableInfo> getTableMap(ISQLDatabaseMetaData md,
- IDatabaseObjectInfo[] objs)
- throws SQLException
- {
- HashMap<String, ITableInfo> result = new HashMap<String, ITableInfo>();
- if (objs[0].getDatabaseObjectType() == DatabaseObjectType.TABLE) {
- for (int i = 0; i < objs.length; i++) {
- IDatabaseObjectInfo info = objs[i];
-
- // TODO: allow the user to specify ignore case or preserve case.
- result.put(info.getSimpleName().toUpperCase(), (ITableInfo)info);
- }
- } else {
- // Assume objs[0] is a schema/catalog
- String catalog = objs[0].getCatalogName();
- String schema = objs[0].getSchemaName();
- md.getTables(catalog, schema, null, new String[] { "TABLE" }, null);
- }
- return result;
- }
-
- /**
- * Returns a list of column differences.
- *
- * @return Returns null if no diffs exist.
- */
- public List<ColumnDifference> getColumnDifferences() {
- return colDifferences;
- }
-
- /**
- * Must have the same number of objects to compare in each set, and they
- * must be the same type of Objects (Schemas or Tables)
- *
- * @param sourceObjs
- * @param destObjs
- * @return
- */
- private boolean sanityCheck(IDatabaseObjectInfo[] sourceObjs,
- IDatabaseObjectInfo[] destObjs)
- {
- boolean result = true;
- if (sourceObjs.length != destObjs.length) {
- result = false;
- }
- if (sourceObjs[0].getDatabaseObjectType()
- != destObjs[0].getDatabaseObjectType())
- {
- result = false;
- }
- return result;
- }
-
- private int[] getTableCounts() {
- int[] result = null;
-
- ISession sourceSession = prov.getDiffSourceSession();
- IDatabaseObjectInfo[] dbObjs = prov.getSourceSelectedDatabaseObjects();
- if (dbObjs != null) {
- result = new int[dbObjs.length];
- for (int i = 0; i < dbObjs.length; i++) {
- if (false == dbObjs[i] instanceof ITableInfo) {
- continue;
- }
- try {
- ITableInfo ti = (ITableInfo) dbObjs[i];
- result[i] =
- DBUtil.getTableCount(sourceSession,
- ti.getCatalogName(),
- ti.getSchemaName(),
- ti.getSimpleName(),
- DialectFactory.SOURCE_TYPE);
- } catch (Exception e) {
- s_log.error(
- "Unexpected exception while attempting to get table counts",e);
- result[i] = 0;
- }
- }
- }
- return result;
- }
-
-}
Added: trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/IScriptFileManager.java
===================================================================
--- trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/IScriptFileManager.java (rev 0)
+++ trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/IScriptFileManager.java 2011-02-13 17:01:24 UTC (rev 6156)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2011 Rob Manning
+ * man...@us...
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package net.sourceforge.squirrel_sql.plugins.dbdiff;
+
+import java.io.IOException;
+
+import net.sourceforge.squirrel_sql.client.session.ISession;
+
+/**
+ * Interface for manager of script files. Ihis allows the plugin to cleanup any temporary script files that
+ * were created for comparison purposes.
+ */
+public interface IScriptFileManager
+{
+
+ /**
+ * Creates a filename (for a temporary file) based on the specified session information. This should have
+ * the side effect of storing the filename off for cleanup later.
+ *
+ * @param session
+ * the session in which objects have been selected to have their definitions compared
+ * @param number
+ * which of the two sessions (generally, 1 or 2) is one being passed.
+ * @return a temporary filename
+ * @throws IOException
+ */
+ String getOutputFilenameForSession(ISession session, int number) throws IOException;
+
+ /**
+ * Remove the previously created filenames if they exist.
+ */
+ void cleanupScriptFiles();
+
+}
\ No newline at end of file
Added: trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/ScriptFileManager.java
===================================================================
--- trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/ScriptFileManager.java (rev 0)
+++ trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/ScriptFileManager.java 2011-02-13 17:01:24 UTC (rev 6156)
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2011 Rob Manning
+ * man...@us...
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package net.sourceforge.squirrel_sql.plugins.dbdiff;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashSet;
+
+import net.sourceforge.squirrel_sql.client.session.ISession;
+import net.sourceforge.squirrel_sql.fw.util.FileWrapper;
+import net.sourceforge.squirrel_sql.fw.util.FileWrapperFactory;
+import net.sourceforge.squirrel_sql.fw.util.FileWrapperFactoryImpl;
+import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
+import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
+
+/**
+ *
+ */
+public class ScriptFileManager implements IScriptFileManager
+{
+
+ /** Logger for this class. */
+ private final static ILogger s_log = LoggerController.createLogger(ScriptFileManager.class);
+
+ private final HashSet<String> scriptFiles = new HashSet<String>();
+
+ private FileWrapperFactory fileWrapperFactory = new FileWrapperFactoryImpl();
+
+ /**
+ * @see net.sourceforge.squirrel_sql.plugins.dbdiff.IScriptFileManager#
+ * getOutputFilenameForSession(net.sourceforge.squirrel_sql.client.session.ISession, int)
+ */
+ public String getOutputFilenameForSession(ISession session, int number) throws IOException
+ {
+ final String sessionUserName = session.getAlias().getUserName();
+ final File tempSessionFile =
+ File.createTempFile(sessionUserName + "-" + number + "-session-for-diff-", ".sql");
+ scriptFiles.add(tempSessionFile.getAbsolutePath());
+ if (s_log.isDebugEnabled())
+ {
+ s_log.debug("Created temporary script filename for session: " + tempSessionFile.getAbsolutePath());
+ }
+
+ return tempSessionFile.getAbsolutePath();
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.plugins.dbdiff.IScriptFileManager#cleanupScriptFiles()
+ */
+ public void cleanupScriptFiles()
+ {
+ for (final String scriptFile : scriptFiles)
+ {
+ final FileWrapper fileWrapper = fileWrapperFactory.create(scriptFile);
+ if (fileWrapper.exists())
+ {
+ if (s_log.isDebugEnabled())
+ {
+ s_log.debug("Attempting to delete previously created temporary script file: " + scriptFile);
+ }
+ fileWrapper.delete();
+ }
+ else
+ {
+ if (s_log.isDebugEnabled())
+ {
+ s_log.debug("Previously created temporary script file did not exist: " + scriptFile);
+ }
+
+ }
+ }
+ }
+
+ /**
+ * @param fileWrapperFactory
+ * the fileWrapperFactory to set
+ */
+ public void setFileWrapperFactory(FileWrapperFactory fileWrapperFactory)
+ {
+ this.fileWrapperFactory = fileWrapperFactory;
+ }
+
+}
Modified: trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/SessionInfoProvider.java
===================================================================
--- trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/SessionInfoProvider.java 2011-02-13 16:04:52 UTC (rev 6155)
+++ trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/SessionInfoProvider.java 2011-02-13 17:01:24 UTC (rev 6156)
@@ -2,19 +2,19 @@
* Copyright (C) 2007 Rob Manning
* man...@us...
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or any later version.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package net.sourceforge.squirrel_sql.plugins.dbdiff;
@@ -22,22 +22,29 @@
import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
/**
- * This is implemented in order to pass needed info along to diff executor.
- *
+ * This is implemented in order to pass needed info along to diff executor.
*/
-public interface SessionInfoProvider {
-
- public void setDiffSourceSession(ISession session);
-
- public ISession getDiffSourceSession();
-
- public IDatabaseObjectInfo[] getSourceSelectedDatabaseObjects();
-
- public IDatabaseObjectInfo[] getDestSelectedDatabaseObjects();
-
- public void setDestSelectedDatabaseObjects(IDatabaseObjectInfo[] infos);
-
- public void setDestDiffSession(ISession session);
-
- public ISession getDiffDestSession();
+public interface SessionInfoProvider
+{
+
+ public void setSourceSession(ISession session);
+
+ public ISession getSourceSession();
+
+ public IDatabaseObjectInfo[] getSourceSelectedDatabaseObjects();
+
+ public IDatabaseObjectInfo[] getDestSelectedDatabaseObjects();
+
+ public void setDestSelectedDatabaseObjects(IDatabaseObjectInfo[] infos);
+
+ public void setSourceSelectedDatabaseObjects(IDatabaseObjectInfo[] infos);
+
+ public void setDestSession(ISession session);
+
+ public ISession getDestSession();
+
+ /**
+ * @return the scriptFileManager
+ */
+ public IScriptFileManager getScriptFileManager();
}
Modified: trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/TableDiffExecutor.java
===================================================================
--- trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/TableDiffExecutor.java 2011-02-13 16:04:52 UTC (rev 6155)
+++ trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/TableDiffExecutor.java 2011-02-13 17:01:24 UTC (rev 6156)
@@ -1,3 +1,22 @@
+/*
+ * Copyright (C) 2007 Rob Manning
+ * man...@us...
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
package net.sourceforge.squirrel_sql.plugins.dbdiff;
import java.sql.SQLException;
@@ -2,3 +21,2 @@
import java.util.ArrayList;
-import java.util.Comparator;
import java.util.HashMap;
@@ -13,113 +31,117 @@
import net.sourceforge.squirrel_sql.fw.sql.ITableInfo;
import net.sourceforge.squirrel_sql.fw.sql.TableColumnInfo;
-public class TableDiffExecutor {
-
- private ISQLDatabaseMetaData _md1;
- private ISQLDatabaseMetaData _md2;
-
- private ITableInfo _t1;
- private ITableInfo _t2;
-
- private List<ColumnDifference> colDifferences = null;
-
- public TableDiffExecutor(ISQLDatabaseMetaData md1,
- ISQLDatabaseMetaData md2)
- {
- _md1 = md1;
- _md2 = md2;
- }
-
- public void setTableInfos(ITableInfo t1, ITableInfo t2) {
- _t1 = t1;
- _t2 = t2;
- if (colDifferences != null) {
- colDifferences.clear();
- }
- }
-
- public void execute() throws SQLException {
- colDifferences = new ArrayList<ColumnDifference>();
- TableColumnInfo[] t1cols = _md1.getColumnInfo(_t1);
- TableColumnInfo[] t2cols = _md2.getColumnInfo(_t2);
- Set<String> columnNames = getAllColumnNames(t1cols, t2cols);
- Set<String> t1ColumnNames = getAllColumnNames(t1cols);
- Map<String, TableColumnInfo> t1ColMap = getColumnMap(t1cols);
- Set<String> t2ColumnNames = getAllColumnNames(t2cols);
- Map<String, TableColumnInfo> t2ColMap = getColumnMap(t2cols);
-
- for (String columnName : columnNames) {
- ColumnDifference diff = new ColumnDifference();
- if (t1ColumnNames.contains(columnName)) {
- TableColumnInfo c1 = t1ColMap.get(columnName);
-
- if (t2ColumnNames.contains(columnName)) { // Column is in both table 1 and 2
- TableColumnInfo c2 = t2ColMap.get(columnName);
- diff.setColumns(c1, c2);
- } else {
- // Column is in table 1, but not table 2
- diff.setCol2Exists(false);
- diff.setColumn1(c...
[truncated message content] |