use of org.talend.core.ui.services.ISQLBuilderService in project tdi-studio-se by Talend.
the class AbstractElementPropertySectionController method openSqlBuilderBuildIn.
public void openSqlBuilderBuildIn(final ConnectionParameters connParameters, final String propertyName) {
ISQLBuilderService service = (ISQLBuilderService) GlobalServiceRegister.getDefault().getService(ISQLBuilderService.class);
service.openSQLBuilderDialog(connParameters, composite, elem, propertyName, getCommandStack(), this, part);
}
use of org.talend.core.ui.services.ISQLBuilderService in project tdi-studio-se by Talend.
the class GuessSchemaController method runShadowProcessForPerl.
private void runShadowProcessForPerl() {
final ProgressMonitorDialog pmd = new ProgressMonitorDialog(this.composite.getShell());
try {
pmd.run(true, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
if (columns != null) {
columns.clear();
}
//$NON-NLS-1$
monitor.beginTask(Messages.getString("GuessSchemaController.waitOpenDatabase"), IProgressMonitor.UNKNOWN);
if (connParameters == null) {
initConnectionParameters();
}
ISQLBuilderService service = (ISQLBuilderService) GlobalServiceRegister.getDefault().getService(ISQLBuilderService.class);
DatabaseConnection connt = service.createConnection(connParameters);
IMetadataConnection iMetadataConnection = null;
boolean isStatus = false;
ExtractMetaDataUtils extractMeta = ExtractMetaDataUtils.getInstance();
if (connt != null) {
iMetadataConnection = ConvertionHelper.convert(connt);
isStatus = checkConnection(iMetadataConnection);
}
if (!monitor.isCanceled()) {
try {
if (isStatus) {
extractMeta.getConnection(iMetadataConnection.getDbType(), iMetadataConnection.getUrl(), iMetadataConnection.getUsername(), iMetadataConnection.getPassword(), iMetadataConnection.getDatabase(), iMetadataConnection.getSchema(), iMetadataConnection.getDriverClass(), iMetadataConnection.getDriverJarPath(), iMetadataConnection.getDbVersionString(), iMetadataConnection.getAdditionalParams());
if (extractMeta.getConn() != null) {
Statement smst = extractMeta.getConn().createStatement();
extractMeta.setQueryStatementTimeout(smst);
ResultSet rs = smst.executeQuery(memoSQL);
ResultSetMetaData rsmd = rs.getMetaData();
int numbOfColumn = rsmd.getColumnCount();
int count = 0;
List<String[]> cvsArrays = new ArrayList<String[]>();
while (rs.next() && count < 50) {
String[] dataOneRow = new String[numbOfColumn];
for (int i = 1; i <= numbOfColumn; i++) {
String tempStr = rs.getString(i);
dataOneRow[i - 1] = tempStr;
}
cvsArrays.add(dataOneRow);
count++;
}
refreshMetaDataTable(rsmd, cvsArrays);
extractMeta.closeConnection();
}
} else {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
//$NON-NLS-1$
String pid = "org.talend.sqlbuilder";
//$NON-NLS-1$
String mainMsg = "Database connection is failed. ";
ErrorDialogWithDetailAreaAndContinueButton dialog = new ErrorDialogWithDetailAreaAndContinueButton(composite.getShell(), pid, mainMsg, connParameters.getConnectionComment());
if (dialog.getCodeOfButton() == Window.OK) {
openParamemerDialog(composite.getShell(), part.getProcess().getContextManager());
}
}
});
}
} catch (Exception e) {
extractMeta.closeConnection();
ExceptionHandler.process(e);
final String strExcepton = "Connect to DB error ,or some errors in SQL query string, or 'Guess Schema' not compatible with current SQL query string." + System.getProperty("line.separator");
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
MessageDialog.openWarning(composite.getShell(), Messages.getString("GuessSchemaController.connError"), //$NON-NLS-1$
strExcepton);
}
});
}
}
}
});
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
use of org.talend.core.ui.services.ISQLBuilderService in project tdi-studio-se by Talend.
the class SqlMemoController method refreshConnectionCommand.
private Command refreshConnectionCommand() {
// open sql builder in repository mode, just use query object, no need for connection information
ConnectionParameters connParameters = new ConnectionParameters();
String queryId = (String) elem.getPropertyValue(EParameterName.REPOSITORY_QUERYSTORE_TYPE.getName());
Query query = MetadataToolHelper.getQueryFromRepository(queryId);
DatabaseConnectionItem item = findRepositoryItem(queryId);
if (item != null) {
connParameters.setRepositoryName(item.getProperty().getLabel());
connParameters.setRepositoryId(item.getProperty().getId());
}
connParameters.setQueryObject(query);
connParameters.setQuery(query.getValue());
TextUtil.setDialogTitle(TextUtil.SQL_BUILDER_TITLE_REP);
String processName = null;
if (elem instanceof IProcess) {
processName = ((IProcess) elem).getName();
} else if (elem instanceof INode) {
processName = ((INode) elem).getProcess().getName();
} else if (elem instanceof IConnection) {
processName = ((IConnection) elem).getSource().getProcess().getName();
}
connParameters.setNodeReadOnly(false);
connParameters.setFromRepository(true);
ISQLBuilderService sqlBuilderService = (ISQLBuilderService) GlobalServiceRegister.getDefault().getService(ISQLBuilderService.class);
Dialog sqlBuilder = sqlBuilderService.openSQLBuilderDialog(composite.getShell(), processName, connParameters);
String sql = null;
if (Window.OK == sqlBuilder.open()) {
sql = connParameters.getQuery();
}
if (sql != null && !queryText.isDisposed()) {
queryText.setText(sql);
String propertyName = (String) openSQLEditorButton.getData(PARAMETER_NAME);
return new PropertyChangeCommand(elem, propertyName, sql);
}
return null;
}
Aggregations