Search in sources :

Example 91 with KettleValueException

use of org.pentaho.di.core.exception.KettleValueException in project pentaho-kettle by pentaho.

the class EnterStringsDialog method getData.

/**
 * Copy information from the meta-data input to the dialog fields.
 */
public void getData() {
    if (strings != null) {
        for (int i = 0; i < strings.getRowMeta().size(); i++) {
            ValueMetaInterface valueMeta = strings.getRowMeta().getValueMeta(i);
            Object valueData = strings.getData()[i];
            String string;
            try {
                string = valueMeta.getString(valueData);
            } catch (KettleValueException e) {
                string = "";
            // TODO: can this ever be a meaningful exception? We're editing strings almost by definition
            }
            TableItem item = wFields.table.getItem(i);
            item.setText(1, valueMeta.getName());
            if (!Utils.isEmpty(string)) {
                item.setText(2, string);
            }
        }
    }
    wFields.sortTable(1);
    wFields.setRowNums();
    wFields.optWidth(true);
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) KettleValueException(org.pentaho.di.core.exception.KettleValueException) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 92 with KettleValueException

use of org.pentaho.di.core.exception.KettleValueException in project pentaho-kettle by pentaho.

the class EnterValueDialog method getData.

public void getData() {
    wValueType.setText(valueMeta.getTypeDesc());
    try {
        if (valueData != null) {
            String value = valueMeta.getString(valueData);
            if (value != null) {
                wInputString.setText(value);
            }
        }
    } catch (KettleValueException e) {
        wInputString.setText(valueMeta.toString());
    }
    setFormats();
    int index = -1;
    // we need to add that mask to the combo box
    if (!Utils.isEmpty(valueMeta.getConversionMask())) {
        index = wFormat.indexOf(valueMeta.getConversionMask());
        if (index < 0) {
            wFormat.add(valueMeta.getConversionMask());
            index = wFormat.indexOf(valueMeta.getConversionMask());
        }
    }
    if (index >= 0) {
        wFormat.select(index);
    }
    wLength.setText(Integer.toString(valueMeta.getLength()));
    wPrecision.setText(Integer.toString(valueMeta.getPrecision()));
    setFormats();
    wInputString.setFocus();
    wInputString.selectAll();
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) KettleValueException(org.pentaho.di.core.exception.KettleValueException)

Example 93 with KettleValueException

use of org.pentaho.di.core.exception.KettleValueException in project pentaho-kettle by pentaho.

the class EnterValueDialog method test.

/**
 * Test the entered value
 */
public void test() {
    try {
        ValueMetaAndData v = getValue(valueMeta.getName());
        MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
        StringBuilder result = new StringBuilder();
        result.append(Const.CR).append(Const.CR).append("    ").append(v.toString());
        result.append(Const.CR).append("    ").append(v.toStringMeta());
        mb.setMessage(BaseMessages.getString(PKG, "EnterValueDialog.TestResult.Message", result.toString()));
        mb.setText(BaseMessages.getString(PKG, "EnterValueDialog.TestResult.Title"));
        mb.open();
    } catch (KettleValueException e) {
        new ErrorDialog(shell, "Error", "There was an error during data type conversion: ", e);
    }
}
Also used : ValueMetaAndData(org.pentaho.di.core.row.ValueMetaAndData) KettleValueException(org.pentaho.di.core.exception.KettleValueException) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 94 with KettleValueException

use of org.pentaho.di.core.exception.KettleValueException in project pentaho-kettle by pentaho.

the class PreviewRowsDialog method getDataForRow.

