use of org.pentaho.di.core.row.ValueMetaInterface 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.row.ValueMetaInterface in project pentaho-kettle by pentaho.
the class TransDataLineage method calculateLineage.
/**
* Using the transformation, we will calculate the data lineage for each field in each step.
*
* @throws KettleStepException
* In case there is an exception calculating the lineage. This is usually caused by unavailable data sources
* etc.
*/
public void calculateLineage() throws KettleStepException {
// After sorting the steps we get a map of all the previous steps of a certain step.
//
final Map<StepMeta, Map<StepMeta, Boolean>> stepMap = transMeta.sortStepsNatural();
// However, the we need a sorted list of previous steps per step, not a map.
// So lets sort the maps, turn them into lists...
//
Map<StepMeta, List<StepMeta>> previousStepListMap = new HashMap<StepMeta, List<StepMeta>>();
for (StepMeta stepMeta : stepMap.keySet()) {
List<StepMeta> previousSteps = new ArrayList<StepMeta>();
previousStepListMap.put(stepMeta, previousSteps);
previousSteps.addAll(stepMap.get(stepMeta).keySet());
// Sort this list...
//
Collections.sort(previousSteps, new Comparator<StepMeta>() {
public int compare(StepMeta o1, StepMeta o2) {
Map<StepMeta, Boolean> beforeMap = stepMap.get(o1);
if (beforeMap != null) {
if (beforeMap.get(o2) == null) {
return -1;
} else {
return 1;
}
} else {
return o1.getName().compareToIgnoreCase(o2.getName());
}
}
});
System.out.println("Step considered: " + stepMeta.getName());
for (StepMeta prev : previousSteps) {
System.out.println(" --> previous step: " + prev.getName());
}
}
fieldStepsMap = new HashMap<ValueMetaInterface, List<StepMeta>>();
List<StepMeta> usedSteps = transMeta.getUsedSteps();
for (StepMeta stepMeta : usedSteps) {
calculateLineage(stepMeta);
}
}
use of org.pentaho.di.core.row.ValueMetaInterface in project pentaho-kettle by pentaho.
the class GetXMLDataStepAnalyzerTest method testGetInputRowMetaInterfaces_isNotInField.
@Test
public void testGetInputRowMetaInterfaces_isNotInField() throws Exception {
Map<String, RowMetaInterface> inputs = new HashMap<>();
RowMetaInterface inputRmi = mock(RowMetaInterface.class);
List<ValueMetaInterface> vmis = new ArrayList<>();
ValueMetaInterface vmi = new ValueMeta("filename");
vmis.add(vmi);
when(inputRmi.getValueMetaList()).thenReturn(vmis);
inputs.put("test", inputRmi);
doReturn(inputs).when(analyzer).getInputFields(meta);
when(parentTransMeta.getPrevStepNames(parentStepMeta)).thenReturn(null);
RowMetaInterface rowMetaInterface = new RowMeta();
rowMetaInterface.addValueMeta(vmi);
ValueMetaInterface vmi2 = new ValueMeta("otherField");
rowMetaInterface.addValueMeta(vmi2);
doReturn(rowMetaInterface).when(analyzer).getOutputFields(meta);
when(meta.isInFields()).thenReturn(false);
when(meta.getIsAFile()).thenReturn(false);
when(meta.isReadUrl()).thenReturn(false);
Map<String, RowMetaInterface> rowMetaInterfaces = analyzer.getInputRowMetaInterfaces(meta);
assertNotNull(rowMetaInterfaces);
assertEquals(2, rowMetaInterfaces.size());
RowMetaInterface metaInterface = rowMetaInterfaces.get(ExternalResourceStepAnalyzer.RESOURCE);
// the row meta interface should only have 1 value meta in it, and it should NOT be filename
assertEquals(1, metaInterface.size());
assertEquals("otherField", metaInterface.getFieldNames()[0]);
}
use of org.pentaho.di.core.row.ValueMetaInterface in project pentaho-kettle by pentaho.
the class GetXMLDataTest method createResultRowMetaInterface.
public RowMetaInterface createResultRowMetaInterface() {
RowMetaInterface rm = new RowMeta();
ValueMetaInterface[] valuesMeta = { new ValueMeta("field1", ValueMeta.TYPE_STRING), new ValueMeta("objectid", ValueMeta.TYPE_STRING), new ValueMeta("sapident", ValueMeta.TYPE_STRING), new ValueMeta("quantity", ValueMeta.TYPE_STRING), new ValueMeta("merkmalname", ValueMeta.TYPE_STRING), new ValueMeta("merkmalswert", ValueMeta.TYPE_STRING) };
for (int i = 0; i < valuesMeta.length; i++) {
rm.addValueMeta(valuesMeta[i]);
}
return rm;
}
use of org.pentaho.di.core.row.ValueMetaInterface in project pentaho-kettle by pentaho.
the class XMLOutputMetaTest method testGetRequiredFields.
@Test
public void testGetRequiredFields() throws Exception {
XMLOutputMeta xmlOutputMeta = new XMLOutputMeta();
xmlOutputMeta.setDefault();
XMLField xmlField = new XMLField();
xmlField.setFieldName("aField");
xmlField.setType(1);
xmlField.setLength(10);
xmlField.setPrecision(3);
XMLField xmlField2 = new XMLField();
xmlField2.setFieldName("bField");
xmlField2.setType(3);
xmlField2.setLength(4);
xmlField2.setPrecision(5);
xmlOutputMeta.setOutputFields(new XMLField[] { xmlField, xmlField2 });
RowMetaInterface requiredFields = xmlOutputMeta.getRequiredFields(new Variables());
List<ValueMetaInterface> valueMetaList = requiredFields.getValueMetaList();
assertEquals(2, valueMetaList.size());
assertEquals("aField", valueMetaList.get(0).getName());
assertEquals(1, valueMetaList.get(0).getType());
assertEquals(10, valueMetaList.get(0).getLength());
assertEquals(3, valueMetaList.get(0).getPrecision());
assertEquals("bField", valueMetaList.get(1).getName());
assertEquals(3, valueMetaList.get(1).getType());
assertEquals(4, valueMetaList.get(1).getLength());
assertEquals(5, valueMetaList.get(1).getPrecision());
}
Aggregations