use of org.knime.base.node.jsnippet.util.FlowVariableRepository in project knime-core by knime.
the class JavaEditVarNodeModel method performExecute.
/**
*/
private void performExecute(final ExecutionContext exec) {
FlowVariableRepository flowVarRepo = new FlowVariableRepository(getAvailableInputFlowVariables());
m_snippet.execute(flowVarRepo, exec);
for (FlowVariable var : flowVarRepo.getModified()) {
Type type = var.getType();
if (type.equals(Type.INTEGER)) {
pushFlowVariableInt(var.getName(), var.getIntValue());
} else if (type.equals(Type.DOUBLE)) {
pushFlowVariableDouble(var.getName(), var.getDoubleValue());
} else {
// case: type.equals(Type.STRING)
pushFlowVariableString(var.getName(), var.getStringValue());
}
}
}
use of org.knime.base.node.jsnippet.util.FlowVariableRepository in project knime-core by knime.
the class JavaEditVarNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
m_snippet.setSettings(m_settings);
FlowVariableRepository flowVarRepository = new FlowVariableRepository(getAvailableInputFlowVariables());
ValidationReport report = m_snippet.validateSettings(new DataTableSpec(), flowVarRepository);
if (report.hasWarnings()) {
setWarningMessage(StringUtils.join(report.getWarnings(), "\n"));
}
if (report.hasErrors()) {
throw new InvalidSettingsException(StringUtils.join(report.getErrors(), "\n"));
}
m_snippet.configure(new DataTableSpec(), flowVarRepository);
for (FlowVariable flowVar : flowVarRepository.getModified()) {
if (flowVar.getType().equals(Type.INTEGER)) {
pushFlowVariableInt(flowVar.getName(), flowVar.getIntValue());
} else if (flowVar.getType().equals(Type.DOUBLE)) {
pushFlowVariableDouble(flowVar.getName(), flowVar.getDoubleValue());
} else {
pushFlowVariableString(flowVar.getName(), flowVar.getStringValue());
}
}
// execute if execute on config flag is set
if (!m_settings.isRunOnExecute()) {
performExecute(null);
}
return new PortObjectSpec[] { FlowVariablePortObjectSpec.INSTANCE };
}
use of org.knime.base.node.jsnippet.util.FlowVariableRepository in project knime-core by knime.
the class JavaSnippetNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected DataTableSpec[] configure(final DataTableSpec[] inSpecs) throws InvalidSettingsException {
m_snippet.setSettings(m_settings);
FlowVariableRepository flowVarRepository = new FlowVariableRepository(getAvailableInputFlowVariables());
// The following method also compile-checks the code and checks for missing converter factories
ValidationReport report = m_snippet.validateSettings(inSpecs[0], flowVarRepository);
if (report.hasWarnings()) {
setWarningMessage(StringUtils.join(report.getWarnings(), "\n"));
}
if (report.hasErrors()) {
throw new InvalidSettingsException(StringUtils.join(report.getErrors(), "\n"));
}
DataTableSpec outSpec = m_snippet.configure(inSpecs[0], flowVarRepository);
for (FlowVariable flowVar : flowVarRepository.getModified()) {
if (flowVar.getType().equals(Type.INTEGER)) {
pushFlowVariableInt(flowVar.getName(), flowVar.getIntValue());
} else if (flowVar.getType().equals(Type.DOUBLE)) {
pushFlowVariableDouble(flowVar.getName(), flowVar.getDoubleValue());
} else {
pushFlowVariableString(flowVar.getName(), flowVar.getStringValue());
}
}
return new DataTableSpec[] { outSpec };
}
use of org.knime.base.node.jsnippet.util.FlowVariableRepository in project knime-core by knime.
the class JavaSnippetNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected BufferedDataTable[] execute(final BufferedDataTable[] inData, final ExecutionContext exec) throws Exception {
m_snippet.setSettings(m_settings);
FlowVariableRepository flowVarRepo = new FlowVariableRepository(getAvailableInputFlowVariables());
BufferedDataTable output = m_snippet.execute(inData[0], flowVarRepo, exec);
for (FlowVariable var : flowVarRepo.getModified()) {
Type type = var.getType();
if (type.equals(Type.INTEGER)) {
pushFlowVariableInt(var.getName(), var.getIntValue());
} else if (type.equals(Type.DOUBLE)) {
pushFlowVariableDouble(var.getName(), var.getDoubleValue());
} else {
// case: type.equals(Type.STRING)
pushFlowVariableString(var.getName(), var.getStringValue());
}
}
return new BufferedDataTable[] { output };
}
use of org.knime.base.node.jsnippet.util.FlowVariableRepository in project knime-core by knime.
the class JavaSnippetNodeModel method createColumnRearranger.
/**
* {@inheritDoc}
*/
@Override
protected ColumnRearranger createColumnRearranger(final DataTableSpec spec, final long rowCount) throws InvalidSettingsException {
m_snippet.setSettings(m_settings);
final FlowVariableRepository flowVarRepo = new FlowVariableRepository(getAvailableInputFlowVariables());
return m_snippet.createRearranger(spec, flowVarRepo, (int) rowCount, null);
}
Aggregations