Search in sources :

Example 21 with DBViewRepNode

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

the class RepNodeUtilsTest method testIsValidSelectionForMatchAnalysis_2.

/**
 * Test: 2) when the selected nodes are: multiple table/views, multiple columns from different table/view, will not
 * be valid;
 */
@Test
public void testIsValidSelectionForMatchAnalysis_2() {
    List<IRepositoryNode> nodes = new ArrayList<IRepositoryNode>();
    DBTableRepNode table1 = mock(DBTableRepNode.class);
    DBTableRepNode table2 = mock(DBTableRepNode.class);
    nodes.clear();
    nodes.add(table1);
    nodes.add(table2);
    Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
    DBViewRepNode view1 = mock(DBViewRepNode.class);
    DBViewRepNode view2 = mock(DBViewRepNode.class);
    nodes.clear();
    nodes.add(view1);
    nodes.add(view2);
    Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
    ColumnRepNode col1 = mock(ColumnRepNode.class);
    ColumnRepNode col2 = mock(ColumnRepNode.class);
    when(col1.getParent()).thenReturn(table1);
    when(col2.getParent()).thenReturn(table2);
    nodes.clear();
    nodes.add(col1);
    nodes.add(col2);
    Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
}
Also used : ColumnRepNode(org.talend.dq.nodes.ColumnRepNode) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 22 with DBViewRepNode

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

the class AnalysisTableTreeViewer method setInput.

/**
 * DOC xqliu Comment method "setInput".
 *
 * @param objs
 */
@Override
public void setInput(Object[] objs) {
    List<DBTableRepNode> tableNodeList = RepositoryNodeHelper.getTableNodeList(objs);
    List<TableIndicator> tableIndicatorList = new ArrayList<TableIndicator>();
    // MOD by zshen for 2011.06.13 add the support for the view.
    List<DBViewRepNode> viewNodeList = RepositoryNodeHelper.getViewNodeList(objs);
    if (tableNodeList.size() == 0 && viewNodeList.size() == 0) {
        // feature 22206 : fixed another bug, when deselect all, the view is not changed
        this.tableIndicators = tableIndicatorList.toArray(new TableIndicator[tableIndicatorList.size()]);
        this.setElements(tableIndicators);
        return;
    }
    List<RepositoryNode> setList = new ArrayList<RepositoryNode>();
    Connection tdProvider = null;
    for (DBTableRepNode tableNode : tableNodeList) {
        if (tdProvider == null) {
            tdProvider = ConnectionHelper.getTdDataProvider(TableHelper.getParentCatalogOrSchema(tableNode.getTdTable()));
        }
        if (tdProvider == null) {
            MessageUI.openError(DefaultMessagesImpl.getString("AnalysisTableTreeViewer.TableProviderIsNull", // $NON-NLS-1$
            tableNode.getLabel()));
        } else if (this.getAnalysis().getContext().getConnection() != null && !tdProvider.equals(this.getAnalysis().getContext().getConnection())) {
            MessageUI.openError(DefaultMessagesImpl.getString("AnalysisTableTreeViewer.TableDataProviderIsInvalid", // $NON-NLS-1$
            tableNode.getLabel()));
        } else {
            setList.add(tableNode);
        }
    }
    for (DBViewRepNode tableNode : viewNodeList) {
        if (tdProvider == null) {
            tdProvider = ConnectionHelper.getTdDataProvider(TableHelper.getParentCatalogOrSchema(tableNode.getTdView()));
        }
        if (tdProvider == null) {
            MessageUI.openError(DefaultMessagesImpl.getString("AnalysisTableTreeViewer.TableProviderIsNull", // $NON-NLS-1$
            tableNode.getLabel()));
        } else if (this.getAnalysis().getContext().getConnection() != null && !tdProvider.equals(this.getAnalysis().getContext().getConnection())) {
            MessageUI.openError(DefaultMessagesImpl.getString("AnalysisTableTreeViewer.TableDataProviderIsInvalid", // $NON-NLS-1$
            tableNode.getLabel()));
        } else {
            setList.add(tableNode);
        }
    }
    for (TableIndicator tableIndicator : tableIndicators) {
        // ADDED yyin 20120606 TDQ-5343
        NamedColumnSet selectedTable = tableIndicator.getColumnSet();
        DQRepositoryNode tableNode = null;
        if (selectedTable instanceof TdTable) {
            tableNode = RepositoryNodeHelper.recursiveFindTdTable(((TdTable) selectedTable));
        } else if (selectedTable instanceof TdView) {
            tableNode = RepositoryNodeHelper.recursiveFindTdView(((TdView) selectedTable));
        }
        // ~
        if (setList.contains(tableNode)) {
            tableIndicatorList.add(tableIndicator);
            setList.remove(tableNode);
        }
    }
    for (RepositoryNode set : setList) {
        TableIndicator tableIndicator = null;
        if (set instanceof DBViewRepNode) {
            tableIndicator = TableIndicator.createTableIndicatorWithRowCountIndicator(((DBViewRepNode) set).getTdView());
        } else if (set instanceof DBTableRepNode) {
            tableIndicator = TableIndicator.createTableIndicatorWithRowCountIndicator(((DBTableRepNode) set).getTdTable());
        } else {
            continue;
        }
        tableIndicatorList.add(tableIndicator);
    }
    this.tableIndicators = tableIndicatorList.toArray(new TableIndicator[tableIndicatorList.size()]);
    this.setElements(tableIndicators);
}
Also used : TableIndicator(org.talend.dataprofiler.core.model.TableIndicator) TdTable(org.talend.cwm.relational.TdTable) ArrayList(java.util.ArrayList) Connection(org.talend.core.model.metadata.builder.connection.Connection) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) TdView(org.talend.cwm.relational.TdView) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) NamedColumnSet(orgomg.cwm.resource.relational.NamedColumnSet)

