Search in sources :

Example 6 with DBConnectionRepNode

use of org.talend.dq.nodes.DBConnectionRepNode in project tdq-studio-se by Talend.

the class RepositoryNodeHelper method recursiveFindDatabaseConnection.

public static DBConnectionRepNode recursiveFindDatabaseConnection(DatabaseConnection dbConn) {
    if (dbConn == null) {
        return null;
    }
    String uuid = getUUID(dbConn);
    if (uuid == null) {
        return null;
    }
    IRepositoryNode MetadataDBConnectionFolderNode = getMetadataDBConnectionFolderNode(dbConn);
    List<DBConnectionRepNode> dbConnectionRepNodes = getDBConnectionRepNodes(MetadataDBConnectionFolderNode, true, true);
    if (dbConnectionRepNodes.size() > 0) {
        for (DBConnectionRepNode childNode : dbConnectionRepNodes) {
            if (uuid.equals(getUUID(childNode.getDatabaseConnection()))) {
                return childNode;
            }
        }
    }
    return null;
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 7 with DBConnectionRepNode

use of org.talend.dq.nodes.DBConnectionRepNode in project tdq-studio-se by Talend.

the class TableAnalysisDPSelectionPage method addListeners.

@Override
protected void addListeners() {
    addListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
            if (object instanceof NamedColumnSet) {
                advanceToNextPageOrFinish();
            }
        }
    });
    addListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            // Connection oldTdDataProvider = null;
            NamedColumnSetAnalysisParameter paraneter = (NamedColumnSetAnalysisParameter) getConnectionParams();
            List tempList = ((IStructuredSelection) event.getSelection()).toList();
            List<NamedColumnSet> setList = new ArrayList<NamedColumnSet>();
            for (Object object : tempList) {
                if (object instanceof DBTableRepNode) {
                    DBTableRepNode tableNode = (DBTableRepNode) object;
                    // MOD klliu if table node is not initialized , then init that . bug 20097 2011-03-31
                    if (!tableNode.isInitialized()) {
                        tableNode.getChildren().get(0).getChildren();
                    }
                    // ~
                    setList.add(tableNode.getTdTable());
                }
            // if (object instanceof NamedColumnSet) {
            // NamedColumnSet set = (NamedColumnSet) object;
            // Connection tdProvider = ConnectionHelper.getTdDataProvider(TableHelper
            // .getParentCatalogOrSchema(set));
            // oldTdDataProvider = oldTdDataProvider == null ? tdProvider : oldTdDataProvider;
            // if (oldTdDataProvider != null && !oldTdDataProvider.equals(tdProvider)) {
            // MessageUI.openWarning(DefaultMessagesImpl
            // .getString("TableAnalysisDPSelectionPage.TableSelectWarning")); //$NON-NLS-1$
            // } else if (tdProvider != null && paraneter != null) {
            // setList.add(set);
            // paraneter.setTdDataProvider(oldTdDataProvider);
            // }
            // }
            }
            if (setList.size() > 0 && paraneter != null) {
                paraneter.setNamedColumnSets(setList.toArray(new NamedColumnSet[setList.size()]));
                DBTableRepNode recursiveFind = (DBTableRepNode) RepositoryNodeHelper.recursiveFind((TdTable) setList.get(0));
                RepositoryNode parent = recursiveFind.getParent().getParent();
                // MOD qiongli 2011-3-16 bug 19475
                RepositoryNode catalogNode = parent;
                if (parent instanceof DBCatalogRepNode) {
                    parent = parent.getParent();
                } else if (parent instanceof DBSchemaRepNode) {
                    parent = parent.getParent();
                    if (parent instanceof DBCatalogRepNode) {
                        catalogNode = parent;
                        parent = parent.getParent();
                    }
                }
                // TdTableRepositoryObject tableViewObject = (TdTableRepositoryObject) recursiveFind.getObject();
                // IRepositoryViewObject viewObject = parent.getObject();
                DBConnectionRepNode connNode = (DBConnectionRepNode) parent;
                paraneter.setConnectionRepNode(connNode);
                Connection connection = ConnectionHelper.getConnection((TdTable) setList.get(0));
                paraneter.setTdDataProvider(connection);
                List<IRepositoryNode> packagesNode = new ArrayList<IRepositoryNode>();
                packagesNode.add(catalogNode);
                paraneter.setPackages(packagesNode);
                setPageComplete(true);
            } else {
                setPageComplete(false);
            }
        }
    });
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) DBSchemaRepNode(org.talend.dq.nodes.DBSchemaRepNode) TdTable(org.talend.cwm.relational.TdTable) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Connection(org.talend.core.model.metadata.builder.connection.Connection) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) NamedColumnSetAnalysisParameter(org.talend.dq.analysis.parameters.NamedColumnSetAnalysisParameter) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) DBCatalogRepNode(org.talend.dq.nodes.DBCatalogRepNode) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ArrayList(java.util.ArrayList) List(java.util.List) NamedColumnSet(orgomg.cwm.resource.relational.NamedColumnSet)

