Search in sources :

Example 1 with YamlReader

use of org.pentaho.di.trans.steps.yamlinput.YamlReader in project pentaho-kettle by pentaho.

the class YamlInputDialog method get.

private void get() {
    YamlReader yaml = null;
    try {
        YamlInputMeta meta = new YamlInputMeta();
        getInfo(meta);
        FileInputList inputList = meta.getFiles(transMeta);
        if (inputList.getFiles().size() > 0) {
            wFields.removeAll();
            yaml = new YamlReader();
            yaml.loadFile(inputList.getFile(0));
            RowMeta row = yaml.getFields();
            for (int i = 0; i < row.size(); i++) {
                ValueMetaInterface value = row.getValueMeta(i);
                TableItem item = new TableItem(wFields.table, SWT.NONE);
                item.setText(1, value.getName());
                item.setText(2, value.getName());
                item.setText(3, value.getTypeDesc());
            }
            wFields.removeEmptyRows();
            wFields.setRowNums();
            wFields.optWidth(true);
        }
    } catch (Exception e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "YamlInputDialog.ErrorParsingData.DialogTitle"), BaseMessages.getString(PKG, "YamlInputDialog.ErrorParsingData.DialogMessage"), e);
    } finally {
        if (yaml != null) {
            try {
                yaml.close();
            } catch (Exception e) {
            /* Ignore */
            }
        }
    }
}
Also used : RowMeta(org.pentaho.di.core.row.RowMeta) TableItem(org.eclipse.swt.widgets.TableItem) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) YamlReader(org.pentaho.di.trans.steps.yamlinput.YamlReader) YamlInputMeta(org.pentaho.di.trans.steps.yamlinput.YamlInputMeta) FileInputList(org.pentaho.di.core.fileinput.FileInputList) KettleException(org.pentaho.di.core.exception.KettleException) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Aggregations

TableItem (org.eclipse.swt.widgets.TableItem)1 KettleException (org.pentaho.di.core.exception.KettleException)1 FileInputList (org.pentaho.di.core.fileinput.FileInputList)1 RowMeta (org.pentaho.di.core.row.RowMeta)1 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)1 YamlInputMeta (org.pentaho.di.trans.steps.yamlinput.YamlInputMeta)1 YamlReader (org.pentaho.di.trans.steps.yamlinput.YamlReader)1 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)1