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());
}
}
}
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();
}
}
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;
}
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;
}
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;
}
Aggregations