use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-cassandra-plugin by pentaho.
the class CassandraOutputDialog method setupTablesCombo.
protected void setupTablesCombo() {
Connection conn = null;
Keyspace kSpace = null;
try {
String hostS = transMeta.environmentSubstitute(m_hostText.getText());
String portS = transMeta.environmentSubstitute(m_portText.getText());
String userS = m_userText.getText();
String passS = m_passText.getText();
if (!Utils.isEmpty(userS) && !Utils.isEmpty(passS)) {
userS = transMeta.environmentSubstitute(userS);
passS = transMeta.environmentSubstitute(passS);
}
String keyspaceS = transMeta.environmentSubstitute(m_keyspaceText.getText());
try {
Map<String, String> opts = new HashMap<String, String>();
opts.put(CassandraUtils.CQLOptions.CQLVERSION_OPTION, CassandraUtils.CQLOptions.CQL3_STRING);
conn = CassandraUtils.getCassandraConnection(hostS, Integer.parseInt(portS), userS, passS, ConnectionFactory.Driver.BINARY_CQL3_PROTOCOL, opts);
kSpace = conn.getKeyspace(keyspaceS);
} catch (Exception e) {
logError(// $NON-NLS-1$
BaseMessages.getString(PKG, "CassandraOutputDialog.Error.ProblemGettingSchemaInfo.Message") + ":\n\n" + e.getLocalizedMessage(), // $NON-NLS-1$
e);
new ErrorDialog(shell, BaseMessages.getString(PKG, // $NON-NLS-1$
"CassandraOutputDialog.Error.ProblemGettingSchemaInfo.Title"), // $NON-NLS-1$
BaseMessages.getString(PKG, "CassandraOutputDialog.Error.ProblemGettingSchemaInfo.Message") + ":\n\n" + e.getLocalizedMessage(), // $NON-NLS-1$
e);
return;
}
List<String> tables = kSpace.getTableNamesCQL3();
m_tableCombo.removeAll();
for (String famName : tables) {
m_tableCombo.add(famName);
}
} catch (Exception ex) {
logError(// $NON-NLS-1$
BaseMessages.getString(PKG, "CassandraOutputDialog.Error.ProblemGettingSchemaInfo.Message") + ":\n\n" + ex.getMessage(), // $NON-NLS-1$
ex);
new ErrorDialog(shell, BaseMessages.getString(PKG, // $NON-NLS-1$
"CassandraOutputDialog.Error.ProblemGettingSchemaInfo.Title"), // $NON-NLS-1$
BaseMessages.getString(PKG, "CassandraOutputDialog.Error.ProblemGettingSchemaInfo.Message") + ":\n\n" + ex.getMessage(), // $NON-NLS-1$
ex);
} finally {
if (conn != null) {
try {
conn.closeConnection();
} catch (Exception e) {
// TODO popup another error dialog
e.printStackTrace();
}
}
}
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-cassandra-plugin by pentaho.
the class CassandraOutputDialog method popupSchemaInfo.
protected void popupSchemaInfo() {
Connection conn = null;
Keyspace kSpace = null;
try {
String hostS = transMeta.environmentSubstitute(m_hostText.getText());
String portS = transMeta.environmentSubstitute(m_portText.getText());
String userS = m_userText.getText();
String passS = m_passText.getText();
if (!Utils.isEmpty(userS) && !Utils.isEmpty(passS)) {
userS = transMeta.environmentSubstitute(userS);
passS = transMeta.environmentSubstitute(passS);
}
String keyspaceS = transMeta.environmentSubstitute(m_keyspaceText.getText());
try {
Map<String, String> opts = new HashMap<String, String>();
opts.put(CassandraUtils.CQLOptions.CQLVERSION_OPTION, CassandraUtils.CQLOptions.CQL3_STRING);
conn = CassandraUtils.getCassandraConnection(hostS, Integer.parseInt(portS), userS, passS, ConnectionFactory.Driver.BINARY_CQL3_PROTOCOL, opts);
conn.setHosts(hostS);
conn.setDefaultPort(Integer.parseInt(portS));
conn.setUsername(userS);
conn.setPassword(passS);
kSpace = conn.getKeyspace(keyspaceS);
} catch (Exception e) {
logError(// $NON-NLS-1$
BaseMessages.getString(PKG, "CassandraOutputDialog.Error.ProblemGettingSchemaInfo.Message") + ":\n\n" + e.getLocalizedMessage(), // $NON-NLS-1$
e);
new ErrorDialog(shell, BaseMessages.getString(PKG, // $NON-NLS-1$
"CassandraOutputDialog.Error.ProblemGettingSchemaInfo.Title"), // $NON-NLS-1$
BaseMessages.getString(PKG, "CassandraOutputDialog.Error.ProblemGettingSchemaInfo.Message") + ":\n\n" + e.getLocalizedMessage(), // $NON-NLS-1$
e);
return;
}
String table = transMeta.environmentSubstitute(m_tableCombo.getText());
if (Utils.isEmpty(table)) {
// $NON-NLS-1$
throw new Exception("No table name specified!");
}
table = CassandraUtils.cql3MixedCaseQuote(table);
// if (!CassandraColumnMetaData.tableExists(conn, table)) {
if (!kSpace.tableExists(table)) {
throw new Exception(// $NON-NLS-1$ //$NON-NLS-2$
"The table '" + table + "' does not " + "seem to exist in the keyspace '" + // $NON-NLS-1$
keyspaceS);
}
ITableMetaData cassMeta = kSpace.getTableMetaData(table);
// CassandraColumnMetaData cassMeta = new CassandraColumnMetaData(conn,
// table);
String schemaDescription = cassMeta.describe();
ShowMessageDialog smd = // $NON-NLS-1$
new ShowMessageDialog(shell, SWT.ICON_INFORMATION | SWT.OK, "Schema info", schemaDescription, true);
smd.open();
} catch (Exception e1) {
logError(// $NON-NLS-1$
BaseMessages.getString(PKG, "CassandraOutputDialog.Error.ProblemGettingSchemaInfo.Message") + ":\n\n" + e1.getMessage(), // $NON-NLS-1$
e1);
new ErrorDialog(shell, BaseMessages.getString(PKG, // $NON-NLS-1$
"CassandraOutputDialog.Error.ProblemGettingSchemaInfo.Title"), // $NON-NLS-1$
BaseMessages.getString(PKG, "CassandraOutputDialog.Error.ProblemGettingSchemaInfo.Message") + ":\n\n" + e1.getMessage(), // $NON-NLS-1$
e1);
} finally {
if (conn != null) {
try {
conn.closeConnection();
} catch (Exception e) {
// TODO popup another error dialog
e.printStackTrace();
}
}
}
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class GPLoadDialog method getUpdate.
private void getUpdate() {
try {
RowMetaInterface r = transMeta.getPrevStepFields(stepname);
if (r != null) {
TableItemInsertListener listener = new TableItemInsertListener() {
public boolean tableItemInserted(TableItem tableItem, ValueMetaInterface v) {
if (v.getType() == ValueMetaInterface.TYPE_DATE) {
// The default is date mask.
tableItem.setText(3, BaseMessages.getString(PKG, "GPLoadDialog.DateMask.Label"));
} else {
tableItem.setText(3, "");
}
return true;
}
};
BaseStepDialog.getFieldsFromPrevious(r, wReturn, 1, new int[] { 1, 2 }, new int[] {}, -1, -1, listener);
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "GPLoadDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "GPLoadDialog.FailedToGetFields.DialogMessage"), ke);
}
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class GetPreviousRowFieldDialog method get.
private void get() {
try {
RowMetaInterface r = transMeta.getPrevStepFields(stepname);
if (r != null) {
TableItemInsertListener listener = new TableItemInsertListener() {
public boolean tableItemInserted(TableItem tableItem, ValueMetaInterface v) {
return true;
}
};
BaseStepDialog.getFieldsFromPrevious(r, wFields, 1, new int[] { 1 }, new int[] {}, -1, -1, listener);
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "GetPreviousRowFieldDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "GetPreviousRowFieldDialog.FailedToGetFields.DialogMessage"), ke);
}
}
use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.
the class CombinationLookupDialog method create.
/**
* Generate code for create table. Conversions done by database.
*/
private void create() {
try {
// Gather info...
CombinationLookupMeta info = new CombinationLookupMeta();
getInfo(info);
// new name might not yet be linked to other steps!
String name = stepname;
StepMeta stepMeta = new StepMeta(BaseMessages.getString(PKG, "CombinationLookupDialog.StepMeta.Title"), name, info);
RowMetaInterface prev = transMeta.getPrevStepFields(stepname);
SQLStatement sql = info.getSQLStatements(transMeta, stepMeta, prev, repository, metaStore);
if (!sql.hasError()) {
if (sql.hasSQL()) {
SQLEditor sqledit = new SQLEditor(transMeta, shell, SWT.NONE, info.getDatabaseMeta(), transMeta.getDbCache(), sql.getSQL());
sqledit.open();
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
mb.setMessage(BaseMessages.getString(PKG, "CombinationLookupDialog.NoSQLNeeds.DialogMessage"));
mb.setText(BaseMessages.getString(PKG, "CombinationLookupDialog.NoSQLNeeds.DialogTitle"));
mb.open();
}
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(sql.getError());
mb.setText(BaseMessages.getString(PKG, "CombinationLookupDialog.SQLError.DialogTitle"));
mb.open();
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "CombinationLookupDialog.UnableToCreateSQL.DialogTitle"), BaseMessages.getString(PKG, "CombinationLookupDialog.UnableToCreateSQL.DialogMessage"), ke);
}
}
Aggregations