Update of /cvsroot/squirrel-sql/sql12/plugins/db2/src/net/sourceforge/squirrel_sql/plugins/db2/tab
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv28994/plugins/db2/src/net/sourceforge/squirrel_sql/plugins/db2/tab
Modified Files:
ProcedureSourceTab.java ViewSourceTab.java
TriggerSourceTab.java UDFSourceTab.java TableSourceTab.java
Log Message:
refactoring to remove duplicate plugin code.
Index: UDFSourceTab.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/plugins/db2/src/net/sourceforge/squirrel_sql/plugins/db2/tab/UDFSourceTab.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** UDFSourceTab.java 18 Aug 2007 13:49:17 -0000 1.2
--- UDFSourceTab.java 12 Dec 2009 18:06:05 -0000 1.3
***************
*** 18,35 ****
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
- import java.sql.PreparedStatement;
- import java.sql.SQLException;
-
- import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
- import net.sourceforge.squirrel_sql.fw.sql.ISQLConnection;
- import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
- import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
-
- import net.sourceforge.squirrel_sql.client.session.ISession;
import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.FormattedSourceTab;
/**
! * This class will display the source for an DB2 User-Defined function.
! *
! * @author manningr
*/
public class UDFSourceTab extends FormattedSourceTab
--- 18,25 ----
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.FormattedSourceTab;
/**
! * This class provides the necessary information to the parent tab to display the source for an DB2
! * User-Defined function.
*/
public class UDFSourceTab extends FormattedSourceTab
***************
*** 60,108 ****
"and routine_name = ? ";
! /** Logger for this class. */
! private final static ILogger s_log =
! LoggerController.createLogger(UDFSourceTab.class);
! /** whether or not we are connected to OS/400 */
! private boolean isOS400 = false;
!
! /**
! * Constructor
! *
! * @param hint
! * @param stmtSep
! * @param isOS400 whether or not we are connected to OS/400
! */
! public UDFSourceTab(String hint, String stmtSep, boolean isOS400)
! {
super(hint);
! super.setCompressWhitespace(true);
! super.setupFormatter(stmtSep, null);
! this.isOS400 = isOS400;
}
! /**
! * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.BaseSourceTab#createStatement()
! */
! @Override
! protected PreparedStatement createStatement() throws SQLException
! {
! final ISession session = getSession();
! final IDatabaseObjectInfo doi = getDatabaseObjectInfo();
!
! String sql = SQL;
! if (isOS400) {
! sql = OS_400_SQL;
! }
! if (s_log.isDebugEnabled()) {
! s_log.debug("Running SQL: "+sql);
! s_log.debug("schema="+doi.getSchemaName());
! s_log.debug("udf name="+doi.getSimpleName());
! }
! ISQLConnection conn = session.getSQLConnection();
! PreparedStatement pstmt = conn.prepareStatement(sql);
! pstmt.setString(1, doi.getSchemaName());
! pstmt.setString(2, doi.getSimpleName());
! return pstmt;
! }
}
--- 50,84 ----
"and routine_name = ? ";
! /** whether or not we are connected to OS/400 */
! private boolean isOS400 = false;
! /**
! * Constructor
! *
! * @param hint
! * what the user sees on mouse-over tool-tip
! * @param stmtSep
! * the string to use to separate SQL statements
! * @param isOS400
! * whether or not we are connected to OS/400
! */
! public UDFSourceTab(String hint, String stmtSep, boolean isOS400) {
super(hint);
! super.setCompressWhitespace(true);
! super.setupFormatter(stmtSep, null);
! this.isOS400 = isOS400;
}
! /**
! * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.table.PSFormattedSourceTab#getSqlStatement()
! */
! @Override
! protected String getSqlStatement()
! {
! String sql = SQL;
! if (isOS400) {
! sql = OS_400_SQL;
! }
! return sql;
! }
}
Index: TriggerSourceTab.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/plugins/db2/src/net/sourceforge/squirrel_sql/plugins/db2/tab/TriggerSourceTab.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** TriggerSourceTab.java 1 Sep 2007 16:04:33 -0000 1.6
--- TriggerSourceTab.java 12 Dec 2009 18:06:05 -0000 1.7
***************
*** 18,35 ****
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
- import java.sql.PreparedStatement;
- import java.sql.SQLException;
-
- import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
- import net.sourceforge.squirrel_sql.fw.sql.ISQLConnection;
- import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
- import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
-
- import net.sourceforge.squirrel_sql.client.session.ISession;
import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.FormattedSourceTab;
/**
! * This class will display the source for an DB2 trigger.
! *
! * @author manningr
*/
public class TriggerSourceTab extends FormattedSourceTab
--- 18,24 ----
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.FormattedSourceTab;
/**
! * This class provides the necessary information to the parent tab to display the source for an DB2 trigger.
*/
public class TriggerSourceTab extends FormattedSourceTab
***************
*** 40,46 ****
"where TABSCHEMA = ? " +
"and TRIGNAME = ? ";
!
/** SQL that retrieves the source of a trigger on DB2 on OS/400. */
! private final static String OS2_400_SQL =
"select action_statement " +
"from qsys2.systriggers " +
--- 29,35 ----
"where TABSCHEMA = ? " +
"and TRIGNAME = ? ";
!
/** SQL that retrieves the source of a trigger on DB2 on OS/400. */
! private final static String OS2_400_SQL =
"select action_statement " +
"from qsys2.systriggers " +
***************
*** 48,57 ****
"and trigger_name = ? ";
! /** Logger for this class. */
! private final static ILogger s_log =
! LoggerController.createLogger(TriggerSourceTab.class);
!
private boolean isOS2400 = false;
public TriggerSourceTab(String hint, boolean isOS2400, String stmtSep)
{
--- 37,53 ----
"and trigger_name = ? ";
! /** a boolean value indicating whether or not this DB2 is on OS/400 */
private boolean isOS2400 = false;
+ /**
+ * Constructor
+ *
+ * @param hint
+ * what the user sees on mouse-over tool-tip
+ * @param isOS2400
+ * a boolean value indicating whether or not this DB2 is on OS/400.
+ * @param stmtSep
+ * the character that separates SQL statements
+ */
public TriggerSourceTab(String hint, boolean isOS2400, String stmtSep)
{
***************
*** 62,89 ****
}
! /**
! * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.BaseSourceTab#createStatement()
! */
! @Override
! protected PreparedStatement createStatement() throws SQLException
! {
! final ISession session = getSession();
! final IDatabaseObjectInfo doi = getDatabaseObjectInfo();
!
String sql = SQL;
if (isOS2400) {
sql = OS2_400_SQL;
}
!
! if (s_log.isDebugEnabled()) {
! s_log.debug("Running SQL: "+sql);
! s_log.debug("schema="+doi.getSchemaName());
! s_log.debug("trigname="+doi.getSimpleName());
! }
! ISQLConnection conn = session.getSQLConnection();
! PreparedStatement pstmt = conn.prepareStatement(sql);
! pstmt.setString(1, doi.getSchemaName());
! pstmt.setString(2, doi.getSimpleName());
! return pstmt;
! }
}
--- 58,72 ----
}
! /**
! * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.table.PSFormattedSourceTab#getSqlStatement()
! */
! @Override
! protected String getSqlStatement()
! {
String sql = SQL;
if (isOS2400) {
sql = OS2_400_SQL;
}
! return sql;
! }
}
Index: TableSourceTab.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/plugins/db2/src/net/sourceforge/squirrel_sql/plugins/db2/tab/TableSourceTab.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** TableSourceTab.java 28 Nov 2008 23:00:44 -0000 1.4
--- TableSourceTab.java 12 Dec 2009 18:06:05 -0000 1.5
***************
*** 46,55 ****
{
/** SQL that retrieves the source of a MQT. */
! private static final String MQT_SQL = "SELECT text " + "FROM SYSCAT.VIEWS " + "WHERE viewschema = ? "
! + "and viewname = ? ";
/** SQL that retrieves the source of a MQT on OS/400 */
! private static final String OS400_MQT_SQL = "select mqt_definition " + "from qsys2.systables "
! + "where table_schema = ? " + "and table_name = ? ";
/** Logger for this class. */
--- 46,61 ----
{
/** SQL that retrieves the source of a MQT. */
! private static final String MQT_SQL =
! "SELECT text " +
! "FROM SYSCAT.VIEWS " +
! "WHERE viewschema = ? " +
! "and viewname = ? ";
/** SQL that retrieves the source of a MQT on OS/400 */
! private static final String OS400_MQT_SQL =
! "select mqt_definition " +
! "from qsys2.systables " +
! "where table_schema = ? " +
! "and table_name = ? ";
/** Logger for this class. */
***************
*** 62,65 ****
--- 68,75 ----
* Constructor
*
+ * @param hint
+ * what the user sees on mouse-over tool-tip
+ * @param stmtSep
+ * the string to use to separate SQL statements
* @param isOS400
* whether or not we are connected to an OS/400 system
***************
*** 187,189 ****
--- 197,204 ----
return tmp.toString();
}
+
+ protected String getSqlStatement()
+ {
+ return null;
+ }
}
Index: ProcedureSourceTab.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/plugins/db2/src/net/sourceforge/squirrel_sql/plugins/db2/tab/ProcedureSourceTab.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** ProcedureSourceTab.java 30 Aug 2007 21:59:31 -0000 1.8
--- ProcedureSourceTab.java 12 Dec 2009 18:06:05 -0000 1.9
***************
*** 1,3 ****
--- 1,4 ----
package net.sourceforge.squirrel_sql.plugins.db2.tab;
+
/*
* Copyright (C) 2006 Rob Manning
***************
*** 18,111 ****
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
- import java.sql.PreparedStatement;
- import java.sql.SQLException;
-
- import net.sourceforge.squirrel_sql.client.session.ISession;
import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.FormattedSourceTab;
- import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
- import net.sourceforge.squirrel_sql.fw.sql.ISQLConnection;
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;
/**
! * This class will display the source for an DB2 stored procedure.
! *
! * @author manningr
*/
public class ProcedureSourceTab extends FormattedSourceTab
{
!
! private static interface i18n {
! StringManager s_stringMgr =
! StringManagerFactory.getStringManager(ProcedureSourceTab.class);
- //i18n[ProcedureSourceTab.cLanguageProcMsg=This is a C-language routine. The
- //source code is unavailable.]
- String C_LANGUAGE_PROC_MSG =
- s_stringMgr.getString("ProcedureSourceTab.cLanguageProcMsg");
- }
-
/** SQL that retrieves the source of a stored procedure. */
private static String SQL =
! "select " +
! " case " +
! " when language = 'C' then '" +i18n.C_LANGUAGE_PROC_MSG+"' " +
! " else text " +
! " end as text " +
! "from SYSCAT.PROCEDURES " +
! "where PROCSCHEMA = ? " +
! "and PROCNAME = ? ";
!
! /** SQL that retrieves the source of a stored procedure on OS/400 */
! private static String OS_400_SQL =
! "select routine_definition from qsys2.sysroutines " +
! "where routine_schema = ? " +
! "and routine_name = ? ";
!
! /** Logger for this class. */
! private final static ILogger s_log =
! LoggerController.createLogger(ProcedureSourceTab.class);
!
! /** boolean to indicate whether or not this session is OS/400 */
! private boolean isOS400 = false;
! /**
! * Constructor
! *
! * @param hint what the user sees on mouse-over tool-tip
! * @param isOS400 whether or not the session is OS/400
! */
! public ProcedureSourceTab(String hint, boolean isOS400, String stmtSep)
! {
! super(hint);
! super.setCompressWhitespace(false);
! super.setupFormatter(stmtSep, null);
! this.isOS400 = isOS400;
! }
-
/**
! * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.BaseSourceTab#createStatement()
*/
@Override
! protected PreparedStatement createStatement() throws SQLException
{
! final ISession session = getSession();
! final IDatabaseObjectInfo doi = getDatabaseObjectInfo();
! String sql = SQL;
! if (isOS400) {
! sql = OS_400_SQL;
! }
! if (s_log.isDebugEnabled()) {
! s_log.debug("Running SQL for procedure source: "+sql);
! s_log.debug("schema="+doi.getSchemaName());
! s_log.debug("procedure name="+doi.getSimpleName());
! }
! ISQLConnection conn = session.getSQLConnection();
! PreparedStatement pstmt = conn.prepareStatement(sql);
! pstmt.setString(1, doi.getSchemaName());
! pstmt.setString(2, doi.getSimpleName());
! return pstmt;
}
}
--- 19,85 ----
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.FormattedSourceTab;
import net.sourceforge.squirrel_sql.fw.util.StringManager;
import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
!
/**
! * This class provides the necessary information to the parent tab to display the source for an DB2 stored
! * procedure.
*/
public class ProcedureSourceTab extends FormattedSourceTab
{
! private static interface i18n
! {
! StringManager s_stringMgr = StringManagerFactory.getStringManager(ProcedureSourceTab.class);
!
! // i18n[ProcedureSourceTab.cLanguageProcMsg=This is a C-language routine. The
! // source code is unavailable.]
! String C_LANGUAGE_PROC_MSG = s_stringMgr.getString("ProcedureSourceTab.cLanguageProcMsg");
! }
/** SQL that retrieves the source of a stored procedure. */
private static String SQL =
! "select " +
! " case " +
! " when language = 'C' then '" +i18n.C_LANGUAGE_PROC_MSG+"' " +
! " else text " +
! " end as text " +
! "from SYSCAT.PROCEDURES " +
! "where PROCSCHEMA = ? " +
! "and PROCNAME = ? ";
!
! /** SQL that retrieves the source of a stored procedure on OS/400 */
! private static String OS_400_SQL =
! "select routine_definition from qsys2.sysroutines " +
! "where routine_schema = ? " +
! "and routine_name = ? ";
! /** boolean to indicate whether or not this session is OS/400 */
! private boolean isOS400 = false;
/**
! * Constructor
! *
! * @param hint
! * what the user sees on mouse-over tool-tip
! * @param isOS400
! * whether or not the session is OS/400
*/
+ public ProcedureSourceTab(String hint, boolean isOS400, String stmtSep) {
+ super(hint);
+ super.setCompressWhitespace(false);
+ super.setupFormatter(stmtSep, null);
+ this.isOS400 = isOS400;
+ }
+
@Override
! protected String getSqlStatement()
{
! String sql = SQL;
! if (isOS400)
! {
! sql = OS_400_SQL;
! }
! return sql;
}
}
Index: ViewSourceTab.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/plugins/db2/src/net/sourceforge/squirrel_sql/plugins/db2/tab/ViewSourceTab.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ViewSourceTab.java 18 Aug 2007 13:49:17 -0000 1.4
--- ViewSourceTab.java 12 Dec 2009 18:06:05 -0000 1.5
***************
*** 1,3 ****
--- 1,6 ----
package net.sourceforge.squirrel_sql.plugins.db2.tab;
+
+ import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.FormattedSourceTab;
+
/*
* Copyright (C) 2007 Rob Manning
***************
*** 18,94 ****
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
- import java.sql.PreparedStatement;
- import java.sql.SQLException;
- import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
- import net.sourceforge.squirrel_sql.fw.sql.ISQLConnection;
- import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
- import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
-
- import net.sourceforge.squirrel_sql.client.session.ISession;
- import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.FormattedSourceTab;
/**
! * This class will display the source for an DB2 view.
! *
! * @author manningr
*/
public class ViewSourceTab extends FormattedSourceTab
{
/** SQL that retrieves the source of a stored procedure. */
! private static final String SQL =
! "SELECT TEXT " +
! "FROM SYSCAT.VIEWS " +
! "WHERE VIEWSCHEMA = ? " +
! "AND VIEWNAME = ? ";
!
/** SQL that retrieves the source of a stored procedure on OS/400 */
private static final String OS_400_SQL =
! "select view_definition " +
! "from qsys2.sysviews " +
! "where table_schema = ? " +
! "and table_name = ? ";
!
! /** Logger for this class. */
! private final static ILogger s_log =
! LoggerController.createLogger(ViewSourceTab.class);
! /** boolean to indicate whether or not this session is OS/400 */
! private boolean isOS400 = false;
!
! /**
! * Constructor
! *
! * @param isOS400 whether or not we are connected to an OS/400 system
! */
! public ViewSourceTab(String hint, String stmtSep, boolean isOS400)
! {
super(hint);
! super.setCompressWhitespace(true);
! super.setupFormatter(stmtSep, null);
! this.isOS400 = isOS400;
}
! /**
! * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.BaseSourceTab#createStatement()
! */
! @Override
! protected PreparedStatement createStatement() throws SQLException
{
! final ISession session = getSession();
! final IDatabaseObjectInfo doi = getDatabaseObjectInfo();
! ISQLConnection conn = session.getSQLConnection();
! String sql = SQL;
! if (isOS400) {
! sql = OS_400_SQL;
! }
! if (s_log.isDebugEnabled()) {
! s_log.debug("Running SQL for View source tab: "+sql);
! s_log.debug("schema="+doi.getSchemaName());
! s_log.debug("view name="+doi.getSimpleName());
! }
! PreparedStatement pstmt = conn.prepareStatement(sql);
! pstmt.setString(1, doi.getSchemaName());
! pstmt.setString(2, doi.getSimpleName());
! return pstmt;
}
}
--- 21,72 ----
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
! * This class will display the source for an DB2 view on either LUW or OS/400.
*/
public class ViewSourceTab extends FormattedSourceTab
{
/** SQL that retrieves the source of a stored procedure. */
! private static final String SQL =
! "SELECT TEXT " +
! "FROM SYSCAT.VIEWS " +
! "WHERE VIEWSCHEMA = ? " +
! "AND VIEWNAME = ? ";
!
/** SQL that retrieves the source of a stored procedure on OS/400 */
private static final String OS_400_SQL =
! "select view_definition " +
! "from qsys2.sysviews " +
! "where table_schema = ? " +
! "and table_name = ? ";
! /** boolean to indicate whether or not this session is OS/400 */
! private boolean isOS400 = false;
!
! /**
! * Constructor
! *
! * @param isOS400
! * whether or not we are connected to an OS/400 system
! */
! public ViewSourceTab(String hint, String stmtSep, boolean isOS400) {
super(hint);
! super.setCompressWhitespace(true);
! super.setupFormatter(stmtSep, null);
! this.isOS400 = isOS400;
}
! /**
! * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.table.PSFormattedSourceTab#getSqlStatement()
! */
! @Override
! protected String getSqlStatement()
{
! String sql = SQL;
! if (isOS400)
! {
! sql = OS_400_SQL;
! }
! return sql;
}
}
|