use of org.knime.base.node.preproc.columnTrans.AbstractMany2OneCellFactory in project knime-core by knime.
the class Many2OneColPMMLNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inObjects, final ExecutionContext exec) throws CanceledExecutionException, Exception {
BufferedDataTable inData = (BufferedDataTable) inObjects[0];
AbstractMany2OneCellFactory cellFactory = getCellFactory(inData.getDataTableSpec());
BufferedDataTable outData = exec.createColumnRearrangeTable(inData, createRearranger(inData.getDataTableSpec(), cellFactory), exec);
if (m_pmmlEnabled) {
if (IncludeMethod.valueOf(m_includeMethod.getStringValue()) == IncludeMethod.RegExpPattern) {
setWarningMessage("Regular Expressions are not supported in PMML. " + "The generated PMML document is invalid.");
}
// the optional PMML in port (can be null)
PMMLPortObject inPMMLPort = (PMMLPortObject) inObjects[1];
/*
PMMLOne2ManyTranslator trans = new PMMLOne2ManyTranslator(
cellFactory.getColumnMapping(),
new DerivedFieldMapper(inPMMLPort));
*/
int[] sourceColIndices = cellFactory.getIncludedColIndices();
String[] sourceColNames = new String[sourceColIndices.length];
for (int i = 0; i < sourceColIndices.length; i++) {
sourceColNames[i] = inData.getDataTableSpec().getColumnSpec(sourceColIndices[i]).getName();
}
PMMLMany2OneTranslator trans = new PMMLMany2OneTranslator(cellFactory.getAppendedColumnName(), sourceColNames, IncludeMethod.valueOf(m_includeMethod.getStringValue()));
PMMLPortObjectSpecCreator creator = new PMMLPortObjectSpecCreator(inPMMLPort, outData.getDataTableSpec());
PMMLPortObject outPMMLPort = new PMMLPortObject(creator.createSpec(), inPMMLPort);
outPMMLPort.addGlobalTransformations(trans.exportToTransDict());
return new PortObject[] { outData, outPMMLPort };
} else {
return new PortObject[] { outData };
}
}
use of org.knime.base.node.preproc.columnTrans.AbstractMany2OneCellFactory in project knime-core by knime.
the class Many2OneColPMMLNodeModel method getCellFactory.
private AbstractMany2OneCellFactory getCellFactory(final DataTableSpec spec) {
AbstractMany2OneCellFactory cellFactory;
IncludeMethod method = IncludeMethod.valueOf(m_includeMethod.getStringValue());
int[] includedColIndices = new int[m_includedColumns.getIncludeList().size()];
int index = 0;
for (String colName : m_includedColumns.getIncludeList()) {
includedColIndices[index++] = spec.findColumnIndex(colName);
}
String newColName = DataTableSpec.getUniqueColumnName(spec, m_appendedColumnName.getStringValue());
m_appendedColumnName.setStringValue(newColName);
if (method.equals(IncludeMethod.RegExpPattern)) {
cellFactory = new RegExpCellFactory(spec, newColName, includedColIndices, m_pattern.getStringValue());
} else if (method.equals(IncludeMethod.Minimum)) {
cellFactory = new MinMaxCellFactory(spec, newColName, includedColIndices, false);
} else if (method.equals(IncludeMethod.Binary)) {
cellFactory = new BinaryCellFactory(spec, newColName, includedColIndices);
} else {
cellFactory = new MinMaxCellFactory(spec, newColName, includedColIndices, true);
}
return cellFactory;
}
Aggregations