use of org.talend.dq.nodes.DBConnectionRepNode in project tdq-studio-se by Talend.
the class DBConnectionDuplicateHandleTest method createConnectionNode.
/**
* DOC zshen Comment method "createConnectionNode".
*
* @return
*/
private RepositoryNode createConnectionNode(DatabaseConnectionItem createConnectionItem) {
IRepositoryViewObject connectionViewObject = null;
try {
connectionViewObject = factory.getLastVersion(createConnectionItem.getProperty().getId());
} catch (PersistenceException e) {
Assert.fail(e.getMessage());
}
RepositoryNode dbParentRepNode = new DBConnectionRepNode(connectionViewObject, null, ENodeType.REPOSITORY_ELEMENT, null);
return dbParentRepNode;
}
use of org.talend.dq.nodes.DBConnectionRepNode 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.DBConnectionRepNode 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.DBConnectionRepNode in project tdq-studio-se by Talend.
the class ConnectionEditor method doSave.
@Override
public void doSave(IProgressMonitor monitor) {
if (masterPage.isDirty()) {
masterPage.doSave(monitor);
setPartName(masterPage.getIntactElemenetName());
// MOD qiongli 2012-11-29 avoid item is proxy(get item form IRepositoryViewObject).
ConnectionRepNode connectionRepNode = ((ConnectionInfoPage) getMasterPage()).getCurrentRepNode();
if (connectionRepNode != null && connectionRepNode instanceof DBConnectionRepNode) {
IRepositoryViewObject object = connectionRepNode.getObject();
if (object != null) {
ConnectionItem item = (ConnectionItem) object.getProperty().getItem();
String name = ((DatabaseConnectionItem) item).getConnection().getName();
CWMPlugin.getDefault().updateConnetionAliasByName(item.getConnection(), masterPage.getOldDataproviderName());
masterPage.setOldDataproviderName(name);
}
}
// refresh the analysis editor
if (masterPage.isNameTextUpdate()) {
WorkbenchUtils.nodifyDependedAnalysis((ConnectionItem) connectionRepNode.getObject().getProperty().getItem());
// WorkbenchUtils.refreshCurrentAnalysisEditor();
masterPage.setModify(false);
// TDQ-11312
if (this.getEditorInput() instanceof FileEditorInput) {
this.setInput(masterPage.getEditorInput());
}
}
}
setEditorObject(((ConnectionInfoPage) getMasterPage()).getCurrentRepNode());
super.doSave(monitor);
}
use of org.talend.dq.nodes.DBConnectionRepNode in project tdq-studio-se by Talend.
the class ConnectionInfoPage method changeConnectionInformations.
/**
* Change connection informations with server, port etc., and update related analyses.
*
* MOD yyi 9082 2010-02-25
*/
protected void changeConnectionInformations() {
DBConnectionRepNode node = getCurrentRepNode();
if (node != null) {
IWizard wizard = new DatabaseWizard(PlatformUI.getWorkbench(), false, node, null);
WizardDialog dialog = new WizardDialog(null, wizard);
dialog.setPageSize(780, 550);
wizard.setContainer(dialog);
dialog.open();
}
}
Aggregations