Example 8 with DBConnectionRepNode

use of org.talend.dq.nodes.DBConnectionRepNode in project tdq-studio-se by Talend.

the class CatalogAnalysisDPSelectionPage method addListeners.

@Override
protected void addListeners() {
    addListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
            if (object instanceof Catalog) {
                advanceToNextPageOrFinish();
            }
        }
    });
    addListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            try {
                Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
                PackagesAnalyisParameter catalogPanameter = (PackagesAnalyisParameter) getConnectionParams();
                List<IRepositoryNode> nodes = new ArrayList<IRepositoryNode>();
                if (object instanceof DBCatalogRepNode) {
                    DBCatalogRepNode catalogNode = (DBCatalogRepNode) object;
                    Catalog catalog = ((MetadataCatalogRepositoryObject) catalogNode.getObject()).getCatalog();
                    Connection tdProvider = ConnectionHelper.getTdDataProvider(SwitchHelpers.PACKAGE_SWITCH.doSwitch(catalog));
                    nodes.add(catalogNode);
                    if (tdProvider != null && catalogPanameter != null) {
                        catalogPanameter.setTdDataProvider(tdProvider);
                        catalogPanameter.setConnectionRepNode((DBConnectionRepNode) catalogNode.getParent());
                        catalogPanameter.setPackages(nodes);
                    }
                    setPageComplete(true);
                } else {
                    setPageComplete(false);
                }
            } catch (Exception e) {
                log.error(e, e);
            }
        }
    });
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Connection(org.talend.core.model.metadata.builder.connection.Connection) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Catalog(orgomg.cwm.resource.relational.Catalog) DBCatalogRepNode(org.talend.dq.nodes.DBCatalogRepNode) PackagesAnalyisParameter(org.talend.dq.analysis.parameters.PackagesAnalyisParameter) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) MetadataCatalogRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataCatalogRepositoryObject) ArrayList(java.util.ArrayList) List(java.util.List)

Example 9 with DBConnectionRepNode

use of org.talend.dq.nodes.DBConnectionRepNode in project tdq-studio-se by Talend.

the class ImageLib method getImageNameByRepositoryNode.

