Search in sources :

Example 11 with TableNode

use of org.talend.sqlbuilder.dbstructure.nodes.TableNode in project tdi-studio-se by Talend.

the class DetailTabManager method createTabs.

/**
     * Returns a list of all available tabs for a given node. These tabs can be
     * standard or plugin tabs.
     * 
     * @param node for which to find tabs.
     * @return List of tabs
     */
//$NON-NLS-1$
@SuppressWarnings("unchecked")
private static List createTabs(INode node) {
    //        if (CONSTANT_LOGGER.isDebugEnabled()) {
    //            CONSTANT_LOGGER.debug("Creating tabs for: " + node.getUniqueIdentifier());
    //        }
    ArrayList tabList = new ArrayList();
    // create connection info tab if needed
    if (node instanceof DatabaseNode) {
        IDetailTab dbTab = new ConnectionInfoTab();
        dbTab.setNode(node);
        tabList.add(dbTab);
    }
    // create our basic table tabs
    if (node instanceof TableNode) {
        IDetailTab tab1 = new ColumnInfoTab();
        //IDetailTab tab2 = new TableInfoTab();
        IDetailTab tab3 = new PreviewTab();
        IDetailTab tab4 = new RowCountTab();
        IDetailTab tab5 = new PrimaryKeysTab();
        IDetailTab tab6 = new ExportedKeysTab();
        IDetailTab tab7 = new ImportedKeysTab();
        IDetailTab tab8 = new IndexesTab();
        //IDetailTab tab9 = new PriviligesTab();
        //IDetailTab tab10 = new ColumnPriviligesTab();
        //IDetailTab tab11 = new RowIdsTab();
        //IDetailTab tab12 = new VersionsTab();
        tab1.setNode(node);
        //tab2.setNode(node);
        tab3.setNode(node);
        tab4.setNode(node);
        tab5.setNode(node);
        tab6.setNode(node);
        tab7.setNode(node);
        tab8.setNode(node);
        //tab9.setNode(node);
        //tab10.setNode(node);
        //tab11.setNode(node);
        //tab12.setNode(node);
        tabList.add(tab1);
        //tabList.add(tab2);
        tabList.add(tab3);
        tabList.add(tab4);
        tabList.add(tab5);
        tabList.add(tab6);
        tabList.add(tab7);
        tabList.add(tab8);
    //tabList.add(tab9);
    //tabList.add(tab10);
    //tabList.add(tab11);
    //tabList.add(tab12);
    }
    return tabList;
}
Also used : DatabaseNode(org.talend.sqlbuilder.dbstructure.nodes.DatabaseNode) PrimaryKeysTab(org.talend.sqlbuilder.dbdetail.tab.PrimaryKeysTab) ImportedKeysTab(org.talend.sqlbuilder.dbdetail.tab.ImportedKeysTab) RowCountTab(org.talend.sqlbuilder.dbdetail.tab.RowCountTab) ArrayList(java.util.ArrayList) TableNode(org.talend.sqlbuilder.dbstructure.nodes.TableNode) PreviewTab(org.talend.sqlbuilder.dbdetail.tab.PreviewTab) IndexesTab(org.talend.sqlbuilder.dbdetail.tab.IndexesTab) ExportedKeysTab(org.talend.sqlbuilder.dbdetail.tab.ExportedKeysTab) ConnectionInfoTab(org.talend.sqlbuilder.dbdetail.tab.ConnectionInfoTab) ColumnInfoTab(org.talend.sqlbuilder.dbdetail.tab.ColumnInfoTab)

Example 12 with TableNode

use of org.talend.sqlbuilder.dbstructure.nodes.TableNode in project tdi-studio-se by Talend.

the class ColumnInfoTab method getDataSet.

public DataSet getDataSet() throws Exception {
    INode node = getNode();
    if (node == null) {
        return null;
    }
    if (node.getSession() == null) {
        return null;
    }
    if (node instanceof TableNode) {
        TableNode tableNode = (TableNode) node;
        ITableInfo ti = tableNode.getTableInfo();
        if (tableNode.getTableInfo() == null) {
            return null;
        }
        ResultSet resultSet = null;
        SessionTreeNode treeNode = node.getSession();
        // For synonym table, should get the corresponding table.
        if (ti.getType().equals("SYNONYM")) {
            //$NON-NLS-1$
            String realTableName = ExtractMetaDataFromDataBase.getTableNameBySynonym(treeNode.getInteractiveConnection().getConnection(), ti.getSimpleName());
            resultSet = treeNode.getMetaData().getJDBCMetaData().getColumns(ti.getCatalogName(), ti.getSchemaName(), realTableName, //$NON-NLS-1$
            "%");
        } else {
            // https://jira.talendforge.org/browse/TDI-28578
            String tableName = ti.getSimpleName();
            if (tableName.contains("/")) {
                tableName = tableName.replaceAll("/", "//");
            }
            resultSet = node.getSession().getMetaData().getJDBCMetaData().getColumns(ti.getCatalogName(), ti.getSchemaName(), tableName, "%");
        // resultSet = node.getSession().getMetaData().getColumns(tableNode.getTableInfo());
        }
        DataSet dataSet = new DataSet(null, resultSet, new int[] { 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 });
        resultSet.close();
        return dataSet;
    }
    return null;
}
Also used : INode(org.talend.sqlbuilder.dbstructure.nodes.INode) ITableInfo(net.sourceforge.squirrel_sql.fw.sql.ITableInfo) DataSet(org.talend.sqlbuilder.dataset.dataset.DataSet) SessionTreeNode(org.talend.sqlbuilder.sessiontree.model.SessionTreeNode) TableNode(org.talend.sqlbuilder.dbstructure.nodes.TableNode) ResultSet(java.sql.ResultSet)

