Search in sources :

Example 1 with DBCatalogRepNode

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

the class RepNodeUtilsTest method testIsValidSelectionForMatchAnalysis.

/**
 * Test: 1) when the selected node is: connection, catalog,schema, folder, will not be valid; 2) when the selected
 * nodes are: multiple table/views, multiple columns from different table/view, will not be valid; 3) when the
 * selected node is: one single table/view/file table,will be valid; 4) when the selected nodes are: multiple
 * columns from one same table/view, will be valid.
 */
@Test
public void testIsValidSelectionForMatchAnalysis() {
    // 1) when the selected node is: connection, catalog,schema, folder, will not be valid;
    List<IRepositoryNode> nodes = new ArrayList<IRepositoryNode>();
    ConnectionRepNode cNode = mock(ConnectionRepNode.class);
    nodes.add(cNode);
    Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
    DBConnectionRepNode dbNode = mock(DBConnectionRepNode.class);
    nodes.clear();
    nodes.add(dbNode);
    Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
    DBConnectionFolderRepNode dbfNode = mock(DBConnectionFolderRepNode.class);
    nodes.clear();
    nodes.add(dbfNode);
    Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
    DQDBFolderRepositoryNode folderNode = mock(DQDBFolderRepositoryNode.class);
    nodes.clear();
    nodes.add(folderNode);
    Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
    DBCatalogRepNode catalogNode = mock(DBCatalogRepNode.class);
    nodes.clear();
    nodes.add(catalogNode);
    Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
    DBSchemaRepNode schemaNode = mock(DBSchemaRepNode.class);
    nodes.clear();
    nodes.add(schemaNode);
    Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) ConnectionRepNode(org.talend.dq.nodes.ConnectionRepNode) DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) DBSchemaRepNode(org.talend.dq.nodes.DBSchemaRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) DBCatalogRepNode(org.talend.dq.nodes.DBCatalogRepNode) ArrayList(java.util.ArrayList) DQDBFolderRepositoryNode(org.talend.dq.nodes.DQDBFolderRepositoryNode) DBConnectionFolderRepNode(org.talend.dq.nodes.DBConnectionFolderRepNode) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with DBCatalogRepNode

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

the class SelectedCompareUIProvider method fillContextMenu.

@Override
public void fillContextMenu(IMenuManager menu) {
    // TDQ-9394 hide all "Reload" menu.
    if (!isShowMenu()) {
        return;
    }
    if (isShowMenu()) {
        return;
    }
    Iterator<?> iter = ((TreeSelection) this.getContext().getSelection()).iterator();
    while (iter.hasNext()) {
        Object obj = iter.next();
        if (!(obj instanceof RepositoryNode)) {
            return;
        }
    }
    TreeSelection treeSelection = (TreeSelection) getContext().getSelection();
    if (treeSelection == null) {
        return;
    }
    Object firstElement = treeSelection.getFirstElement();
    RepositoryNode rNode = (RepositoryNode) firstElement;
    IFolder folder = WorkbenchUtils.getFolder(rNode);
    IFolder metadataFolder = ResourceManager.getMetadataFolder();
    if (!folder.getFullPath().toOSString().startsWith(metadataFolder.getFullPath().toOSString())) {
        return;
    }
    Object[] selectedObj = treeSelection.toArray();
    if (selectedObj.length < 2) {
        return;
    }
    List<Object> objects = new ArrayList<Object>();
    for (Object obj : selectedObj) {
        Connection conn = getConnection(obj);
        if (!MetadataConnectionUtils.isTDQSupportDBTemplate(conn)) {
            return;
        }
        RepositoryNode node = (RepositoryNode) obj;
        if (node instanceof DBConnectionRepNode) {
            Property property = ((DBConnectionRepNode) node).getObject().getProperty();
            DatabaseConnectionItem databaseConnectionItem = (DatabaseConnectionItem) property.getItem();
            Connection databaseConnection = databaseConnectionItem.getConnection();
            objects.add(databaseConnection);
        } else if (node instanceof DBCatalogRepNode) {
            Catalog catalog = ((DBCatalogRepNode) node).getCatalog();
            objects.add(catalog);
        } else if (node instanceof DBSchemaRepNode) {
            Schema schema = ((DBSchemaRepNode) node).getSchema();
            objects.add(schema);
        } else if (node instanceof DBTableRepNode) {
            TdTable tdTable = ((DBTableRepNode) node).getTdTable();
            objects.add(tdTable);
        } else if (node instanceof DBColumnRepNode) {
            TdColumn tdColumn = ((DBColumnRepNode) node).getTdColumn();
            objects.add(tdColumn);
        }
    }
    // MOD yyi 2011-03-22 17871:hide compare action for flat file column
    if (2 == objects.size()) {
        selectionCompareAction.refreshSelectedObj(objects.get(0), objects.get(1));
        menu.add(selectionCompareAction);
    }
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) DBSchemaRepNode(org.talend.dq.nodes.DBSchemaRepNode) TdTable(org.talend.cwm.relational.TdTable) Schema(orgomg.cwm.resource.relational.Schema) ArrayList(java.util.ArrayList) Connection(org.talend.core.model.metadata.builder.connection.Connection) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) RepositoryNode(org.talend.repository.model.RepositoryNode) Catalog(orgomg.cwm.resource.relational.Catalog) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) TdColumn(org.talend.cwm.relational.TdColumn) DBCatalogRepNode(org.talend.dq.nodes.DBCatalogRepNode) TreeSelection(org.eclipse.jface.viewers.TreeSelection) Property(org.talend.core.model.properties.Property) IFolder(org.eclipse.core.resources.IFolder)

