Search in sources :

Example 1 with IngresVectorwiseLoaderMeta

use of org.pentaho.di.trans.steps.ivwloader.IngresVectorwiseLoaderMeta in project pentaho-kettle by pentaho.

the class IngresVectorwiseLoaderDialog method sql.

private void sql() {
    try {
        IngresVectorwiseLoaderMeta info = new IngresVectorwiseLoaderMeta();
        getInfo(info);
        RowMetaInterface prev = transMeta.getPrevStepFields(stepname);
        StepMeta stepMeta = transMeta.findStep(stepname);
        // Only use the fields that were specified.
        // 
        RowMetaInterface prevNew = new RowMeta();
        for (int i = 0; i < info.getFieldDatabase().length; i++) {
            ValueMetaInterface insValue = prev.searchValueMeta(info.getFieldStream()[i]);
            if (insValue != null) {
                ValueMetaInterface insertValue = insValue.clone();
                insertValue.setName(info.getFieldDatabase()[i]);
                prevNew.addValueMeta(insertValue);
            } else {
                throw new KettleStepException(BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.FailedToFindField.Message", info.getFieldStream()[i]));
            }
        }
        prev = prevNew;
        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, "IngresVectorWiseLoaderDialog.NoSQL.DialogMessage"));
                mb.setText(BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.NoSQL.DialogTitle"));
                mb.open();
            }
        } else {
            MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
            mb.setMessage(sql.getError());
            mb.setText(BaseMessages.getString(PKG, "System.Dialog.Error.Title"));
            mb.open();
        }
    } catch (KettleException ke) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.BuildSQLError.DialogTitle"), BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.BuildSQLError.DialogMessage"), ke);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) SQLEditor(org.pentaho.di.ui.core.database.dialog.SQLEditor) KettleStepException(org.pentaho.di.core.exception.KettleStepException) RowMeta(org.pentaho.di.core.row.RowMeta) IngresVectorwiseLoaderMeta(org.pentaho.di.trans.steps.ivwloader.IngresVectorwiseLoaderMeta) 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) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) 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 KettleStepException (org.pentaho.di.core.exception.KettleStepException)1 RowMeta (org.pentaho.di.core.row.RowMeta)1 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)1 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)1 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)1 StepMeta (org.pentaho.di.trans.step.StepMeta)1 IngresVectorwiseLoaderMeta (org.pentaho.di.trans.steps.ivwloader.IngresVectorwiseLoaderMeta)1 SQLEditor (org.pentaho.di.ui.core.database.dialog.SQLEditor)1 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)1