use of org.knime.ext.sun.nodes.script.settings.JavaScriptingSettings in project knime-core by knime.
the class StringManipulationVariableNodeModel method calculate.
/**
* @throws CompilationFailedException
* @throws InstantiationException
* @throws Exception
*/
private void calculate() throws InvalidSettingsException, CompilationFailedException, InstantiationException {
if (m_settings == null || m_settings.getExpression() == null) {
throw new InvalidSettingsException("No expression has been set.");
}
JavaScriptingSettings settings = m_settings.createJavaScriptingSettings();
settings.setInputAndCompile(new DataTableSpec());
// calculate the result
ColumnCalculator cc = new ColumnCalculator(settings, this);
DataCell calculate = null;
try {
calculate = cc.calculate(new DefaultRow(new RowKey(""), new DataCell[] {}));
} catch (NoSuchElementException e) {
throw new InvalidSettingsException(e.getMessage());
}
String newVariableName;
Map<String, FlowVariable> inputFlowVariables = getAvailableInputFlowVariables();
if (m_settings.isReplace()) {
newVariableName = m_settings.getColName();
CheckUtils.checkSettingNotNull(inputFlowVariables.get(newVariableName), "Can't replace input variable '%s' -- it does not exist in the input", newVariableName);
} else {
newVariableName = new UniqueNameGenerator(inputFlowVariables.keySet()).newName(m_settings.getColName());
}
// convert and push result as flow variable
CheckUtils.checkSetting(!calculate.isMissing(), "Calculation returned missing value");
Class<? extends DataCell> cellType = calculate.getClass();
if (cellType.equals(IntCell.class)) {
pushFlowVariableInt(newVariableName, ((IntCell) calculate).getIntValue());
} else if (cellType.equals(DoubleCell.class)) {
pushFlowVariableDouble(newVariableName, ((DoubleCell) calculate).getDoubleValue());
} else if (cellType.equals(StringCell.class)) {
pushFlowVariableString(newVariableName, ((StringCell) calculate).getStringValue());
} else {
throw new RuntimeException("Invalid variable class: " + cellType);
}
}
use of org.knime.ext.sun.nodes.script.settings.JavaScriptingSettings in project knime-core by knime.
the class JavaScriptingNodeDialog method saveSettingsTo.
/**
* {@inheritDoc}
*/
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) throws InvalidSettingsException {
JavaScriptingSettings s = m_customizer.createSettings();
// first save jar panel so that settings contain additional
// libraries that may be required for test compilation
m_jarPanel.saveSettingsTo(s);
m_mainPanel.saveSettingsTo(s);
s.saveSettingsTo(settings);
}
use of org.knime.ext.sun.nodes.script.settings.JavaScriptingSettings in project knime-core by knime.
the class JavaIfSwitchNodeDialogPane method loadSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
JavaScriptingSettings jsSettings = m_customizer.createSettings();
jsSettings.loadSettingsInDialog(settings, JavaIfSwitchNodeModel.EMPTY_SPEC);
m_panel.loadSettingsFrom(jsSettings, JavaIfSwitchNodeModel.EMPTY_SPEC);
}
use of org.knime.ext.sun.nodes.script.settings.JavaScriptingSettings in project knime-core by knime.
the class JavaEditVariableNodeModel method loadValidatedSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadValidatedSettingsFrom(final NodeSettingsRO settings) throws InvalidSettingsException {
JavaScriptingSettings jsSettings = m_customizer.createSettings();
jsSettings.loadSettingsInModel(settings);
m_settings = jsSettings;
}
use of org.knime.ext.sun.nodes.script.settings.JavaScriptingSettings in project knime-core by knime.
the class JavaScriptingNodeDialog method loadSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
JavaScriptingSettings s = m_customizer.createSettings();
s.loadSettingsInDialog(settings, specs[0]);
m_mainPanel.loadSettingsFrom(s, specs[0]);
m_jarPanel.loadSettingsFrom(s);
}
Aggregations