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));
}
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);
}
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);
}
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);
}
}
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());
}
}
// ~
}
}
}
Aggregations