Search in sources :

Example 51 with KettleValueException

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

the class Spoon method applyVariables.

public void applyVariables() {
    for (int i = 0; i < variables.size(); i++) {
        try {
            String name = variables.getValueMeta(i).getName();
            String value = variables.getString(i, "");
            applyVariableToAllLoadedObjects(name, value);
        } catch (KettleValueException e) {
            // Just eat the exception. getString() should never give an
            // exception.
            log.logDebug("Unexpected exception occurred : " + e.getMessage());
        }
    }
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) KettleValueException(org.pentaho.di.core.exception.KettleValueException) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 52 with KettleValueException

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

the class TransHistoryDelegate method displayHistoryData.

private void displayHistoryData(final int index) {
    TransHistoryLogTab 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 53 with KettleValueException

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

the class RestClientExternalResourceConsumer method getResourcesFromRow.

@Override
public Collection<IExternalResourceInfo> getResourcesFromRow(Rest step, RowMetaInterface rowMeta, Object[] row) {
    Set<IExternalResourceInfo> resources = new HashSet<>();
    RestMeta meta = (RestMeta) step.getStepMetaInterface();
    if (meta == null) {
        meta = (RestMeta) step.getStepMeta().getStepMetaInterface();
    }
    if (meta != null) {
        String url;
        String method;
        String body;
        try {
            if (meta.isUrlInField()) {
                url = rowMeta.getString(row, meta.getUrlField(), null);
            } else {
                url = meta.getUrl();
            }
            if (StringUtils.isNotEmpty(url)) {
                WebServiceResourceInfo resourceInfo = createResourceInfo(url, meta);
                if (ArrayUtils.isNotEmpty(meta.getHeaderField())) {
                    for (int i = 0; i < meta.getHeaderField().length; i++) {
                        String field = meta.getHeaderField()[i];
                        String label = meta.getHeaderName()[i];
                        resourceInfo.addHeader(label, rowMeta.getString(row, field, null));
                    }
                }
                if (ArrayUtils.isNotEmpty(meta.getParameterField())) {
                    for (int i = 0; i < meta.getParameterField().length; i++) {
                        String field = meta.getParameterField()[i];
                        String label = meta.getParameterName()[i];
                        resourceInfo.addParameter(label, rowMeta.getString(row, field, null));
                    }
                }
                if (meta.isDynamicMethod()) {
                    method = rowMeta.getString(row, meta.getMethodFieldName(), null);
                    resourceInfo.setMethod(method);
                }
                if (StringUtils.isNotEmpty(meta.getBodyField())) {
                    body = rowMeta.getString(row, meta.getBodyField(), null);
                    resourceInfo.setBody(body);
                }
                resources.add(resourceInfo);
            }
        } catch (KettleValueException e) {
            // could not find a url on this row
            log.debug(e.getMessage(), e);
        }
    }
    return resources;
}
Also used : IExternalResourceInfo(org.pentaho.metaverse.api.model.IExternalResourceInfo) RestMeta(org.pentaho.di.trans.steps.rest.RestMeta) WebServiceResourceInfo(org.pentaho.metaverse.api.model.WebServiceResourceInfo) KettleValueException(org.pentaho.di.core.exception.KettleValueException) HashSet(java.util.HashSet)

Example 54 with KettleValueException

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

the class ExternalResourceStepAnalyzer method getInputRowMetaInterfaces.

@Override
protected Map<String, RowMetaInterface> getInputRowMetaInterfaces(T meta) {
    Map<String, RowMetaInterface> inputRows = super.getInputRowMetaInterfaces(meta);
    if (inputRows == null) {
        inputRows = new HashMap<>();
    }
    // assume that the output fields are defined in the step and are based on the resource inputs
    if (isInput()) {
        RowMetaInterface stepFields = getOutputFields(meta);
        if (stepFields != null) {
            RowMetaInterface clone = stepFields.clone();
            // "additional" fields, or fields coming from previous steps
            for (final String inputFieldToIgnore : getInputFieldsToIgnore(meta, inputRows, stepFields)) {
                try {
                    clone.removeValueMeta(inputFieldToIgnore);
                } catch (KettleValueException e) {
                // could not find it in the output, skip it
                }
            }
            inputRows.put(RESOURCE, clone);
        }
    }
    return inputRows;
}
Also used : RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) KettleValueException(org.pentaho.di.core.exception.KettleValueException)

Example 55 with KettleValueException

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

the class ExternalResourceStepAnalyzer method getOutputRowMetaInterfaces.

@Override
protected Map<String, RowMetaInterface> getOutputRowMetaInterfaces(T meta) {
    Map<String, RowMetaInterface> outputRows = super.getOutputRowMetaInterfaces(meta);
    if (MapUtils.isNotEmpty(outputRows)) {
        // if this is an output step analyzer, we always need to write the resource fields out
        if (isOutput()) {
            RowMetaInterface out = null;
            Set<String> outputResourceFields = getOutputResourceFields(meta);
            for (RowMetaInterface rowMetaInterface : outputRows.values()) {
                if (outputResourceFields != null) {
                    out = rowMetaInterface.clone();
                    // only add the fields that appear in the output of the step, not all fields that pass through
                    for (ValueMetaInterface field : rowMetaInterface.getValueMetaList()) {
                        if (!outputResourceFields.contains(field.getName())) {
                            try {
                                out.removeValueMeta(field.getName());
                            } catch (KettleValueException e) {
                            // could not find it in the output, skip it
                            }
                        }
                    }
                } else {
                    // assume all fields are written
                    out = rowMetaInterface;
                }
                break;
            }
            outputRows.put(RESOURCE, out);
        }
    }
    return outputRows;
}
Also used : 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