Search in sources :

Example 1 with ITableInfo

use of net.sourceforge.squirrel_sql.fw.sql.ITableInfo in project tdi-studio-se by Talend.

the class CatalogNode method loadChildren.

/**
     * LoadChildren.
     */
//$NON-NLS-1$
@SuppressWarnings("unchecked")
public void loadChildren() {
    if (psessionNode.getInteractiveConnection() == null) {
        //$NON-NLS-1$
        TableFolderNode node = new TableFolderNode(this, "TABLE", psessionNode, new ITableInfo[0]);
        addChildNode(node);
        return;
    }
    pchildNames = new ArrayList();
    try {
        ITableInfo[] tables = null;
        // String[] tableTypes = psessionNode.getMetaData().getTableTypes();
        //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        String[] tableTypes = { "TABLE", "VIEW", "SYNONYM" };
        try {
            //$NON-NLS-1$
            tables = psessionNode.getMetaData().getTables(null, getSchemaName(), "%", tableTypes);
        } catch (Throwable e) {
            //$NON-NLS-1$
            SqlBuilderPlugin.log(Messages.getString("CatalogNode.logMessage1"), e);
        }
        //$NON-NLS-1$
        TableFolderNode node = new TableFolderNode(this, "TABLE", psessionNode, tables);
        pchildNames.add(node.getLabelText());
        if (!isExcludedByFilter(node.getLabelText())) {
            addChildNode(node);
        }
    } catch (Throwable e) {
        //$NON-NLS-1$
        SqlBuilderPlugin.log(Messages.getString("CatalogNode.logMessage2", pname), e);
    }
}
Also used : ITableInfo(net.sourceforge.squirrel_sql.fw.sql.ITableInfo) ArrayList(java.util.ArrayList)

Example 2 with ITableInfo

use of net.sourceforge.squirrel_sql.fw.sql.ITableInfo in project tdi-studio-se by Talend.

the class SchemaNode method loadChildren.

/**
     * LoadChildren.
     */
//$NON-NLS-1$
@SuppressWarnings("unchecked")
public void loadChildren() {
    pchildNames = new ArrayList();
    try {
        ITableInfo[] tables = null;
        String[] tableTypes = psessionNode.getMetaData().getTableTypes();
        try {
            //$NON-NLS-1$
            tables = psessionNode.getMetaData().getTables(pname, pname, "%", tableTypes);
        } catch (Throwable e) {
            //$NON-NLS-1$
            SqlBuilderPlugin.log(Messages.getString("SchemaNode.logMessage3"), e);
        }
        for (int i = 0; i < tableTypes.length; ++i) {
            INode childNode = findExtensionNode(tableTypes[i]);
            if (childNode != null) {
                pchildNames.add(childNode.getLabelText());
                if (!isExcludedByFilter(childNode.getLabelText())) {
                    addChildNode(childNode);
                }
            } else {
                TableFolderNode node = new TableFolderNode(this, tableTypes[i], psessionNode, tables);
                pchildNames.add(node.getLabelText());
                if (!isExcludedByFilter(node.getLabelText())) {
                    addChildNode(node);
                }
            }
        }
        // load extension nodes
        addExtensionNodes();
    } catch (Throwable e) {
        //$NON-NLS-1$
        SqlBuilderPlugin.log(Messages.getString("SchemaNode.logMessage4") + pname, e);
    }
}
Also used : ITableInfo(net.sourceforge.squirrel_sql.fw.sql.ITableInfo) ArrayList(java.util.ArrayList) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint)

Example 3 with ITableInfo

use of net.sourceforge.squirrel_sql.fw.sql.ITableInfo in project tdi-studio-se by Talend.

the class ImportedKeysTab 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().getImportedKeys(ti.getCatalogName(), ti.getSchemaName(), realTableName);
        } else {
            resultSet = node.getSession().getMetaData().getImportedKeys((tableNode.getTableInfo()));
        }
        DataSet dataSet = new DataSet(null, resultSet, new int[] { 3, 4, 8, 9, 10, 11, 12, 13, 14 });
        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 4 with ITableInfo

use of net.sourceforge.squirrel_sql.fw.sql.ITableInfo in project tdi-studio-se by Talend.

the class PrimaryKeysTab 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 name .
        if (ti.getType().equals("SYNONYM")) {
            //$NON-NLS-1$
            String realTableName = ExtractMetaDataFromDataBase.getTableNameBySynonym(treeNode.getInteractiveConnection().getConnection(), ti.getSimpleName());
            resultSet = treeNode.getMetaData().getJDBCMetaData().getPrimaryKeys(ti.getCatalogName(), ti.getSchemaName(), realTableName);
        } else {
            resultSet = node.getSession().getMetaData().getPrimaryKeys((tableNode.getTableInfo()));
        }
        DataSet dataSet = new DataSet(null, resultSet, new int[] { 4, 5, 6 });
        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 5 with ITableInfo

use of net.sourceforge.squirrel_sql.fw.sql.ITableInfo in project tdi-studio-se by Talend.

the class ExportedKeysTab 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().getExportedKeys(ti.getCatalogName(), ti.getSchemaName(), realTableName);
        } else {
            resultSet = node.getSession().getMetaData().getExportedKeys((tableNode.getTableInfo()));
        }
        DataSet dataSet = new DataSet(null, resultSet, new int[] { 4, 7, 8, 9, 10, 11, 12, 13, 14 });
        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)

Aggregations

ITableInfo (net.sourceforge.squirrel_sql.fw.sql.ITableInfo)7 ResultSet (java.sql.ResultSet)5 DataSet (org.talend.sqlbuilder.dataset.dataset.DataSet)5 INode (org.talend.sqlbuilder.dbstructure.nodes.INode)5 TableNode (org.talend.sqlbuilder.dbstructure.nodes.TableNode)5 SessionTreeNode (org.talend.sqlbuilder.sessiontree.model.SessionTreeNode)5 ArrayList (java.util.ArrayList)2 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)1