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