use of org.knime.core.node.dialog.ExternalNodeData.ExternalNodeDataBuilder in project knime-core by knime.
the class WizardPageManager method applyWorkflowParameters.
/**
* Applies a given map of workflow parameters to the current workflow
*
* @param parameterMap a map with parameter name as key and parameter string value as value
* @throws InvalidSettingsException If a parameter name is not valid or a not uniquely defined in the workflow or if the parameter value does not validate.
*/
public void applyWorkflowParameters(final Map<String, String> parameterMap) throws InvalidSettingsException {
try (WorkflowLock lock = getWorkflowManager().lock()) {
if (parameterMap.size() > 0) {
Map<String, ExternalNodeData> inputData = new HashMap<String, ExternalNodeData>(parameterMap.size());
for (String key : parameterMap.keySet()) {
ExternalNodeDataBuilder dataBuilder = ExternalNodeData.builder(key);
dataBuilder.stringValue(parameterMap.get(key));
inputData.put(key, dataBuilder.build());
}
try {
// FIXME: This call should happen on the WizardExecutionController, once there is no potential version issues
getWorkflowManager().setInputNodes(inputData);
} catch (Exception ex) {
String errorPrefix = "Could not set workflow parameters: ";
String errorMessage = ex.getMessage();
if (!errorMessage.startsWith(errorPrefix)) {
errorMessage = errorPrefix + ex.getMessage();
}
throw new InvalidSettingsException(errorMessage, ex);
}
}
}
}
Aggregations