Revision: 6319
http://squirrel-sql.svn.sourceforge.net/squirrel-sql/?rev=6319&view=rev
Author: manningr
Date: 2011-07-27 22:23:52 +0000 (Wed, 27 Jul 2011)
Log Message:
-----------
License header and TODO cleanup.
Modified Paths:
--------------
trunk/sql12/plugins/dbcopy/src/main/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/ApplicationStub.java
trunk/sql12/plugins/dbcopy/src/main/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/CLCopyListener.java
trunk/sql12/plugins/dbcopy/src/main/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/CLCopyUICallback.java
trunk/sql12/plugins/dbcopy/src/main/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/CommandLineArgumentProcessor.java
trunk/sql12/plugins/dbcopy/src/main/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/DBCopyCLI.java
trunk/sql12/plugins/dbcopy/src/main/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/SessionInfoProviderImpl.java
Modified: trunk/sql12/plugins/dbcopy/src/main/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/ApplicationStub.java
===================================================================
--- trunk/sql12/plugins/dbcopy/src/main/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/ApplicationStub.java 2011-07-27 22:21:46 UTC (rev 6318)
+++ trunk/sql12/plugins/dbcopy/src/main/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/ApplicationStub.java 2011-07-27 22:23:52 UTC (rev 6319)
@@ -1,3 +1,22 @@
+/*
+ * 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.dbcopy.cli;
import javax.swing.Action;
@@ -248,7 +267,6 @@
@Override
public boolean shutdown(boolean updateLaunchScript)
{
-
return false;
}
Modified: trunk/sql12/plugins/dbcopy/src/main/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/CLCopyListener.java
===================================================================
--- trunk/sql12/plugins/dbcopy/src/main/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/CLCopyListener.java 2011-07-27 22:21:46 UTC (rev 6318)
+++ trunk/sql12/plugins/dbcopy/src/main/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/CLCopyListener.java 2011-07-27 22:23:52 UTC (rev 6319)
@@ -1,3 +1,22 @@
+/*
+ * 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.dbcopy.cli;
import net.sourceforge.squirrel_sql.plugins.dbcopy.event.AnalysisEvent;
@@ -12,16 +31,15 @@
{
private boolean copyFinished = false;
-
- public boolean isCopyFinished() {
+
+ public boolean isCopyFinished()
+ {
return copyFinished;
}
-
+
@Override
public void analyzingTable(TableEvent e)
{
- // TODO Auto-generated method stub
-
}
@Override
@@ -33,14 +51,12 @@
@Override
public void copyStarted(CopyEvent e)
{
- // TODO Auto-generated method stub
-
}
@Override
public void handleError(ErrorEvent e)
{
- System.err.println("Encountered the following exception: "+e.getException().getMessage());
+ System.err.println("Encountered the following exception: " + e.getException().getMessage());
e.getException().printStackTrace();
copyFinished = true;
}
@@ -48,36 +64,26 @@
@Override
public void recordCopied(RecordEvent e)
{
- // TODO Auto-generated method stub
-
}
@Override
public void statementExecuted(StatementEvent e)
{
- // TODO Auto-generated method stub
-
}
@Override
public void tableAnalysisStarted(AnalysisEvent e)
{
- // TODO Auto-generated method stub
-
}
@Override
public void tableCopyFinished(TableEvent e)
{
- // TODO Auto-generated method stub
-
}
@Override
public void tableCopyStarted(TableEvent e)
{
- // TODO Auto-generated method stub
-
}
}
Modified: trunk/sql12/plugins/dbcopy/src/main/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/CLCopyUICallback.java
===================================================================
--- trunk/sql12/plugins/dbcopy/src/main/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/CLCopyUICallback.java 2011-07-27 22:21:46 UTC (rev 6318)
+++ trunk/sql12/plugins/dbcopy/src/main/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/CLCopyUICallback.java 2011-07-27 22:23:52 UTC (rev 6319)
@@ -1,3 +1,22 @@
+/*
+ * 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.dbcopy.cli;
import net.sourceforge.squirrel_sql.fw.dialects.UserCancelledOperationException;
Modified: trunk/sql12/plugins/dbcopy/src/main/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/CommandLineArgumentProcessor.java
===================================================================
--- trunk/sql12/plugins/dbcopy/src/main/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/CommandLineArgumentProcessor.java 2011-07-27 22:21:46 UTC (rev 6318)
+++ trunk/sql12/plugins/dbcopy/src/main/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/CommandLineArgumentProcessor.java 2011-07-27 22:23:52 UTC (rev 6319)
@@ -1,3 +1,22 @@
+/*
+ * 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.dbcopy.cli;
import java.util.ArrayList;
@@ -37,8 +56,6 @@
private Options options = new Options();
private CommandLine cmd = null;
-
- private boolean valid = true;
public CommandLineArgumentProcessor(String[] args) throws ParseException
{
@@ -46,11 +63,11 @@
CommandLineParser parser = new GnuParser();
try {
cmd = parser.parse(options, args);
- } catch (Exception e) {
+ } catch (ParseException e) {
HelpFormatter formatter = new HelpFormatter();
- System.out.println(e.getMessage());
+ System.err.println(e.getMessage());
formatter.printHelp("DBCopyCLI", options, true);
- valid = false;
+ throw e;
}
}
@@ -114,41 +131,6 @@
}
- public boolean isValid() {
- return valid;
- }
-
- public void validate()
- {
- try
- {
- if (!cmd.hasOption(SOURCE_SESSION))
- {
- throw new ParseException("Missing " + SOURCE_SESSION);
- }
- if (!cmd.hasOption(DEST_SESSION))
- {
- throw new ParseException("Missing " + DEST_SESSION);
- }
- if (!cmd.hasOption(TABLE_LIST) && !cmd.hasOption(TABLE_PATTERN))
- {
- throw new ParseException("Must specify either " + TABLE_LIST + " or " + TABLE_PATTERN);
- }
- if (!cmd.hasOption(DEST_SCHEMA))
- {
- throw new ParseException("Missing " + DEST_SCHEMA);
- }
- }
- catch (ParseException e)
- {
- HelpFormatter formatter = new HelpFormatter();
- System.out.println(e.getMessage());
- formatter.printHelp("DBCopyCLI", options, true);
- System.exit(1);
-
- }
- }
-
public String getSourceAliasName() {
return cmd.getOptionValue(SOURCE_SESSION);
}
Modified: trunk/sql12/plugins/dbcopy/src/main/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/DBCopyCLI.java
===================================================================
--- trunk/sql12/plugins/dbcopy/src/main/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/DBCopyCLI.java 2011-07-27 22:21:46 UTC (rev 6318)
+++ trunk/sql12/plugins/dbcopy/src/main/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/DBCopyCLI.java 2011-07-27 22:23:52 UTC (rev 6319)
@@ -1,3 +1,22 @@
+/*
+ * 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.dbcopy.cli;
import java.sql.SQLException;
@@ -4,10 +23,6 @@
import java.util.ArrayList;
import java.util.Iterator;
-import org.apache.commons.cli.HelpFormatter;
-import org.apache.commons.cli.ParseException;
-import org.apache.commons.lang.StringUtils;
-
import net.sourceforge.squirrel_sql.client.IApplication;
import net.sourceforge.squirrel_sql.client.gui.db.DataCache;
import net.sourceforge.squirrel_sql.client.gui.db.SQLAlias;
@@ -24,16 +39,14 @@
import net.sourceforge.squirrel_sql.fw.sql.ITableInfo;
import net.sourceforge.squirrel_sql.fw.sql.SQLConnection;
import net.sourceforge.squirrel_sql.fw.sql.SQLDriverManager;
-import net.sourceforge.squirrel_sql.fw.sql.TableInfo;
-import net.sourceforge.squirrel_sql.fw.util.StringUtilities;
-import net.sourceforge.squirrel_sql.fw.util.Utilities;
import net.sourceforge.squirrel_sql.plugins.dbcopy.CopyExecutor;
import net.sourceforge.squirrel_sql.plugins.dbcopy.DBCopyPlugin;
import net.sourceforge.squirrel_sql.plugins.dbcopy.SessionInfoProvider;
-import net.sourceforge.squirrel_sql.plugins.dbcopy.event.CopyTableListener;
import net.sourceforge.squirrel_sql.plugins.dbcopy.prefs.PreferencesManager;
import net.sourceforge.squirrel_sql.plugins.dbcopy.util.DBUtil;
+import org.apache.commons.lang.StringUtils;
+
/*
* Copyright (C) 2011 Rob Manning
* man...@us...
@@ -66,16 +79,16 @@
private static DataCache dataCache = null;
- private static ISession sourceSession = null;
-
- // private static ISession destSession = null;
-
private static SessionInfoProvider sessionInfoProvider = new SessionInfoProviderImpl();
private static ArrayList<ITableInfo> tables = new ArrayList<ITableInfo>();
private static CLCopyListener listener = new CLCopyListener();
+ private static ISession sourceSession = null;
+
+ private static ISession destSession = null;
+
/**
* @param args
*/
@@ -93,10 +106,11 @@
applicationFiles.getDatabaseAliasesFile(), squirrelResources.getDefaultDriversUrl(),
applicationStub);
- ISession destSession = getSessionForAlias(argProcessor.getDestAliasName());
+ setDestSession(getSessionForAlias(argProcessor.getDestAliasName()));
+ setSourceSession(getSessionForAlias(argProcessor.getSourceAliasName()));
- sessionInfoProvider.setSourceSession(getSessionForAlias(argProcessor.getSourceAliasName()));
- sessionInfoProvider.setDestSession(destSession);
+ sessionInfoProvider.setSourceSession(getSourceSession());
+ sessionInfoProvider.setDestSession(getDestSession());
for (String tableStr : argProcessor.getTableList())
{
tables.add(getTableInfo(sessionInfoProvider.getSourceSession(), sourceSchemaName, sourceCatalogName,
@@ -107,7 +121,7 @@
DatabaseObjectInfo destObject =
new DatabaseObjectInfo(destCatalogName, destSchemaName, simpleName, DatabaseObjectType.SCHEMA,
- destSession.getMetaData());
+ getDestSession().getMetaData());
sessionInfoProvider.setDestDatabaseObject(destObject);
PreferencesManager.initialize(new DBCopyPlugin());
@@ -118,8 +132,9 @@
executor.addListener(listener);
executor.setPref(new CLCopyUICallback());
executor.execute();
-
- while (!listener.isCopyFinished()) {
+
+ while (!listener.isCopyFinished())
+ {
System.out.print(".");
Thread.sleep(2000);
}
@@ -131,6 +146,12 @@
{
ISQLDatabaseMetaData md = session.getMetaData();
ITableInfo[] result = md.getTables(catalogName, schemaName, tableName, new String[] { "TABLE" }, null);
+ if (result.length == 0)
+ {
+ throw new IllegalStateException("Source table to be copied (" + tableName
+ + ") could not be located in schema (" + schemaName + ") and/or catalog (" + catalogName +
+ ") for alias: " + session.getAlias().getName());
+ }
return result[0];
}
@@ -165,4 +186,24 @@
}
throw new RuntimeException("Alias (" + alias + ") was not found");
}
+
+ public static void setSourceSession(ISession sourceSession)
+ {
+ DBCopyCLI.sourceSession = sourceSession;
+ }
+
+ public static ISession getSourceSession()
+ {
+ return sourceSession;
+ }
+
+ public static void setDestSession(ISession destSession)
+ {
+ DBCopyCLI.destSession = destSession;
+ }
+
+ public static ISession getDestSession()
+ {
+ return destSession;
+ }
}
Modified: trunk/sql12/plugins/dbcopy/src/main/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/SessionInfoProviderImpl.java
===================================================================
--- trunk/sql12/plugins/dbcopy/src/main/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/SessionInfoProviderImpl.java 2011-07-27 22:21:46 UTC (rev 6318)
+++ trunk/sql12/plugins/dbcopy/src/main/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/SessionInfoProviderImpl.java 2011-07-27 22:23:52 UTC (rev 6319)
@@ -1,3 +1,22 @@
+/*
+ * 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.dbcopy.cli;
import java.util.List;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|