protected int getDataForRow(TableItem item, Object[] row) {
    int nrErrors = 0;
    if (row == null) {
        // no row to process
        return nrErrors;
    }
    // Display the correct line item...
    // 
    String strNr;
    lineNr++;
    try {
        strNr = wFields.getNumberColumn().getValueMeta().getString(new Long(lineNr));
    } catch (Exception e) {
        strNr = Integer.toString(lineNr);
    }
    item.setText(0, strNr);
    for (int c = 0; c < rowMeta.size(); c++) {
        ValueMetaInterface v = rowMeta.getValueMeta(c);
        String show;
        try {
            show = v.getString(row[c]);
            if (v.isBinary() && show != null && show.length() > MAX_BINARY_STRING_PREVIEW_SIZE) {
                // We want to limit the size of the strings during preview to keep all SWT widgets happy.
                // 
                show = show.substring(0, MAX_BINARY_STRING_PREVIEW_SIZE);
            }
        } catch (KettleValueException e) {
            nrErrors++;
            if (nrErrors < 25) {
                log.logError(Const.getStackTracker(e));
            }
            show = null;
        } catch (ArrayIndexOutOfBoundsException e) {
            nrErrors++;
            if (nrErrors < 25) {
                log.logError(Const.getStackTracker(e));
            }
            show = null;
        }
        if (show != null) {
            item.setText(c + 1, show);
            item.setForeground(c + 1, GUIResource.getInstance().getColorBlack());
        } else {
            // Set null value
            item.setText(c + 1, "<null>");
            item.setForeground(c + 1, GUIResource.getInstance().getColorBlue());
        }
    }
    return nrErrors;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) KettleValueException(org.pentaho.di.core.exception.KettleValueException) KettleValueException(org.pentaho.di.core.exception.KettleValueException) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 95 with KettleValueException

use of org.pentaho.di.core.exception.KettleValueException in project pentaho-kettle by pentaho.

the class SubjectDataBrowserDialog method getDataForRow.

protected int getDataForRow(TableItem item, RowMetaInterface rowMeta, Object[] row, int lineNr) {
    int nrErrors = 0;
    // Display the correct line item...
    // 
    String strNr;
    try {
        strNr = wFields.getNumberColumn().getValueMeta().getString(new Long(lineNr));
    } catch (Exception e) {
        strNr = Integer.toString(lineNr);
    }
    item.setText(0, strNr);
    for (int c = 0; c < rowMeta.size(); c++) {
        ValueMetaInterface v = rowMeta.getValueMeta(c);
        String show;
        try {
            show = v.getString(row[c]);
            if (v.isBinary() && show != null && show.length() > MAX_BINARY_STRING_PREVIEW_SIZE) {
                // We want to limit the size of the strings during preview to keep all SWT widgets happy.
                // 
                show = show.substring(0, MAX_BINARY_STRING_PREVIEW_SIZE);
            }
        } catch (KettleValueException e) {
            nrErrors++;
            if (nrErrors < 25) {
                log.logError(Const.getStackTracker(e));
            }
            show = null;
        } catch (ArrayIndexOutOfBoundsException e) {
            nrErrors++;
            if (nrErrors < 25) {
                log.logError(Const.getStackTracker(e));
            }
            show = null;
        }
        if (show != null) {
            item.setText(c + 1, show);
            item.setForeground(c + 1, GUIResource.getInstance().getColorBlack());
        } else {
            // Set null value
            item.setText(c + 1, "<null>");
            item.setForeground(c + 1, GUIResource.getInstance().getColorBlue());
        }
    }
    return nrErrors;
}
Also used : KettleValueException(org.pentaho.di.core.exception.KettleValueException) KettleValueException(org.pentaho.di.core.exception.KettleValueException) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Aggregations

KettleValueException (org.pentaho.di.core.exception.KettleValueException)127 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)35 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)35 KettleException (org.pentaho.di.core.exception.KettleException)25 KettleStepException (org.pentaho.di.core.exception.KettleStepException)17 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)16 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)13 IOException (java.io.IOException)12 Test (org.junit.Test)11 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)11 KettleFileException (org.pentaho.di.core.exception.KettleFileException)11 ParseException (java.text.ParseException)10 Date (java.util.Date)9 EOFException (java.io.EOFException)8 SQLException (java.sql.SQLException)8 ArrayList (java.util.ArrayList)8 Calendar (java.util.Calendar)8 KettleEOFException (org.pentaho.di.core.exception.KettleEOFException)8 UnsupportedEncodingException (java.io.UnsupportedEncodingException)6 BigDecimal (java.math.BigDecimal)6