Example 3 with DBCatalogRepNode

use of org.talend.dq.nodes.DBCatalogRepNode 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 4 with DBCatalogRepNode

use of org.talend.dq.nodes.DBCatalogRepNode 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 5 with DBCatalogRepNode

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

the class ColumnAnalysisDOSelectionPage method addListeners.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.core.ui.wizard.analysis.AnalysisDPSelectionPage#addListeners()
     */
@Override
protected void addListeners() {
    addListener(new IDoubleClickListener() {

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

        public void selectionChanged(SelectionChangedEvent event) {
            try {
                Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
                nodes = new ArrayList<IRepositoryNode>();
                if (object instanceof IRepositoryNode) {
                    List<IRepositoryNode> list = ((IStructuredSelection) event.getSelection()).toList();
                    nodes.addAll(list);
                    updateCompleteState();
                    notifyObservers();
                } else {
                    setPageComplete(false);
                }
            } catch (Exception e) {
                log.error(e, e);
            }
        }
    });
}
Also used : DBCatalogRepNode(org.talend.dq.nodes.DBCatalogRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ArrayList(java.util.ArrayList) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

DBCatalogRepNode (org.talend.dq.nodes.DBCatalogRepNode)17 DBSchemaRepNode (org.talend.dq.nodes.DBSchemaRepNode)13 IRepositoryNode (org.talend.repository.model.IRepositoryNode)11 DBConnectionRepNode (org.talend.dq.nodes.DBConnectionRepNode)9 ArrayList (java.util.ArrayList)8 DBTableRepNode (org.talend.dq.nodes.DBTableRepNode)6 RepositoryNode (org.talend.repository.model.RepositoryNode)6 List (java.util.List)5 Connection (org.talend.core.model.metadata.builder.connection.Connection)5 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5 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 ExchangeComponentRepNode (org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode)4 PackagesAnalyisParameter (org.talend.dq.analysis.parameters.PackagesAnalyisParameter)4 DBColumnRepNode (org.talend.dq.nodes.DBColumnRepNode)4 Catalog (orgomg.cwm.resource.relational.Catalog)4 ExchangeCategoryRepNode (org.talend.dataprofiler.core.ui.exchange.ExchangeCategoryRepNode)3 AnalysisRepNode (org.talend.dq.nodes.AnalysisRepNode)3