Search in sources :

Example 1 with MySQLBulkLoaderMeta

use of org.pentaho.di.trans.steps.mysqlbulkloader.MySQLBulkLoaderMeta in project pentaho-kettle by pentaho.

the class MySQLBulkLoaderDialog method create.

// Generate code for create table...
// Conversions done by Database
private void create() {
    try {
        MySQLBulkLoaderMeta info = new MySQLBulkLoaderMeta();
        getInfo(info);
        // new name might not yet be linked to other steps!
        String name = stepname;
        StepMeta stepMeta = new StepMeta(BaseMessages.getString(PKG, "MySQLBulkLoaderDialog.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, "MySQLBulkLoaderDialog.NoSQLNeeds.DialogMessage"));
                mb.setText(BaseMessages.getString(PKG, "MySQLBulkLoaderDialog.NoSQLNeeds.DialogTitle"));
                mb.open();
            }
        } else {
            MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
            mb.setMessage(sql.getError());
            mb.setText(BaseMessages.getString(PKG, "MySQLBulkLoaderDialog.SQLError.DialogTitle"));
            mb.open();
        }
    } catch (KettleException ke) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "MySQLBulkLoaderDialog.CouldNotBuildSQL.DialogTitle"), BaseMessages.getString(PKG, "MySQLBulkLoaderDialog.CouldNotBuildSQL.DialogMessage"), ke);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) SQLEditor(org.pentaho.di.ui.core.database.dialog.SQLEditor) MySQLBulkLoaderMeta(org.pentaho.di.trans.steps.mysqlbulkloader.MySQLBulkLoaderMeta) 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

MessageBox (org.eclipse.swt.widgets.MessageBox)1 SQLStatement (org.pentaho.di.core.SQLStatement)1 KettleException (org.pentaho.di.core.exception.KettleException)1 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)1 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)1 StepMeta (org.pentaho.di.trans.step.StepMeta)1 MySQLBulkLoaderMeta (org.pentaho.di.trans.steps.mysqlbulkloader.MySQLBulkLoaderMeta)1 SQLEditor (org.pentaho.di.ui.core.database.dialog.SQLEditor)1 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)1