use of org.talend.sqlbuilder.dbstructure.nodes.CatalogNode in project tdi-studio-se by Talend.
the class SessionTreeNodeManager method convert2INode.
/**
* DOC qianbing Comment method "convert2INode". Converts the RepositoryNode input to INode. INode is used for the
* sql editor,result viewer and the detail viewer.
*
* @param repositoryNode RepositoryNode
* @param selectedContext
* @return INode
*/
public INode convert2INode(RepositoryNode repositoryNode, String selectedContext, SessionTreeNode sessionTreeNode) throws Exception {
// Creates the SessionTreeNode.
RepositoryNodeType nodeType = getRepositoryType(repositoryNode);
if (nodeType.equals(RepositoryNodeType.DATABASE)) {
// processes the database
DatabaseModel model = sessionTreeNode.getDbModel();
INode[] nodes = model.getChildNodes();
DatabaseNode dn = (DatabaseNode) nodes[0];
return dn;
} else if (nodeType.equals(RepositoryNodeType.TABLE)) {
// processes the table
MetadataTableRepositoryObject tableObject = (MetadataTableRepositoryObject) repositoryNode.getObject();
MetadataTable table = tableObject.getTable();
String realName = table.getSourceName();
DatabaseModel model = sessionTreeNode.getDbModel();
INode[] nodes = model.getChildNodes();
DatabaseNode dn = (DatabaseNode) nodes[0];
nodes = dn.getChildNodes();
CatalogNode cn = (CatalogNode) nodes[0];
nodes = cn.getChildNodes();
if (nodes != null && nodes.length > 0) {
for (INode node : nodes) {
TableNode tableNode = (TableNode) node;
if (tableNode.getName().equals(realName)) {
return node;
}
}
}
} else if (nodeType.equals(RepositoryNodeType.COLUMN)) {
// Processes the column.
// Gets the repositoryNode's parent,should be the repositoryNode of table infomation.
repositoryNode = repositoryNode.getParent();
return convert2INode(repositoryNode, selectedContext, sessionTreeNode);
}
return null;
}
use of org.talend.sqlbuilder.dbstructure.nodes.CatalogNode in project tdi-studio-se by Talend.
the class Dictionary method load.
/**
* Perform full load of dictionary for dbNode.
*
* @param dbNode DatabaseNode of which to load dictionary information
* @param monitor ProgressMonitor displayed whilst loading
* @throws InterruptedException If user cancelled loading
*/
public void load(DatabaseNode dbNode, IProgressMonitor monitor) throws InterruptedException {
try {
// check for cancellation by user
if (monitor.isCanceled()) {
//$NON-NLS-1$
throw new InterruptedException(Messages.getString("Progress.Dictionary.Cancelled"));
}
INode[] children = dbNode.getChildNodes();
if (children == null) {
return;
}
// start task with a 1000 work units for every root node
monitor.beginTask(dbNode.getSession().toString(), children.length * ROOT_WORK_UNIT);
for (int i = 0; i < children.length; i++) {
// check for cancellation by user
if (monitor.isCanceled()) {
//$NON-NLS-1$
throw new InterruptedException(Messages.getString("Progress.Dictionary.Cancelled"));
}
INode node = (INode) children[i];
if (node instanceof SchemaNode || node instanceof CatalogNode) {
loadSchemaCatalog(node, monitor);
}
}
// store dictionary immediately so that
// we can resuse it if a second session is opened
store();
} finally {
monitor.done();
}
}
Aggregations