public static String getImageNameByRepositoryNode(IRepositoryNode node) {
    String imageName = null;
    IRepositoryViewObject viewObject = node.getObject();
    ENodeType type = node.getType();
    if (node instanceof ReportAnalysisRepNode) {
        imageName = ImageLib.ANALYSIS_OBJECT;
    } else if (node instanceof RecycleBinRepNode) {
        imageName = ImageLib.RECYCLEBIN_EMPTY;
    } else if (type.equals(ENodeType.SYSTEM_FOLDER)) {
        String label = viewObject.getLabel();
        if (label.equals(EResourceConstant.DATA_PROFILING.getName())) {
            imageName = ImageLib.DATA_PROFILING;
        } else if (label.equals(EResourceConstant.METADATA.getName())) {
            imageName = ImageLib.METADATA;
        } else if (node instanceof DBConnectionFolderRepNode) {
            imageName = ImageLib.CONNECTION;
        } else if (label.equals(EResourceConstant.FILEDELIMITED.getName())) {
            imageName = ImageLib.FILE_DELIMITED;
        } else if (label.equals(EResourceConstant.HADOOP_CLUSTER.getName())) {
            imageName = ImageLib.HADOOP_CLUSTER;
        } else if (label.equals(EResourceConstant.LIBRARIES.getName())) {
            imageName = ImageLib.LIBRARIES;
        } else if (label.equals(EResourceConstant.EXCHANGE.getName())) {
            imageName = ImageLib.EXCHANGE;
        } else {
            imageName = ImageLib.FOLDERNODE_IMAGE;
        }
    } else if (type.equals(ENodeType.SIMPLE_FOLDER)) {
        imageName = ImageLib.FOLDERNODE_IMAGE;
    } else if (type.equals(ENodeType.REPOSITORY_ELEMENT)) {
        if (node instanceof DBConnectionRepNode) {
            imageName = ImageLib.TD_DATAPROVIDER;
        } else if (node instanceof DFConnectionRepNode) {
            imageName = ImageLib.FILE_DELIMITED;
        } else if (node instanceof AnalysisRepNode) {
            imageName = ImageLib.ANALYSIS_OBJECT;
        } else if (node instanceof ReportRepNode) {
            imageName = ImageLib.REPORT_OBJECT;
        } else if (node instanceof SysIndicatorDefinitionRepNode) {
            imageName = ImageLib.IND_DEFINITION;
        } else if (node instanceof PatternRepNode) {
            imageName = ImageLib.PATTERN_REG;
        } else if (node instanceof RuleRepNode) {
            imageName = ImageLib.DQ_RULE;
        } else if (node instanceof SourceFileRepNode) {
            imageName = ImageLib.SOURCE_FILE;
        } else if (node instanceof ExchangeCategoryRepNode || node instanceof ExchangeComponentRepNode) {
            imageName = ImageLib.EXCHANGE;
        } else if (node instanceof JrxmlTempleteRepNode) {
            imageName = ImageLib.JRXML_ICON;
        }
    } else if (type.equals(ENodeType.TDQ_REPOSITORY_ELEMENT)) {
        if (node instanceof DBCatalogRepNode) {
            imageName = ImageLib.CATALOG;
        } else if (node instanceof DBSchemaRepNode) {
            imageName = ImageLib.SCHEMA;
        } else if (node instanceof DBTableFolderRepNode) {
            imageName = ImageLib.FOLDERNODE_IMAGE;
        } else if (node instanceof DBViewFolderRepNode) {
            imageName = ImageLib.FOLDERNODE_IMAGE;
        } else if (node instanceof DBTableRepNode || node instanceof DFTableRepNode) {
            imageName = ImageLib.TABLE;
        } else if (node instanceof DBViewRepNode) {
            imageName = ImageLib.VIEW;
        } else if (node instanceof DBColumnRepNode) {
            if (((DBColumnRepNode) node).isKey()) {
                imageName = ImageLib.PK_COLUMN;
            } else {
                imageName = ImageLib.TD_COLUMN;
            }
        } else if (node instanceof DFColumnRepNode) {
            imageName = ImageLib.TD_COLUMN;
        } else if (node instanceof DBColumnFolderRepNode || node instanceof DFColumnFolderRepNode) {
            imageName = ImageLib.FOLDERNODE_IMAGE;
        }
    }
    return imageName;
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) SourceFileRepNode(org.talend.dq.nodes.SourceFileRepNode) DBViewFolderRepNode(org.talend.dq.nodes.DBViewFolderRepNode) DBCatalogRepNode(org.talend.dq.nodes.DBCatalogRepNode) ReportRepNode(org.talend.dq.nodes.ReportRepNode) ExchangeComponentRepNode(org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode) SysIndicatorDefinitionRepNode(org.talend.dq.nodes.SysIndicatorDefinitionRepNode) DFTableRepNode(org.talend.dq.nodes.DFTableRepNode) DBConnectionFolderRepNode(org.talend.dq.nodes.DBConnectionFolderRepNode) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) PatternRepNode(org.talend.dq.nodes.PatternRepNode) DBTableFolderRepNode(org.talend.dq.nodes.DBTableFolderRepNode) DFColumnFolderRepNode(org.talend.dq.nodes.DFColumnFolderRepNode) DBSchemaRepNode(org.talend.dq.nodes.DBSchemaRepNode) RuleRepNode(org.talend.dq.nodes.RuleRepNode) JrxmlTempleteRepNode(org.talend.dq.nodes.JrxmlTempleteRepNode) RecycleBinRepNode(org.talend.dq.nodes.RecycleBinRepNode) DBColumnFolderRepNode(org.talend.dq.nodes.DBColumnFolderRepNode) DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode) AnalysisRepNode(org.talend.dq.nodes.AnalysisRepNode) ExchangeCategoryRepNode(org.talend.dataprofiler.core.ui.exchange.ExchangeCategoryRepNode) DFConnectionRepNode(org.talend.dq.nodes.DFConnectionRepNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ENodeType(org.talend.repository.model.IRepositoryNode.ENodeType) ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode)

