Search in sources :

Example 6 with INode

use of net.sourceforge.sqlexplorer.dbstructure.nodes.INode in project tdq-studio-se by Talend.

the class VersionsTab method getDataSet.

public DataSet getDataSet() throws Exception {
    INode node = getNode();
    if (node == null) {
        return null;
    }
    if (node instanceof TableNode) {
        TableNode tableNode = (TableNode) node;
        ResultSet resultSet = node.getSession().getMetaData().getVersionColumns(tableNode.getTableInfo());
        DataSet dataSet = new DataSet(resultSet, null);
        resultSet.close();
        return dataSet;
    }
    return null;
}
Also used : INode(net.sourceforge.sqlexplorer.dbstructure.nodes.INode) DataSet(net.sourceforge.sqlexplorer.dataset.DataSet) TableNode(net.sourceforge.sqlexplorer.dbstructure.nodes.TableNode) ResultSet(java.sql.ResultSet)

Example 7 with INode

use of net.sourceforge.sqlexplorer.dbstructure.nodes.INode in project tdq-studio-se by Talend.

the class IndexesTab method getDataSet.

public DataSet getDataSet() throws Exception {
    INode node = getNode();
    if (node == null) {
        return null;
    }
    if (node instanceof TableNode) {
        TableNode tableNode = (TableNode) node;
        List<IndexInfo> indexes = node.getSession().getMetaData().getIndexInfo(tableNode.getTableInfo());
        List<Comparable[]> dataRows = new ArrayList<Comparable[]>();
        int index = 0;
        for (IndexInfo col : indexes) {
            // type)
            if ("STATISTIC".equalsIgnoreCase(col.getIndexType().name())) {
                continue;
            }
            Comparable[] row = new Comparable[COLUMN_LABELS.length];
            dataRows.add(row);
            int i = 0;
            row[i++] = col.isNonUnique();
            row[i++] = col.getIndexQualifier();
            row[i++] = col.getSimpleName();
            row[i++] = col.getIndexType();
            row[i++] = col.getOrdinalPosition();
            row[i++] = col.getColumnName();
            row[i++] = col.getSortOrder();
            row[i++] = col.getCardinality();
            row[i++] = col.getPages();
            row[i++] = col.getFilterCondition();
            if (i != COLUMN_LABELS.length)
                throw new RuntimeException(Messages.getString("ColumnInfoTab.runtimeException"));
        }
        DataSet dataSet = new DataSet(COLUMN_LABELS, dataRows.toArray(new Comparable[dataRows.size()][]));
        return dataSet;
    }
    return null;
}
Also used : INode(net.sourceforge.sqlexplorer.dbstructure.nodes.INode) DataSet(net.sourceforge.sqlexplorer.dataset.DataSet) TableNode(net.sourceforge.sqlexplorer.dbstructure.nodes.TableNode) ArrayList(java.util.ArrayList) IndexInfo(net.sourceforge.squirrel_sql.fw.sql.IndexInfo)

Example 8 with INode

use of net.sourceforge.sqlexplorer.dbstructure.nodes.INode in project tdq-studio-se by Talend.

the class ColumnPriviligesTab method getDataSet.

public DataSet getDataSet() throws Exception {
    INode node = getNode();
    if (node == null) {
        return null;
    }
    if (node instanceof TableNode) {
        TableNode tableNode = (TableNode) node;
        ResultSet resultSet = node.getSession().getMetaData().getColumnPrivileges(tableNode.getTableInfo());
        DataSet dataSet = new DataSet(resultSet, new int[] { 4, 5, 6, 7, 8 });
        resultSet.close();
        return dataSet;
    }
    return null;
}
Also used : INode(net.sourceforge.sqlexplorer.dbstructure.nodes.INode) DataSet(net.sourceforge.sqlexplorer.dataset.DataSet) TableNode(net.sourceforge.sqlexplorer.dbstructure.nodes.TableNode) ResultSet(java.sql.ResultSet)

Example 9 with INode

use of net.sourceforge.sqlexplorer.dbstructure.nodes.INode in project tdq-studio-se by Talend.

the class Dictionary method loadSchemaCatalog.

/**
 * Load dictionary data for catalog
 *
 * @param node catalognode to load
 * @param monitor ProgressMonitor displayed whilst loading
 * @throws InterruptedException If user cancelled loading
 */