Example 23 with DBViewRepNode

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

the class TablesSelectionDialog method initCheckedColumnSet.

private void initCheckedColumnSet(List<IRepositoryNode> columnSetList) {
    List<IRepositoryNode> packageList = new ArrayList<IRepositoryNode>();
    for (IRepositoryNode columnSetNode : columnSetList) {
        if (columnSetNode instanceof DBTableRepNode) {
            DBTableRepNode tableRepNode = (DBTableRepNode) columnSetNode;
            // MOD qiongli 2012-5-4 TDQ-5137 use the table parent(DBTableFolderRepNode not DBCatalogRepNode or
            // DBSchemaRepNode).
            IRepositoryNode parentPackageNode = tableRepNode.getParent();
            if (parentPackageNode != null) {
                if (!packageList.contains(parentPackageNode)) {
                    packageList.add(parentPackageNode);
                }
                RepositoryNodeKey packageKey = new RepositoryNodeKey(parentPackageNode);
                List<IRepositoryNode> repoNodelist = packageCheckedMap.get(packageKey);
                if (repoNodelist == null) {
                    repoNodelist = new ArrayList<IRepositoryNode>();
                    this.packageCheckedMap.put(packageKey, repoNodelist);
                }
                repoNodelist.add(tableRepNode);
            }
        } else if (columnSetNode instanceof DBViewRepNode) {
            // support DBview
            DBViewRepNode viewRepNode = (DBViewRepNode) columnSetNode;
            IRepositoryNode parentPackageNode = viewRepNode.getParent();
            if (parentPackageNode != null) {
                if (!packageList.contains(parentPackageNode)) {
                    packageList.add(parentPackageNode);
                }
                RepositoryNodeKey packageKey = new RepositoryNodeKey(parentPackageNode);
                List<IRepositoryNode> repoNodelist = packageCheckedMap.get(packageKey);
                if (repoNodelist == null) {
                    repoNodelist = new ArrayList<IRepositoryNode>();
                    this.packageCheckedMap.put(packageKey, repoNodelist);
                }
                repoNodelist.add(viewRepNode);
            }
        }
    }
    this.setInitialElementSelections(packageList);
}
Also used : DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode)

Example 24 with DBViewRepNode

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

the class ColumnsSelectionDialog method selectionChanged.

