Search in sources :

Example 1 with KettleValueException

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

the class JobHistoryDelegate method displayHistoryData.

private void displayHistoryData(final int index) {
    JobHistoryLogTab model = models[index];
    ColumnInfo[] colinf = model.logDisplayTableView.getColumns();
    // 
    if (model.logDisplayTableView == null || model.logDisplayTableView.isDisposed()) {
        return;
    }
    int selectionIndex = model.logDisplayTableView.getSelectionIndex();
    model.logDisplayTableView.table.clearAll();
    List<Object[]> rows = model.rows;
    if (rows != null && rows.size() > 0) {
        // 
        for (Object[] rowData : rows) {
            TableItem item = new TableItem(model.logDisplayTableView.table, SWT.NONE);
            for (int c = 0; c < colinf.length; c++) {
                ColumnInfo column = colinf[c];
                ValueMetaInterface valueMeta = column.getValueMeta();
                String string = null;
                try {
                    string = valueMeta.getString(rowData[c]);
                } catch (KettleValueException e) {
                    log.logError("history data conversion issue", e);
                }
                item.setText(c + 1, Const.NVL(string, ""));
            }
            // Add some color
            // 
            Long errors = null;
            LogStatus status = null;
            LogTableField errorsField = model.logTable.getErrorsField();
            if (errorsField != null) {
                int index1 = model.logTableFields.indexOf(errorsField);
                try {
                    errors = colinf[index1].getValueMeta().getInteger(rowData[index1]);
                } catch (KettleValueException e) {
                    log.logError("history data conversion issue", e);
                }
            }
            LogTableField statusField = model.logTable.getStatusField();
            if (statusField != null) {
                int index1 = model.logTableFields.indexOf(statusField);
                String statusString = null;
                try {
                    statusString = colinf[index1].getValueMeta().getString(rowData[index1]);
                } catch (KettleValueException e) {
                    log.logError("history data conversion issue", e);
                }
                if (statusString != null) {
                    status = LogStatus.findStatus(statusString);
                }
            }
            if (errors != null && errors > 0L) {
                item.setBackground(GUIResource.getInstance().getColorRed());
            } else if (status != null && LogStatus.STOP.equals(status)) {
                item.setBackground(GUIResource.getInstance().getColorYellow());
            }
        }
        model.logDisplayTableView.removeEmptyRows();
        model.logDisplayTableView.setRowNums();
        model.logDisplayTableView.optWidth(true);
    } else {
        model.logDisplayTableView.clearAll(false);
    // new TableItem(wFields.get(tabIndex).table, SWT.NONE); // Give it an item to prevent errors on various
    // platforms.
    }
    if (selectionIndex >= 0 && selectionIndex < model.logDisplayTableView.getItemCount()) {
        model.logDisplayTableView.table.select(selectionIndex);
        showLogEntry();
    }
}
Also used : LogTableField(org.pentaho.di.core.logging.LogTableField) TableItem(org.eclipse.swt.widgets.TableItem) ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) LogStatus(org.pentaho.di.core.logging.LogStatus) KettleValueException(org.pentaho.di.core.exception.KettleValueException)

Example 2 with KettleValueException

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

the class TransGraph method sniff.

