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