public void selectionChanged(SelectionChangedEvent event) {
    // MOD klliu 2011-01-27 15750 todo 31
    RepositoryNode selectedObj = (RepositoryNode) ((IStructuredSelection) event.getSelection()).getFirstElement();
    if (selectedObj != null) {
        if (selectedObj.hasChildren()) {
            this.selectedTreeRepoNode = selectedObj;
            this.setOutput(selectedObj);
            Boolean allCheckFlag = this.getTreeViewer().getChecked(selectedObj);
            List<?> repositoryNodeList = (List<?>) modelElementCheckedMap.get(selectedObj);
            if (repositoryNodeList != null) {
                this.getTableViewer().setCheckedElements(repositoryNodeList.toArray());
            } else // MOD klliu check Table/View node is select
            if (selectedObj instanceof DBTableRepNode || selectedObj instanceof DBViewRepNode || selectedObj instanceof DFTableRepNode) {
                if (allCheckFlag) {
                    this.getTableViewer().setCheckedElements(selectedObj.getChildren().get(0).getChildren().toArray());
                }
            }
        // ~
        }
    }
}
Also used : DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) DFTableRepNode(org.talend.dq.nodes.DFTableRepNode) ArrayList(java.util.ArrayList) List(java.util.List) RepositoryNode(org.talend.repository.model.RepositoryNode) DQDBFolderRepositoryNode(org.talend.dq.nodes.DQDBFolderRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode)

Example 25 with DBViewRepNode

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

the class MetaDataFilterProvider method fillContextMenu.

@Override
public void fillContextMenu(IMenuManager menu) {
    // MOD mzhao user readonly role on svn repository mode.
    if (!isShowMenu()) {
        return;
    }
    TreeSelection currentSelection = ((TreeSelection) this.getContext().getSelection());
    Object firstElement = currentSelection.getFirstElement();
    if (firstElement instanceof IRepositoryNode) {
        IRepositoryNode node = (IRepositoryNode) firstElement;
        if (node instanceof DBConnectionRepNode) {
            PackageFilterAction packageFilterAction = new PackageFilterAction(node);
            menu.add(packageFilterAction);
        } else if (node instanceof DBTableRepNode || node instanceof DBViewRepNode) {
            ColumnFilterAction ecfAction = new ColumnFilterAction(node);
            menu.add(ecfAction);
        }
    }
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) TreeSelection(org.eclipse.jface.viewers.TreeSelection) ColumnFilterAction(org.talend.dataprofiler.core.ui.action.actions.ColumnFilterAction) PackageFilterAction(org.talend.dataprofiler.core.ui.action.actions.PackageFilterAction) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode)

Aggregations

DBViewRepNode (org.talend.dq.nodes.DBViewRepNode)25 DBTableRepNode (org.talend.dq.nodes.DBTableRepNode)21 IRepositoryNode (org.talend.repository.model.IRepositoryNode)16 ArrayList (java.util.ArrayList)11 DFTableRepNode (org.talend.dq.nodes.DFTableRepNode)11 RepositoryNode (org.talend.repository.model.RepositoryNode)8 DBColumnRepNode (org.talend.dq.nodes.DBColumnRepNode)7 TreeSelection (org.eclipse.jface.viewers.TreeSelection)6 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5 DFColumnRepNode (org.talend.dq.nodes.DFColumnRepNode)5 List (java.util.List)4 Test (org.junit.Test)4 ExchangeComponentRepNode (org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode)4 AnalysisRepNode (org.talend.dq.nodes.AnalysisRepNode)4 DBCatalogRepNode (org.talend.dq.nodes.DBCatalogRepNode)4 DBConnectionRepNode (org.talend.dq.nodes.DBConnectionRepNode)4 DBSchemaRepNode (org.talend.dq.nodes.DBSchemaRepNode)4 DFConnectionRepNode (org.talend.dq.nodes.DFConnectionRepNode)4 RuleRepNode (org.talend.dq.nodes.RuleRepNode)4 TreeItem (org.eclipse.swt.widgets.TreeItem)3