public void sniff(final boolean input, final boolean output, final boolean error) {
    StepMeta stepMeta = getCurrentStep();
    if (stepMeta == null || trans == null) {
        return;
    }
    final StepInterface runThread = trans.findRunThread(stepMeta.getName());
    if (runThread != null) {
        List<Object[]> rows = new ArrayList<>();
        final PreviewRowsDialog dialog = new PreviewRowsDialog(shell, trans, SWT.NONE, stepMeta.getName(), null, rows);
        dialog.setDynamic(true);
        // Add a row listener that sends the rows over to the dialog...
        // 
        final RowListener rowListener = new RowListener() {

            @Override
            public void rowReadEvent(RowMetaInterface rowMeta, Object[] row) throws KettleStepException {
                if (input) {
                    try {
                        dialog.addDataRow(rowMeta, rowMeta.cloneRow(row));
                    } catch (KettleValueException e) {
                        throw new KettleStepException(e);
                    }
                }
            }

            @Override
            public void rowWrittenEvent(RowMetaInterface rowMeta, Object[] row) throws KettleStepException {
                if (output) {
                    try {
                        dialog.addDataRow(rowMeta, rowMeta.cloneRow(row));
                    } catch (KettleValueException e) {
                        throw new KettleStepException(e);
                    }
                }
            }

            @Override
            public void errorRowWrittenEvent(RowMetaInterface rowMeta, Object[] row) throws KettleStepException {
                if (error) {
                    try {
                        dialog.addDataRow(rowMeta, rowMeta.cloneRow(row));
                    } catch (KettleValueException e) {
                        throw new KettleStepException(e);
                    }
                }
            }
        };
        // When the dialog is closed, make sure to remove the listener!
        // 
        dialog.addDialogClosedListener(new DialogClosedListener() {

            @Override
            public void dialogClosed() {
                runThread.removeRowListener(rowListener);
            }
        });
        // Open the dialog in a separate thread to make sure it doesn't block
        // 
        getDisplay().asyncExec(new Runnable() {

            @Override
            public void run() {
                dialog.open();
            }
        });
        runThread.addRowListener(rowListener);
    }
}
Also used : StepInterface(org.pentaho.di.trans.step.StepInterface) KettleStepException(org.pentaho.di.core.exception.KettleStepException) ArrayList(java.util.ArrayList) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) EnterPreviewRowsDialog(org.pentaho.di.ui.spoon.dialog.EnterPreviewRowsDialog) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) KettleValueException(org.pentaho.di.core.exception.KettleValueException) StepMeta(org.pentaho.di.trans.step.StepMeta) RowListener(org.pentaho.di.trans.step.RowListener) DialogClosedListener(org.pentaho.di.ui.core.dialog.DialogClosedListener)

Example 3 with KettleValueException

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

the class EditRowsDialog method getDataForRow.

protected int getDataForRow(TableItem item, Object[] row) {
    int nrErrors = 0;
    // 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 : KettleValueException(org.pentaho.di.core.exception.KettleValueException) KettleException(org.pentaho.di.core.exception.KettleException) KettleValueException(org.pentaho.di.core.exception.KettleValueException) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 4 with KettleValueException

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

the class EnterValueDialog method getValue.

private ValueMetaAndData getValue(String valuename) throws KettleValueException {
    try {
        int valtype = ValueMetaFactory.getIdForValueMeta(wValueType.getText());
        ValueMetaAndData val = new ValueMetaAndData(valuename, wInputString.getText());
        ValueMetaInterface valueMeta = ValueMetaFactory.cloneValueMeta(val.getValueMeta(), valtype);
        Object valueData = val.getValueData();
        int formatIndex = wFormat.getSelectionIndex();
        valueMeta.setConversionMask(formatIndex >= 0 ? wFormat.getItem(formatIndex) : wFormat.getText());
        valueMeta.setLength(Const.toInt(wLength.getText(), -1));
        valueMeta.setPrecision(Const.toInt(wPrecision.getText(), -1));
        val.setValueMeta(valueMeta);
        ValueMetaInterface stringValueMeta = new ValueMetaString(valuename);
        stringValueMeta.setConversionMetadata(valueMeta);
        Object targetData = stringValueMeta.convertDataUsingConversionMetaData(valueData);
        val.setValueData(targetData);
        return val;
    } catch (Exception e) {
        throw new KettleValueException(e);
    }
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaAndData(org.pentaho.di.core.row.ValueMetaAndData) KettleValueException(org.pentaho.di.core.exception.KettleValueException) KettleValueException(org.pentaho.di.core.exception.KettleValueException) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 5 with KettleValueException

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

the class SelectRowDialog method getData.

/**
 * Copy information from the input buffer to the dialog fields.
 */
private void getData() {
    for (int i = 0; i < buffer.size(); i++) {
        RowMetaAndData rowMetaAndData = buffer.get(i);
        RowMetaInterface rowMeta = rowMetaAndData.getRowMeta();
        Object[] rowData = rowMetaAndData.getData();
        for (int c = 0; c < rowMeta.size(); c++) {
            ValueMetaInterface v = rowMeta.getValueMeta(c);
            String show;
            try {
                if (v.isNumeric()) {
                    show = v.getString(rowData[c]);
                } else {
                    show = v.getString(rowData[c]);
                }
            } catch (KettleValueException e) {
                show = "<conversion error>";
            }
            if (show != null) {
                wFields.table.getItem(i).setText(c + 1, show);
            }
        }
    }
    wFields.optWidth(true);
}
Also used : RowMetaAndData(org.pentaho.di.core.RowMetaAndData) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) 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