use of org.knime.base.node.preproc.colcompare.ColumnComparatorNodeDialogPane.ComparatorMethod in project knime-core by knime.
the class ColumnComparatorNodeModel method createColumnRearranger.
/**
* {@inheritDoc}
*/
@Override
protected ColumnRearranger createColumnRearranger(final DataTableSpec spec) throws InvalidSettingsException {
final ComparatorMethod method = ComparatorMethod.getMethod(m_operator.getStringValue());
final int idx1 = spec.findColumnIndex(m_firstColumn.getStringValue());
final int idx2 = spec.findColumnIndex(m_secondColumn.getStringValue());
DataColumnSpec leftSpec = spec.getColumnSpec(idx1);
DataColumnSpec rightSpec = spec.getColumnSpec(idx2);
ColumnRearranger colRe = new ColumnRearranger(spec);
colRe.append(new SingleCellFactory(createSpec(leftSpec, rightSpec)) {
private final StringCell m_matchRepl = new StringCell(m_matchValue.getStringValue());
private final StringCell m_mismatchRepl = new StringCell(m_mismatchValue.getStringValue());
@Override
public DataCell getCell(final DataRow row) {
DataCell cell1 = row.getCell(idx1);
DataCell cell2 = row.getCell(idx2);
if (method.compare(cell1, cell2)) {
String strMatch = m_matchOption.getStringValue();
if (strMatch.equals(REPL_OPTIONS[0])) {
return covertMatch(cell1);
} else if (strMatch.equals(REPL_OPTIONS[1])) {
return covertMatch(cell2);
} else if (strMatch.equals(REPL_OPTIONS[2])) {
return DataType.getMissingCell();
} else {
return m_matchRepl;
}
} else {
String strMismatch = m_mismatchOption.getStringValue();
if (strMismatch.equals(REPL_OPTIONS[0])) {
return covertMismatch(cell1);
} else if (strMismatch.equals(REPL_OPTIONS[1])) {
return covertMismatch(cell2);
} else if (strMismatch.equals(REPL_OPTIONS[2])) {
return DataType.getMissingCell();
} else {
return m_mismatchRepl;
}
}
}
});
return colRe;
}
Aggregations