Search in sources :

Example 61 with RowMetaInterface

use of org.pentaho.di.core.row.RowMetaInterface in project pentaho-kettle by pentaho.

the class PGBulkLoaderDialog method setTableFieldCombo.

private void setTableFieldCombo() {
    Runnable fieldLoader = new Runnable() {

        public void run() {
            if (!wTable.isDisposed() && !wConnection.isDisposed() && !wSchema.isDisposed()) {
                final String tableName = wTable.getText(), connectionName = wConnection.getText(), schemaName = wSchema.getText();
                // clear
                for (ColumnInfo colInfo : tableFieldColumns) {
                    colInfo.setComboValues(new String[] {});
                }
                if (!Utils.isEmpty(tableName)) {
                    DatabaseMeta ci = transMeta.findDatabase(connectionName);
                    if (ci != null) {
                        Database db = new Database(loggingObject, ci);
                        try {
                            db.connect();
                            String schemaTable = ci.getQuotedSchemaTableCombination(transMeta.environmentSubstitute(schemaName), transMeta.environmentSubstitute(tableName));
                            RowMetaInterface r = db.getTableFields(schemaTable);
                            if (null != r) {
                                String[] fieldNames = r.getFieldNames();
                                if (null != fieldNames) {
                                    for (ColumnInfo colInfo : tableFieldColumns) {
                                        colInfo.setComboValues(fieldNames);
                                    }
                                }
                            }
                        } catch (Exception e) {
                            for (ColumnInfo colInfo : tableFieldColumns) {
                                colInfo.setComboValues(new String[] {});
                            }
                        // ignore any errors here. drop downs will not be
                        // filled, but no problem for the user
                        } finally {
                            try {
                                if (db != null) {
                                    db.disconnect();
                                }
                            } catch (Exception ignored) {
                                // ignore any errors here.
                                db = null;
                            }
                        }
                    }
                }
            }
        }
    };
    shell.getDisplay().asyncExec(fieldLoader);
}
Also used : Database(org.pentaho.di.core.database.Database) ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) KettleException(org.pentaho.di.core.exception.KettleException)

Example 62 with RowMetaInterface

use of org.pentaho.di.core.row.RowMetaInterface in project pentaho-kettle by pentaho.

the class PGPDecryptStreamDialog method get.

private void get() {
    if (!gotPreviousFields) {
        try {
            String fieldvalue = wStreamFieldName.getText();
            String passphrasefieldvalue = wPassphraseFieldName.getText();
            wStreamFieldName.removeAll();
            wPassphraseFieldName.removeAll();
            RowMetaInterface r = transMeta.getPrevStepFields(stepname);
            if (r != null) {
                String[] fields = r.getFieldNames();
                wStreamFieldName.setItems(fields);
                wPassphraseFieldName.setItems(fields);
            }
            if (fieldvalue != null) {
                wStreamFieldName.setText(fieldvalue);
            }
            if (passphrasefieldvalue != null) {
                wPassphraseFieldName.setText(passphrasefieldvalue);
            }
            gotPreviousFields = true;
        } catch (KettleException ke) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "PGPDecryptStreamDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "PGPDecryptStreamDialog.FailedToGetFields.DialogMessage"), ke);
        }
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface)

Example 63 with RowMetaInterface

use of org.pentaho.di.core.row.RowMetaInterface in project pentaho-kettle by pentaho.

the class PGPEncryptStreamDialog method get.

private void get() {
    if (!gotPreviousFields) {
        try {
            String fieldvalue = wStreamFieldName.getText();
            wStreamFieldName.removeAll();
            String Keyfieldvalue = wKeyNameFieldName.getText();
            wKeyNameFieldName.removeAll();
            RowMetaInterface r = transMeta.getPrevStepFields(stepname);
            if (r != null) {
                wStreamFieldName.setItems(r.getFieldNames());
                wKeyNameFieldName.setItems(r.getFieldNames());
            }
            if (fieldvalue != null) {
                wStreamFieldName.setText(fieldvalue);
            }
            if (Keyfieldvalue != null) {
                wKeyNameFieldName.setText(Keyfieldvalue);
            }
            gotPreviousFields = true;
        } catch (KettleException ke) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "PGPEncryptStreamDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "PGPEncryptStreamDialog.FailedToGetFields.DialogMessage"), ke);
        }
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface)

Example 64 with RowMetaInterface

use of org.pentaho.di.core.row.RowMetaInterface in project pentaho-kettle by pentaho.

the class ProcessFilesDialog method get.

private void get() {
    if (!gotPreviousFields) {
        gotPreviousFields = true;
        try {
            String source = wSourceFileNameField.getText();
            String target = wTargetFileNameField.getText();
            wSourceFileNameField.removeAll();
            wTargetFileNameField.removeAll();
            RowMetaInterface r = transMeta.getPrevStepFields(stepname);
            if (r != null) {
                wSourceFileNameField.setItems(r.getFieldNames());
                wTargetFileNameField.setItems(r.getFieldNames());
                if (source != null) {
                    wSourceFileNameField.setText(source);
                }
                if (target != null) {
                    wTargetFileNameField.setText(target);
                }
            }
        } catch (KettleException ke) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "ProcessFilesDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "ProcessFilesDialog.FailedToGetFields.DialogMessage"), ke);
        }
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface)

Example 65 with RowMetaInterface

use of org.pentaho.di.core.row.RowMetaInterface in project pentaho-kettle by pentaho.

the class PropertyInputDialog method setFileField.

private void setFileField() {
    try {
        String value = wFilenameField.getText();
        wFilenameField.removeAll();
        RowMetaInterface r = transMeta.getPrevStepFields(stepname);
        if (r != null) {
            r.getFieldNames();
            for (int i = 0; i < r.getFieldNames().length; i++) {
                wFilenameField.add(r.getFieldNames()[i]);
            }
        }
        if (value != null) {
            wFilenameField.setText(value);
        }
    } catch (KettleException ke) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "PropertyInputDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "PropertyInputDialog.FailedToGetFields.DialogMessage"), ke);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString)

Aggregations

RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)908 KettleException (org.pentaho.di.core.exception.KettleException)369 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)330 RowMeta (org.pentaho.di.core.row.RowMeta)275 ArrayList (java.util.ArrayList)206 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)196 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)180 Test (org.junit.Test)169 StepMeta (org.pentaho.di.trans.step.StepMeta)150 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)142 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)110 KettleStepException (org.pentaho.di.core.exception.KettleStepException)107 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)101 TableItem (org.eclipse.swt.widgets.TableItem)84 ColumnInfo (org.pentaho.di.ui.core.widget.ColumnInfo)84 Database (org.pentaho.di.core.database.Database)81 TableItemInsertListener (org.pentaho.di.ui.trans.step.TableItemInsertListener)79 FormAttachment (org.eclipse.swt.layout.FormAttachment)76 FormData (org.eclipse.swt.layout.FormData)76 FormLayout (org.eclipse.swt.layout.FormLayout)76