public class TriggerSourceTab extends FormattedSourceTab { /** SQL that retrieves the source of a trigger. */ private final static String SQL = "select TEXT from SYSCAT.TRIGGERS " + "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 " + "where trigger_schema = ? " + "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) { super(hint); super.setCompressWhitespace(true); super.setupFormatter(stmtSep, null); this.isOS2400 = isOS2400; } /** * @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
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
Clone fragments detected by clone detection tool
File path: /sql12/plugins/db2/src/net/sourceforge/squirrel_sql/plugins/db2/tab/TriggerSourceTab.java File path: /sql12/plugins/db2/src/net/sourceforge/squirrel_sql/plugins/db2/tab/ViewSourceTab.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public class TriggerSourceTab extends FormattedSourceTab
1
public class ViewSourceTab extends FormattedSourceTab
2
{
2
{
3
	/** SQL that retrieves the source of a trigger. */
3
	/** SQL that retrieves the source of a stored procedure. */
4
	private final static String SQL =
4
	private static final String SQL =
5
        "select TEXT from
5
        "SELECT TEXT " +
6
 SYSCAT.TRIGGERS " +
6
        "FROM SYSCAT.VIEWS " +
7
        "where TABSCHEMA = ? " +
7
        "WHERE VIEWSCHEMA = ? " +
8
        "and TRIGNAME = ? ";
8
        "AND VIEWNAME = ? ";
9
    
9
	
10
	/** SQL that retrieves the source of a trigger on DB2 on OS/400. */
10
	/** SQL that retrieves the source of a stored procedure on OS/400 */
11
	private final static String OS2_400_SQL = 
11
	private static final String OS_400_SQL = 
12
	    "select action_statement " +
12
	    "select view_definition " +
13
	    "from qsys2.systriggers " +
13
	    "from qsys2.sysviews " +
14
	    "where trigger_schema = ? " +
14
	    "where table_schema = ? " +
15
	    "and trigger_name = ? ";
15
	    "and table_name = ? ";
16
	
16
	
17
	/** Logger for this class. */
17
	/** Logger for this class. */
18
	private final static ILogger s_log =
18
	private final static ILogger s_log =
19
		LoggerController.createLogger(TriggerSourceTab.class);
19
		LoggerController.createLogger(ViewSourceTab.class);
20
	
21
	
20
    /** boolean to indicate whether or not this session is OS/400 */
22
private boolean isOS2400 = false;
21
    private boolean isOS400 = false;
22
    
23
	
24
    /**
25
     * Constructor
26
     * 
27
     * @param isOS400 whether or not we are connected to an OS/400 system
28
     */    
23
	public TriggerSourceTab(String hint, boolean isOS2400, String stmtSep)
29
	public ViewSourceTab(String hint, String stmtSep, boolean isOS400)
24
	{
30
	{
25
		super(hint);
31
		super(hint);
26
        super.setCompressWhitespace(true);
32
        super.setCompressWhitespace(true);
27
        super.setupFormatter(stmtSep, null);
33
        super.setupFormatter(stmtSep, null); 
28
        this.isOS2400 = isOS2400;
34
        this.isOS400 = isOS400;
29
	}
35
	}
30
    /**
36
    /**
31
     * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.BaseSourceTab#createStatement()
37
     * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.BaseSourceTab#createStatement()
32
     */
38
     */
33
    @Override	
39
    @Override	
34
	protected PreparedStatement createStatement() throws SQLException
40
	protected PreparedStatement createStatement() throws SQLException
35
	{
41
	{
36
		final ISession session = getSession();
42
		final ISession session = getSession();
37
		final IDatabaseObjectInfo doi = getDatabaseObjectInfo();
43
		final IDatabaseObjectInfo doi = getDatabaseObjectInfo();
38
		
44
		ISQLConnection conn = session.getSQLConnection();
39
String sql = SQL;
45
        String sql = SQL;
40
		if (isOS2400) {
46
        if (isOS400) {
41
		    sql = OS2_400_SQL;
47
            sql = OS_400_SQL;
42
		}
43
		
48
        }		
44
        if (s_log.isDebugEnabled()) {
49
        if (s_log.isDebugEnabled()) {
45
            s_log.debug("Running SQL: "+sql);
50
            s_log.debug("Running SQL for View source tab: "+sql);
46
            s_log.debug("schema="+doi.getSchemaName());
51
            s_log.debug("schema="+doi.getSchemaName());
47
            s_log.debug("trigname="+doi.getSimpleName());
52
            s_log.debug("view name="+doi.getSimpleName());
48
        }
53
        
49
		ISQLConnection conn = session.getSQLConnection();
54
    
55
        }
50
		PreparedStatement pstmt = conn.prepareStatement(sql);
56
		PreparedStatement pstmt = conn.prepareStatement(sql);
51
        pstmt.setString(1, doi.getSchemaName());
57
        pstmt.setString(1, doi.getSchemaName());
52
		pstmt.setString(2, doi.getSimpleName());
58
		pstmt.setString(2, doi.getSimpleName());
53
		return pstmt
59
		return pstmt
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0