use of org.talend.dq.nodes.DBConnectionRepNode in project tdq-studio-se by Talend.
the class SetJDBCDriverPreferencePage method createConnSelectDialog.
private CheckedTreeSelectionDialog createConnSelectDialog() {
RepositoryNode node = (RepositoryNode) RepositoryNodeHelper.getMetadataFolderNode(EResourceConstant.DB_CONNECTIONS);
CheckedTreeSelectionDialog dialog = new CheckedTreeSelectionDialog(getShell(), new DQRepositoryViewLabelProvider(), new ResourceViewContentProvider());
dialog.setInput(node);
dialog.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof DBConnectionRepNode) {
return isJdbcConnectionNode((DBConnectionRepNode) element);
} else if (element instanceof DBConnectionSubFolderRepNode) {
return hasJdbcConnNodeChild((DBConnectionSubFolderRepNode) element);
}
return false;
}
});
dialog.setValidator(new ISelectionStatusValidator() {
public IStatus validate(Object[] selection) {
for (Object object : selection) {
if (object instanceof DBConnectionRepNode) {
IRepositoryViewObject nodeObject = ((DBConnectionRepNode) object).getObject();
// when it's locked, can not modify
if (nodeObject != null && nodeObject.getProperty() != null && nodeObject.getProperty().getItem() != null && (nodeObject.getRepositoryStatus() == ERepositoryStatus.LOCK_BY_OTHER || nodeObject.getRepositoryStatus() == ERepositoryStatus.LOCK_BY_USER || RepositoryManager.isOpenedItemInEditor(nodeObject))) {
String displayName = nodeObject.getProperty().getDisplayName();
String version = nodeObject.getProperty().getVersion();
return new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, DefaultMessagesImpl.getString("SetJDBCDriverPreferencePage.isLocked", // $NON-NLS-1$ //$NON-NLS-2$
displayName + " " + version));
}
}
}
return new // $NON-NLS-1$
Status(// $NON-NLS-1$
IStatus.OK, // $NON-NLS-1$
PlatformUI.PLUGIN_ID, // $NON-NLS-1$
IStatus.OK, // $NON-NLS-1$
"", null);
}
});
dialog.setContainerMode(true);
// $NON-NLS-1$
dialog.setTitle(DefaultMessagesImpl.getString("SetJDBCDriverPreferencePage.selectConnectionButton"));
// $NON-NLS-1$
dialog.setMessage(DefaultMessagesImpl.getString("SetJDBCDriverPreferencePage.ApplytoConnectionEditors"));
dialog.setSize(80, 30);
return dialog;
}
use of org.talend.dq.nodes.DBConnectionRepNode in project tdq-studio-se by Talend.
the class AbstractCommonActionProviderRealProjectTest method testGetConnectionCase3.
/**
* Test method for
* {@link org.talend.dataprofiler.core.ui.action.provider.AbstractCommonActionProvider#getConnection(java.lang.Object)}
* . case3 :input parameter is DBConnectionRepNode
*/
@Test
public void testGetConnectionCase3() {
// create FileConnection
// connection
IRepositoryViewObject lastVersion = null;
String propertyID = createConnectionItem(connectionName, null, null);
try {
lastVersion = factory.getLastVersion(propertyID);
} catch (PersistenceException e) {
log.error(e, e);
Assert.fail(e.getMessage());
}
// ~connection data
// ~FileConnection
// create DFColumnFolderRepNode
Assert.assertFalse(lastVersion == null);
DBConnectionRepNode dbConnRepNode = new DBConnectionRepNode(lastVersion, null, null, null);
// ~DFColumnFolderRepNode
AbstractCommonActionProvider provider = new AbstractCommonActionProvider();
Connection connection = provider.getConnection(dbConnRepNode);
Assert.assertTrue(connection != null);
}
use of org.talend.dq.nodes.DBConnectionRepNode in project tdq-studio-se by Talend.
the class AbstractCommonActionProviderTest method createConnectionNode.
private RepositoryNode createConnectionNode(String name, IFolder folder, boolean isDelete) {
IPath createPath = Path.EMPTY;
if (folder != null) {
createPath = new Path(folder.getFullPath().lastSegment());
}
// connection
DatabaseConnection createConnection = ConnectionFactory.eINSTANCE.createDatabaseConnection();
createConnection.setName(name);
// $NON-NLS-1$
createConnection.setUsername("UserName");
// $NON-NLS-1$
createConnection.setRawPassword("Password");
// $NON-NLS-1$
createConnection.setURL("URL");
createConnection.setDatabaseType(EDatabaseTypeName.MYSQL.getXmlName());
createConnection.setContextMode(true);
// ~connection
DatabaseConnectionItem createDatabaseConnectionItem = PropertiesFactory.eINSTANCE.createDatabaseConnectionItem();
org.talend.core.model.properties.Property createDatabaseConnectionProperty = PropertiesFactory.eINSTANCE.createProperty();
createDatabaseConnectionProperty.setId(EcoreUtil.generateUUID());
createDatabaseConnectionProperty.setItem(createDatabaseConnectionItem);
createDatabaseConnectionProperty.setLabel(createConnection.getName());
createDatabaseConnectionItem.setProperty(createDatabaseConnectionProperty);
createDatabaseConnectionItem.setConnection(createConnection);
ItemState createItemState = PropertiesFactory.eINSTANCE.createItemState();
createItemState.setDeleted(isDelete);
createDatabaseConnectionItem.setState(createItemState);
IRepositoryViewObject repViewObject = null;
try {
factory.create(createDatabaseConnectionItem, createPath, false);
repViewObject = factory.getLastVersion(createDatabaseConnectionProperty.getId());
} catch (PersistenceException e) {
Assert.fail(e.getMessage());
}
RepositoryNode dbConnRepNode = new DBConnectionRepNode(repViewObject, null, ENodeType.TDQ_REPOSITORY_ELEMENT, null);
return dbConnRepNode;
}
use of org.talend.dq.nodes.DBConnectionRepNode in project tdq-studio-se by Talend.
the class SchemaAnalysisDPSelectionPage method addListeners.
@Override
protected void addListeners() {
addListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
if (object instanceof Schema) {
advanceToNextPageOrFinish();
}
}
});
addListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
PackagesAnalyisParameter schemaPanameter = (PackagesAnalyisParameter) getConnectionParams();
List<IRepositoryNode> nodes = new ArrayList<IRepositoryNode>();
if (object instanceof DBSchemaRepNode) {
DBSchemaRepNode schemaNode = (DBSchemaRepNode) object;
Schema schema = ((MetadataSchemaRepositoryObject) schemaNode.getObject()).getSchema();
Connection tdProvider = ConnectionHelper.getTdDataProvider(SwitchHelpers.PACKAGE_SWITCH.doSwitch(schema));
RepositoryNode parent = schemaNode.getParent();
if (tdProvider != null && schemaPanameter != null) {
if (parent instanceof DBCatalogRepNode) {
schemaPanameter.setConnectionRepNode((DBConnectionRepNode) parent.getParent());
} else {
schemaPanameter.setConnectionRepNode((DBConnectionRepNode) parent);
}
schemaPanameter.setTdDataProvider(tdProvider);
}
nodes.add(schemaNode);
schemaPanameter.setPackages(nodes);
setPageComplete(true);
} else {
setPageComplete(false);
}
}
});
}
use of org.talend.dq.nodes.DBConnectionRepNode in project tdq-studio-se by Talend.
the class ConnAnalysisDPSelectionPage method addListeners.
@Override
protected void addListeners() {
addListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
if (object instanceof IFile) {
IFile file = (IFile) object;
if (file.getParent() != null) {
advanceToNextPageOrFinish();
}
}
}
});
addListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
// get the dataprovider from the seleted connection
Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
AnalysisFilterParameter connPanameter = (AnalysisFilterParameter) getConnectionParams();
if (object instanceof DBConnectionRepNode) {
DBConnectionRepNode connNode = (DBConnectionRepNode) object;
IRepositoryViewObject reposViewObj = connNode.getObject();
Connection connection = ((ConnectionItem) reposViewObj.getProperty().getItem()).getConnection();
if (connection != null && connPanameter != null) {
connPanameter.setTdDataProvider(connection);
connPanameter.setConnectionRepNode(connNode);
}
setPageComplete(true);
} else {
setPageComplete(false);
}
}
});
}
Aggregations