Search in sources :

Example 1 with IndexInfo

use of net.sourceforge.squirrel_sql.fw.sql.IndexInfo 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 2 with IndexInfo

use of net.sourceforge.squirrel_sql.fw.sql.IndexInfo in project tdq-studio-se by Talend.

the class IndexNode method loadChildren.

/*
     * (non-Javadoc)
     * 
     * @see net.sourceforge.sqlexplorer.dbstructure.nodes.AbstractNode#loadChildren()
     */
public void loadChildren() {
    try {
        List<IndexInfo> infos = _session.getMetaData().getIndexInfo(_parentTable.getTableInfo());
        for (IndexInfo info : infos) {
            String indexName = info.getSimpleName();
            SortOrder sort = info.getSortOrder();
            if (indexName != null && indexName.equalsIgnoreCase(_name)) {
                ColumnNode col = new ColumnNode(this, info.getColumnName(), _session, _parentTable, true);
                if (sort == null || sort == SortOrder.ASC) {
                    col.setLabelDecoration("ASC");
                } else {
                    col.setLabelDecoration("DESC");
                }
                addChildNode(col);
            }
        }
    } catch (Exception e) {
        SQLExplorerPlugin.error("Could not load column names", e);
    }
}
Also used : SortOrder(net.sourceforge.squirrel_sql.fw.sql.IndexInfo.SortOrder) IndexInfo(net.sourceforge.squirrel_sql.fw.sql.IndexInfo)

Aggregations

IndexInfo (net.sourceforge.squirrel_sql.fw.sql.IndexInfo)2 ArrayList (java.util.ArrayList)1 DataSet (net.sourceforge.sqlexplorer.dataset.DataSet)1 INode (net.sourceforge.sqlexplorer.dbstructure.nodes.INode)1 TableNode (net.sourceforge.sqlexplorer.dbstructure.nodes.TableNode)1 SortOrder (net.sourceforge.squirrel_sql.fw.sql.IndexInfo.SortOrder)1