Search in sources :

Example 6 with ErrorDialog

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();
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) Keyspace(org.pentaho.cassandra.spi.Keyspace) Connection(org.pentaho.cassandra.spi.Connection) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) KettleException(org.pentaho.di.core.exception.KettleException)

Example 7 with ErrorDialog

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();
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) Keyspace(org.pentaho.cassandra.spi.Keyspace) ShowMessageDialog(org.pentaho.di.ui.core.dialog.ShowMessageDialog) Connection(org.pentaho.cassandra.spi.Connection) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ITableMetaData(org.pentaho.cassandra.spi.ITableMetaData) KettleException(org.pentaho.di.core.exception.KettleException)

Example 8 with ErrorDialog

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);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) TableItemInsertListener(org.pentaho.di.ui.trans.step.TableItemInsertListener) TableItem(org.eclipse.swt.widgets.TableItem) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 9 with ErrorDialog

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);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) TableItemInsertListener(org.pentaho.di.ui.trans.step.TableItemInsertListener) TableItem(org.eclipse.swt.widgets.TableItem) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 10 with ErrorDialog

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);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) SQLEditor(org.pentaho.di.ui.core.database.dialog.SQLEditor) CombinationLookupMeta(org.pentaho.di.trans.steps.combinationlookup.CombinationLookupMeta) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) SQLStatement(org.pentaho.di.core.SQLStatement) MessageBox(org.eclipse.swt.widgets.MessageBox)

Aggregations

ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)527 KettleException (org.pentaho.di.core.exception.KettleException)440 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)178 MessageBox (org.eclipse.swt.widgets.MessageBox)118 TableItem (org.eclipse.swt.widgets.TableItem)97 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)76 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)63 TransMeta (org.pentaho.di.trans.TransMeta)48 Shell (org.eclipse.swt.widgets.Shell)46 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)46 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)44 EnterTextDialog (org.pentaho.di.ui.core.dialog.EnterTextDialog)44 ArrayList (java.util.ArrayList)43 TableItemInsertListener (org.pentaho.di.ui.trans.step.TableItemInsertListener)43 EnterSelectionDialog (org.pentaho.di.ui.core.dialog.EnterSelectionDialog)42 SelectionEvent (org.eclipse.swt.events.SelectionEvent)40 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)39 StepMeta (org.pentaho.di.trans.step.StepMeta)38 FormData (org.eclipse.swt.layout.FormData)37 FormLayout (org.eclipse.swt.layout.FormLayout)37