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;
}
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;
}
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;
}
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;
}
}
}
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;
}
Aggregations