private void loadSchemaCatalog(INode iNode, IProgressMonitor monitor) throws InterruptedException {
    if (_logger.isDebugEnabled()) {
        _logger.debug("Loading dictionary: " + iNode.getName());
    }
    // check for cancellation by user
    if (monitor.isCanceled()) {
        throw new InterruptedException(Messages.getString("Progress.Dictionary.Cancelled"));
    }
    putCatalogSchemaName(iNode.toString(), iNode);
    monitor.subTask(iNode.getName());
    INode[] children = iNode.getChildNodes();
    if (children != null) {
        // check for cancellation by user
        if (monitor.isCanceled()) {
            throw new InterruptedException(Messages.getString("Progress.Dictionary.Cancelled"));
        }
        // divide work equally between type nodes
        int typeNodeWorkUnit = ROOT_WORK_UNIT / SUPPORTED_CONTENT_ASSIST_TYPES.length;
        int typeNodeWorkCompleted = 0;
        for (int i = 0; i < children.length; i++) {
            INode typeNode = children[i];
            if (_logger.isDebugEnabled()) {
                _logger.debug("Loading dictionary: " + typeNode.getName());
            }
            // only load a few types like tables and view nodes into the
            // dictionary
            boolean isIncludedInContentAssist = false;
            for (int j = 0; j < SUPPORTED_CONTENT_ASSIST_TYPES.length; j++) {
                if (typeNode.getType().equalsIgnoreCase(SUPPORTED_CONTENT_ASSIST_TYPES[j])) {
                    isIncludedInContentAssist = true;
                }
            }
            if (!isIncludedInContentAssist) {
                continue;
            }
            monitor.subTask(typeNode.getName());
            // check for cancellation by user
            if (monitor.isCanceled()) {
                throw new InterruptedException(Messages.getString("Progress.Dictionary.Cancelled"));
            }
            INode[] tableNodes = typeNode.getChildNodes();
            if (tableNodes != null) {
                // check for cancellation by user
                if (monitor.isCanceled()) {
                    throw new InterruptedException(Messages.getString("Progress.Dictionary.Cancelled"));
                }
                int tableNodeWorkUnit = typeNodeWorkUnit / tableNodes.length;
                for (int j = 0; j < tableNodes.length; j++) {
                    INode tableNode = tableNodes[j];
                    if (_logger.isDebugEnabled()) {
                        _logger.debug("Loading dictionary: " + tableNode.getName());
                    }
                    if (monitor != null) {
                        monitor.worked(tableNodeWorkUnit);
                        typeNodeWorkCompleted = typeNodeWorkCompleted + tableNodeWorkUnit;
                        if (_logger.isDebugEnabled()) {
                            _logger.debug("worked table: " + tableNodeWorkUnit + ", total type work: " + typeNodeWorkCompleted);
                        }
                        monitor.subTask(tableNode.getQualifiedName());
                        // check for cancellation by user
                        if (monitor.isCanceled()) {
                            throw new InterruptedException(Messages.getString("Progress.Dictionary.Cancelled"));
                        }
                    }
                    // add table name
                    ArrayList tableDetails = (ArrayList) getByTableName(tableNode.getName());
                    if (tableDetails == null) {
                        tableDetails = new ArrayList();
                        putTableName(tableNode.getName(), tableDetails);
                    }
                    tableDetails.add(tableNode);
                    // add column names
                    if (tableNode instanceof TableNode) {
                        TreeSet columnNames = new TreeSet();
                        List columns = ((TableNode) tableNode).getColumnNames();
                        if (columns != null) {
                            Iterator it = columns.iterator();
                            while (it.hasNext()) {
                                columnNames.add(it.next());
                            }
                        }
                        putColumnsByTableName(tableNode.getName(), columnNames);
                    }
                }
            }
            if (typeNodeWorkCompleted < typeNodeWorkUnit) {
                if (_logger.isDebugEnabled()) {
                    _logger.debug("consuming remainder: " + (typeNodeWorkUnit - typeNodeWorkCompleted));
                }
                monitor.worked(typeNodeWorkUnit - typeNodeWorkCompleted);
            }
            typeNodeWorkCompleted = 0;
        }
    }
}
Also used : INode(net.sourceforge.sqlexplorer.dbstructure.nodes.INode) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) TableNode(net.sourceforge.sqlexplorer.dbstructure.nodes.TableNode) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List)

Example 10 with INode

use of net.sourceforge.sqlexplorer.dbstructure.nodes.INode in project tdq-studio-se by Talend.

the class DBTreeLabelProvider method getText.

/**
 * Return the text to display the INode.
 *
 * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
 */
public String getText(Object element) {
    INode node = (INode) element;
    String text = node.getLabelText();
    // return default if no label is provided
    if (text == null) {
        text = node.toString();
    }
    if (node.getLabelDecoration() != null) {
        text = text + " [" + node.getLabelDecoration() + "]";
    }
    return text;
}
Also used : INode(net.sourceforge.sqlexplorer.dbstructure.nodes.INode)

Aggregations

INode (net.sourceforge.sqlexplorer.dbstructure.nodes.INode)22 TableNode (net.sourceforge.sqlexplorer.dbstructure.nodes.TableNode)15 DataSet (net.sourceforge.sqlexplorer.dataset.DataSet)12 ResultSet (java.sql.ResultSet)7 ArrayList (java.util.ArrayList)6 SQLException (java.sql.SQLException)4 Iterator (java.util.Iterator)3 List (java.util.List)2 TreeSet (java.util.TreeSet)2 SQLConnection (net.sourceforge.sqlexplorer.dbproduct.SQLConnection)2 DatabaseNode (net.sourceforge.sqlexplorer.dbstructure.nodes.DatabaseNode)2 SchemaNode (net.sourceforge.sqlexplorer.dbstructure.nodes.SchemaNode)2 TableFolderNode (net.sourceforge.sqlexplorer.dbstructure.nodes.TableFolderNode)2 Point (org.eclipse.swt.graphics.Point)2 DatabaseMetaData (java.sql.DatabaseMetaData)1 Statement (java.sql.Statement)1 LinkedList (java.util.LinkedList)1 SQLCannotConnectException (net.sourceforge.sqlexplorer.SQLCannotConnectException)1 Alias (net.sourceforge.sqlexplorer.dbproduct.Alias)1 User (net.sourceforge.sqlexplorer.dbproduct.User)1