Search in sources :

Example 1 with CatalogNode

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;
}
Also used : INode(org.talend.sqlbuilder.dbstructure.nodes.INode) DatabaseNode(org.talend.sqlbuilder.dbstructure.nodes.DatabaseNode) CatalogNode(org.talend.sqlbuilder.dbstructure.nodes.CatalogNode) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) TableNode(org.talend.sqlbuilder.dbstructure.nodes.TableNode) MetadataTableRepositoryObject(org.talend.sqlbuilder.dbstructure.DBTreeProvider.MetadataTableRepositoryObject)

Example 2 with CatalogNode

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();
    }
}
Also used : SchemaNode(org.talend.sqlbuilder.dbstructure.nodes.SchemaNode) INode(org.talend.sqlbuilder.dbstructure.nodes.INode) CatalogNode(org.talend.sqlbuilder.dbstructure.nodes.CatalogNode)

Aggregations

CatalogNode (org.talend.sqlbuilder.dbstructure.nodes.CatalogNode)2 INode (org.talend.sqlbuilder.dbstructure.nodes.INode)2 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)1 MetadataTableRepositoryObject (org.talend.sqlbuilder.dbstructure.DBTreeProvider.MetadataTableRepositoryObject)1 DatabaseNode (org.talend.sqlbuilder.dbstructure.nodes.DatabaseNode)1 SchemaNode (org.talend.sqlbuilder.dbstructure.nodes.SchemaNode)1 TableNode (org.talend.sqlbuilder.dbstructure.nodes.TableNode)1