Example 13 with TableNode

use of org.talend.sqlbuilder.dbstructure.nodes.TableNode in project tdi-studio-se by Talend.

the class IndexesTab method getDataSet.

public DataSet getDataSet() throws Exception {
    INode node = getNode();
    if (node == null) {
        return null;
    }
    if (node.getSession() == null) {
        return null;
    }
    if (node instanceof TableNode) {
        TableNode tableNode = (TableNode) node;
        ITableInfo ti = tableNode.getTableInfo();
        if (tableNode.getTableInfo() == null) {
            return null;
        }
        ResultSet resultSet = null;
        SessionTreeNode treeNode = node.getSession();
        // For synonym table, should get the corresponding table.
        if (ti.getType().equals("SYNONYM")) {
            //$NON-NLS-1$
            String realTableName = ExtractMetaDataFromDataBase.getTableNameBySynonym(treeNode.getInteractiveConnection().getConnection(), ti.getSimpleName());
            resultSet = treeNode.getMetaData().getJDBCMetaData().getIndexInfo(ti.getCatalogName(), ti.getSchemaName(), realTableName, true, true);
        } else {
            resultSet = node.getSession().getMetaData().getIndexInfo((tableNode.getTableInfo()));
        }
        DataSet dataSet = new DataSet(null, resultSet, new int[] { 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 });
        resultSet.close();
        return dataSet;
    }
    return null;
}
Also used : INode(org.talend.sqlbuilder.dbstructure.nodes.INode) ITableInfo(net.sourceforge.squirrel_sql.fw.sql.ITableInfo) DataSet(org.talend.sqlbuilder.dataset.dataset.DataSet) SessionTreeNode(org.talend.sqlbuilder.sessiontree.model.SessionTreeNode) TableNode(org.talend.sqlbuilder.dbstructure.nodes.TableNode) ResultSet(java.sql.ResultSet)

Example 14 with TableNode

use of org.talend.sqlbuilder.dbstructure.nodes.TableNode in project tdi-studio-se by Talend.

the class PreviewTab method getDataSet.

public DataSet getDataSet() throws Exception {
    INode node = getNode();
    if (node == null) {
        return null;
    }
    if (node.getSession() == null) {
        return null;
    }
    if (node instanceof TableNode) {
        TableNode tableNode = (TableNode) node;
        if (tableNode.getTableInfo() == null) {
            return null;
        }
        int maxResults = SqlBuilderPlugin.getDefault().getPluginPreferences().getInt(IConstants.PRE_ROW_COUNT);
        if (maxResults == 0) {
            maxResults = 50;
        }
        Statement statement = tableNode.getSession().getInteractiveConnection().createStatement();
        statement.setMaxRows(maxResults);
        //$NON-NLS-1$
        statement.execute("select * from " + tableNode.getQualifiedName());
        ResultSet resultSet = statement.getResultSet();
        DataSet dataSet = new DataSet(null, resultSet, null);
        resultSet.close();
        statement.close();
        return dataSet;
    }
    return null;
}
Also used : INode(org.talend.sqlbuilder.dbstructure.nodes.INode) DataSet(org.talend.sqlbuilder.dataset.dataset.DataSet) Statement(java.sql.Statement) TableNode(org.talend.sqlbuilder.dbstructure.nodes.TableNode) ResultSet(java.sql.ResultSet)

Example 15 with TableNode

use of org.talend.sqlbuilder.dbstructure.nodes.TableNode in project tdi-studio-se by Talend.

the class RowCountTab method getDataSet.

public DataSet getDataSet() throws Exception {
    String nodeName = getNode().toString();
    INode node = getNode();
    if (node == null) {
        return null;
    }
    if (node.getSession() == null) {
        return null;
    }
    if (node instanceof TableNode) {
        TableNode tableNode = (TableNode) getNode();
        nodeName = tableNode.getQualifiedName();
    }
    //$NON-NLS-1$
    return new DataSet(null, "select count(*) from " + nodeName, null, getNode().getSession().getInteractiveConnection());
}
Also used : INode(org.talend.sqlbuilder.dbstructure.nodes.INode) DataSet(org.talend.sqlbuilder.dataset.dataset.DataSet) TableNode(org.talend.sqlbuilder.dbstructure.nodes.TableNode)

Aggregations

TableNode (org.talend.sqlbuilder.dbstructure.nodes.TableNode)15 INode (org.talend.sqlbuilder.dbstructure.nodes.INode)11 ArrayList (java.util.ArrayList)7 DataSet (org.talend.sqlbuilder.dataset.dataset.DataSet)7 ResultSet (java.sql.ResultSet)6 ITableInfo (net.sourceforge.squirrel_sql.fw.sql.ITableInfo)5 SessionTreeNode (org.talend.sqlbuilder.sessiontree.model.SessionTreeNode)5 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)4 Point (org.eclipse.swt.graphics.Point)4 TreeSet (java.util.TreeSet)3 Image (org.eclipse.swt.graphics.Image)3 Iterator (java.util.Iterator)2 CompletionProposal (org.eclipse.jface.text.contentassist.CompletionProposal)2 DatabaseNode (org.talend.sqlbuilder.dbstructure.nodes.DatabaseNode)2 Statement (java.sql.Statement)1 List (java.util.List)1 IToken (org.eclipse.jface.text.rules.IToken)1 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)1 ColumnInfoTab (org.talend.sqlbuilder.dbdetail.tab.ColumnInfoTab)1 ConnectionInfoTab (org.talend.sqlbuilder.dbdetail.tab.ConnectionInfoTab)1