Search in sources :

Example 6 with ColumnCalculator

use of org.knime.ext.sun.nodes.script.calculator.ColumnCalculator in project knime-core by knime.

the class StringManipulationNodeModel method createColumnRearranger.

private ColumnRearranger createColumnRearranger(final DataTableSpec spec) throws InvalidSettingsException {
    if (m_settings == null || m_settings.getExpression() == null) {
        throw new InvalidSettingsException("No expression has been set.");
    }
    boolean isReplace = m_settings.isReplace();
    String colName = m_settings.getColName();
    JavaScriptingSettings settings = m_settings.createJavaScriptingSettings();
    try {
        settings.setInputAndCompile(spec);
        ColumnCalculator cc = new ColumnCalculator(settings, this);
        ColumnRearranger result = new ColumnRearranger(spec);
        if (isReplace) {
            result.replace(cc, colName);
        } else {
            result.append(cc);
        }
        return result;
    } catch (Exception e) {
        throw new InvalidSettingsException(e.getMessage(), e);
    }
}
Also used : ColumnRearranger(org.knime.core.data.container.ColumnRearranger) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) ColumnCalculator(org.knime.ext.sun.nodes.script.calculator.ColumnCalculator) JavaScriptingSettings(org.knime.ext.sun.nodes.script.settings.JavaScriptingSettings) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) IOException(java.io.IOException)

Aggregations

ColumnCalculator (org.knime.ext.sun.nodes.script.calculator.ColumnCalculator)6 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)5 IOException (java.io.IOException)4 DataCell (org.knime.core.data.DataCell)4 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)4 DataTableSpec (org.knime.core.data.DataTableSpec)2 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)2 JavaScriptingSettings (org.knime.ext.sun.nodes.script.settings.JavaScriptingSettings)2 NoSuchElementException (java.util.NoSuchElementException)1 DataRow (org.knime.core.data.DataRow)1 RowKey (org.knime.core.data.RowKey)1 DefaultRow (org.knime.core.data.def.DefaultRow)1 DoubleCell (org.knime.core.data.def.DoubleCell)1 BufferedDataTableRowOutput (org.knime.core.node.streamable.BufferedDataTableRowOutput)1 RowOutput (org.knime.core.node.streamable.RowOutput)1 FlowVariable (org.knime.core.node.workflow.FlowVariable)1 UniqueNameGenerator (org.knime.core.util.UniqueNameGenerator)1