Search in sources :

Example 26 with DBTableRepNode

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

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

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

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

the class ColumnFilterAction method run.

@Override
public void run() {
    ColumnFilterWizard wizard = new ColumnFilterWizard(this.namedColumnSet);
    WizardDialog dialog = new WizardDialog(null, wizard);
    dialog.setPageSize(WIDTH, HEIGHT);
    if (dialog.open() == Dialog.OK) {
        // MOD klliu if set the column filter, need to clear the cashe children of Table node.
        if (node instanceof DBTableRepNode) {
            ((DBTableRepNode) node).getCasheChildren().clear();
        }
        CorePlugin.getDefault().refreshDQView(node);
    }
}
Also used : DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) ColumnFilterWizard(org.talend.dataprofiler.core.ui.wizard.database.ColumnFilterWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 30 with DBTableRepNode

use of org.talend.dq.nodes.DBTableRepNode 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)

Aggregations

DBTableRepNode (org.talend.dq.nodes.DBTableRepNode)31 DBViewRepNode (org.talend.dq.nodes.DBViewRepNode)21 IRepositoryNode (org.talend.repository.model.IRepositoryNode)18 ArrayList (java.util.ArrayList)13 RepositoryNode (org.talend.repository.model.RepositoryNode)12 DFTableRepNode (org.talend.dq.nodes.DFTableRepNode)11 DBColumnRepNode (org.talend.dq.nodes.DBColumnRepNode)9 TreeSelection (org.eclipse.jface.viewers.TreeSelection)8 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)7 TdTable (org.talend.cwm.relational.TdTable)6 DBCatalogRepNode (org.talend.dq.nodes.DBCatalogRepNode)6 DBConnectionRepNode (org.talend.dq.nodes.DBConnectionRepNode)6 DBSchemaRepNode (org.talend.dq.nodes.DBSchemaRepNode)6 DFColumnRepNode (org.talend.dq.nodes.DFColumnRepNode)6 List (java.util.List)5 Test (org.junit.Test)5 PatternRepNode (org.talend.dq.nodes.PatternRepNode)5 SysIndicatorDefinitionRepNode (org.talend.dq.nodes.SysIndicatorDefinitionRepNode)5 TreeItem (org.eclipse.swt.widgets.TreeItem)4 DBColumnFolderRepNode (org.talend.dq.nodes.DBColumnFolderRepNode)4