use of org.knime.base.node.preproc.columnTrans.One2ManyCellFactory in project knime-core by knime.
the class One2ManyColPMMLNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
DataTableSpec inDataSpec = (DataTableSpec) inSpecs[0];
m_appendOrgColName = false;
if (m_includedColumns.getIncludeList() == null || m_includedColumns.getIncludeList().size() <= 0) {
setWarningMessage("No columns to transfrom selected. Will have no effect!");
}
// check if the values are present in the current spec
if (m_includedColumns.getIncludeList() != null && m_includedColumns.getIncludeList().size() > 0) {
checkColumnsSpecs(inDataSpec);
}
CellFactory cellFactory = new One2ManyCellFactory(inDataSpec, m_includedColumns.getIncludeList(), m_appendOrgColName);
ColumnRearranger rearranger = createRearranger(inDataSpec, cellFactory);
if (m_pmmlEnabled) {
PMMLPortObjectSpec pmmlSpec = (PMMLPortObjectSpec) inSpecs[1];
PMMLPortObjectSpecCreator pmmlSpecCreator = new PMMLPortObjectSpecCreator(pmmlSpec, inDataSpec);
return new PortObjectSpec[] { rearranger.createSpec(), pmmlSpecCreator.createSpec() };
} else {
return new PortObjectSpec[] { rearranger.createSpec() };
}
}
use of org.knime.base.node.preproc.columnTrans.One2ManyCellFactory in project knime-core by knime.
the class One2ManyColPMMLNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inObjects, final ExecutionContext exec) throws Exception {
BufferedDataTable inData = (BufferedDataTable) inObjects[0];
DataTableSpec dts = inData.getDataTableSpec();
checkColumnsSpecs(dts);
One2ManyCellFactory cellFactory = new One2ManyCellFactory(dts, m_includedColumns.getIncludeList(), m_appendOrgColName);
BufferedDataTable outData = exec.createColumnRearrangeTable(inData, createRearranger(dts, cellFactory), exec);
if (m_pmmlEnabled) {
// the optional PMML in port (can be null)
PMMLPortObject inPMMLPort = (PMMLPortObject) inObjects[1];
PMMLOne2ManyTranslator trans = new PMMLOne2ManyTranslator(cellFactory.getColumnMapping(), new DerivedFieldMapper(inPMMLPort));
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 };
}
}
Aggregations