Example 10 with DBConnectionRepNode

use of org.talend.dq.nodes.DBConnectionRepNode in project tdq-studio-se by Talend.

the class DuplicateAction method refreshHiveConnectionParent.

/**
 * if the duplicate hive connection has its related hadoop cluster, need to refresh it.
 *
 * @param recursiveFind
 */
private void refreshHiveConnectionParent(RepositoryNode recursiveFind) {
    if (recursiveFind instanceof DBConnectionRepNode) {
        String hcId = ConnectionUtils.getHadoopClusterIDOfHive(recursiveFind.getObject());
        if (!StringUtils.isBlank(hcId)) {
            IRepositoryNode HClusterFolderNode = RepositoryNodeHelper.getMetadataFolderNode(EResourceConstant.HADOOP_CLUSTER);
            List<IRepositoryNode> children = HClusterFolderNode.getChildren();
            for (IRepositoryNode hcluster : children) {
                if (StringUtils.equals(hcId, hcluster.getId())) {
                    CorePlugin.getDefault().refreshDQView(hcluster);
                    break;
                }
            }
        }
    }
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Aggregations

DBConnectionRepNode (org.talend.dq.nodes.DBConnectionRepNode)26 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)14 IRepositoryNode (org.talend.repository.model.IRepositoryNode)12 DBCatalogRepNode (org.talend.dq.nodes.DBCatalogRepNode)9 Connection (org.talend.core.model.metadata.builder.connection.Connection)8 DBSchemaRepNode (org.talend.dq.nodes.DBSchemaRepNode)8 RepositoryNode (org.talend.repository.model.RepositoryNode)8 ArrayList (java.util.ArrayList)6 DBTableRepNode (org.talend.dq.nodes.DBTableRepNode)6 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)4 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)4 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)4 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)4 PersistenceException (org.talend.commons.exception.PersistenceException)4 DBColumnRepNode (org.talend.dq.nodes.DBColumnRepNode)4 DBConnectionFolderRepNode (org.talend.dq.nodes.DBConnectionFolderRepNode)4 DFConnectionRepNode (org.talend.dq.nodes.DFConnectionRepNode)4 List (java.util.List)3 Test (org.junit.Test)3 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)3