Revision: 5632
http://squirrel-sql.svn.sourceforge.net/squirrel-sql/?rev=5632&view=rev
Author: manningr
Date: 2010-05-30 18:02:31 +0000 (Sun, 30 May 2010)
Log Message:
-----------
Added support for displaying Netezza external tables in the object tree.
Modified Paths:
--------------
trunk/sql12/plugins/netezza/src/net/sourceforge/squirrel_sql/plugins/netezza/NetezzaPlugin.java
Added Paths:
-----------
trunk/sql12/plugins/netezza/src/net/sourceforge/squirrel_sql/plugins/netezza/exp/NetezzaExtTableInodeExpanderFactory.java
trunk/sql12/plugins/netezza/src/net/sourceforge/squirrel_sql/plugins/netezza/exp/NetezzaExtTableParentExpander.java
Modified: trunk/sql12/plugins/netezza/src/net/sourceforge/squirrel_sql/plugins/netezza/NetezzaPlugin.java
===================================================================
--- trunk/sql12/plugins/netezza/src/net/sourceforge/squirrel_sql/plugins/netezza/NetezzaPlugin.java 2010-05-30 17:26:23 UTC (rev 5631)
+++ trunk/sql12/plugins/netezza/src/net/sourceforge/squirrel_sql/plugins/netezza/NetezzaPlugin.java 2010-05-30 18:02:31 UTC (rev 5632)
@@ -35,6 +35,7 @@
import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectType;
import net.sourceforge.squirrel_sql.fw.util.StringManager;
import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
+import net.sourceforge.squirrel_sql.plugins.netezza.exp.NetezzaExtTableInodeExpanderFactory;
import net.sourceforge.squirrel_sql.plugins.netezza.exp.NetezzaSequenceInodeExpanderFactory;
import net.sourceforge.squirrel_sql.plugins.netezza.exp.NetezzaSynonymInodeExpanderFactory;
import net.sourceforge.squirrel_sql.plugins.netezza.prefs.NetezzaPreferenceBean;
@@ -204,15 +205,21 @@
String stmtSep = _prefsManager.getPreferences().getStatementSeparator();
// ////// Object Tree Expanders ////////
-
+
// Schema Expander - sequences
objTree.addExpander(DatabaseObjectType.SCHEMA,
- new SchemaExpander(new NetezzaSequenceInodeExpanderFactory(), DatabaseObjectType.SEQUENCE));
+ new SchemaExpander(new NetezzaSequenceInodeExpanderFactory(),
+ DatabaseObjectType.SEQUENCE_TYPE_DBO));
// Schema Expander - synonyms
objTree.addExpander(DatabaseObjectType.SCHEMA,
- new SchemaExpander(new NetezzaSynonymInodeExpanderFactory(), DatabaseObjectType.SYNONYM));
+ new SchemaExpander(new NetezzaSynonymInodeExpanderFactory(),
+ DatabaseObjectType.SYNONYM_TYPE_DBO));
+ // Schema Expander - external tables
+ objTree.addExpander(DatabaseObjectType.SCHEMA,
+ new SchemaExpander(new NetezzaExtTableInodeExpanderFactory(),
+ DatabaseObjectType.TABLE_TYPE_DBO));
// ////// Object Tree Detail Tabs ////////
objTree.addDetailTab(DatabaseObjectType.PROCEDURE, new ProcedureSourceTab(stmtSep));
Added: trunk/sql12/plugins/netezza/src/net/sourceforge/squirrel_sql/plugins/netezza/exp/NetezzaExtTableInodeExpanderFactory.java
===================================================================
--- trunk/sql12/plugins/netezza/src/net/sourceforge/squirrel_sql/plugins/netezza/exp/NetezzaExtTableInodeExpanderFactory.java (rev 0)
+++ trunk/sql12/plugins/netezza/src/net/sourceforge/squirrel_sql/plugins/netezza/exp/NetezzaExtTableInodeExpanderFactory.java 2010-05-30 18:02:31 UTC (rev 5632)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010 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.netezza.exp;
+
+import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.INodeExpander;
+import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.INodeExpanderFactory;
+import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectType;
+
+/**
+ * Implementation of INodeExpanderFactory for Netezza external tables
+ *
+ */
+public class NetezzaExtTableInodeExpanderFactory implements INodeExpanderFactory
+{
+
+ /**
+ * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.INodeExpanderFactory#createExpander(net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectType)
+ */
+ public INodeExpander createExpander(DatabaseObjectType type)
+ {
+ return new NetezzaExtTableParentExpander();
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.INodeExpanderFactory#getParentLabelForType(net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectType)
+ */
+ public String getParentLabelForType(DatabaseObjectType type)
+ {
+ return "EXTERNAL TABLE";
+ }
+
+}
Added: trunk/sql12/plugins/netezza/src/net/sourceforge/squirrel_sql/plugins/netezza/exp/NetezzaExtTableParentExpander.java
===================================================================
--- trunk/sql12/plugins/netezza/src/net/sourceforge/squirrel_sql/plugins/netezza/exp/NetezzaExtTableParentExpander.java (rev 0)
+++ trunk/sql12/plugins/netezza/src/net/sourceforge/squirrel_sql/plugins/netezza/exp/NetezzaExtTableParentExpander.java 2010-05-30 18:02:31 UTC (rev 5632)
@@ -0,0 +1,70 @@
+package net.sourceforge.squirrel_sql.plugins.netezza.exp;
+
+/*
+ * Copyright (C) 2010 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.List;
+
+import net.sourceforge.squirrel_sql.client.session.ISession;
+import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.INodeExpander;
+import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.ObjectTreeNode;
+
+/**
+ * This class handles the expanding of the "External Table" node. It will give a list of all the External
+ * Tables available in the schema.
+ */
+public class NetezzaExtTableParentExpander implements INodeExpander
+{
+ /**
+ * Default ctor.
+ */
+ public NetezzaExtTableParentExpander() {
+ super();
+ }
+
+ /**
+ * Though this implementation looks incomplete, it is nonetheless correct. Since the Netezza
+ * driver knows about "EXTERNAL TABLE" table types, it returns them from DatabaseMetaData.getTables.
+ * So it is enough to merely plugin an expander that supports this type and when SQuirreL attempts to
+ * populate the "EXTERNAL TABLE" tree node, the tables are provided by the driver. There was a real
+ * implementation here before that executed the following SQL:
+ *
+ * SELECT * FROM _v_objs_owned
+ * where class = 'EXTERNAL TABLE'
+ * and owner = ?
+ * and database = ?
+ *
+ * However, for reasons mentioned above, this resulted in duplicate entries in the object tree under the
+ * "EXTERNAL TABLE" node.
+ *
+ * @param session
+ * Current session.
+ * @param parentNode
+ * Node to be expanded.
+ *
+ * @return an empty list of ObjectTreeNode type
+ */
+ public List<ObjectTreeNode> createChildren(ISession session, ObjectTreeNode parentNode)
+ throws SQLException
+ {
+ final List<ObjectTreeNode> childNodes = new ArrayList<ObjectTreeNode>();
+ return childNodes;
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|