use of org.talend.dq.nodes.DBSchemaRepNode in project tdq-studio-se by Talend.
the class AbstractCommonActionProviderRealProjectTest method testGetConnectionCase5.
/**
* Test method for
* {@link org.talend.dataprofiler.core.ui.action.provider.AbstractCommonActionProvider#getConnection(java.lang.Object)}
* . case5 :input parameter is DBSchemaRepNode
*/
@Test
public void testGetConnectionCase5() {
// create FileConnection
// connection
IRepositoryViewObject lastVersion = null;
String propertyID = createConnectionItem(connectionName, null, null);
// $NON-NLS-1$
Schema createSchema = createSchema("Schema1");
try {
lastVersion = factory.getLastVersion(propertyID);
lastVersion = new MetadataSchemaRepositoryObject(lastVersion, createSchema);
} catch (PersistenceException e) {
log.error(e, e);
Assert.fail(e.getMessage());
}
// ~connection data
// ~FileConnection
// create DFColumnFolderRepNode
Assert.assertFalse(lastVersion == null);
DBSchemaRepNode dbSchemaRepNode = new DBSchemaRepNode(lastVersion, null, null, null);
// ~DFColumnFolderRepNode
AbstractCommonActionProvider provider = new AbstractCommonActionProvider();
Connection connection = provider.getConnection(dbSchemaRepNode);
Assert.assertTrue(connection != null);
}
use of org.talend.dq.nodes.DBSchemaRepNode 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.DBSchemaRepNode 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.DBSchemaRepNode in project tdq-studio-se by Talend.
the class SchemaAnalysisWizard method initCWMResourceBuilder.
@Override
public ModelElement initCWMResourceBuilder() {
Analysis analysis = (Analysis) super.initCWMResourceBuilder();
if (getAnalysisBuilder() != null) {
// MOD klliu 15750 2011-1-05 add the repnode on parameter
PackagesAnalyisParameter packageParameter = getParameter();
IRepositoryNode connectionRepNode = getParameter().getConnectionRepNode();
ConnectionItem item = (ConnectionItem) connectionRepNode.getObject().getProperty().getItem();
Connection tdProvider = item.getConnection();
// Connection tdProvider = packageParameter.getTdDataProvider();
getAnalysisBuilder().setAnalysisConnection(tdProvider);
Indicator[] indicators = new Indicator[packageParameter.getPackages().size()];
ModelElement[] modelElement = new ModelElement[packageParameter.getPackages().size()];
int i = 0;
for (IRepositoryNode node : packageParameter.getPackages()) {
SchemaIndicator createSchemaIndicator = SchemaFactory.eINSTANCE.createSchemaIndicator();
DBSchemaRepNode catalogNode = (DBSchemaRepNode) node;
Schema schema = ((MetadataSchemaRepositoryObject) catalogNode.getObject()).getSchema();
modelElement[i] = schema;
DefinitionHandler.getInstance().setDefaultIndicatorDefinition(createSchemaIndicator);
createSchemaIndicator.setAnalyzedElement(schema);
indicators[i] = createSchemaIndicator;
i++;
}
getAnalysisBuilder().addElementsToAnalyze(modelElement, indicators);
}
return analysis;
}
use of org.talend.dq.nodes.DBSchemaRepNode 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);
}
}
});
}
Aggregations