use of org.knime.core.node.workflow.WorkflowLock in project knime-core by knime.
the class SinglePageManager method applyValidatedViewValues.
/**
* Applies a given map of view values to a given subnode which have already been validated.
* @param viewValues an already validated map with {@link NodeIDSuffix} string as key and parsed view value as value
* @param containerNodeId the {@link NodeID} of the subnode
* @param useAsDefault true, if values are supposed to be applied as new defaults, false if applied temporarily
* @throws IOException on serialization error
*/
public void applyValidatedViewValues(final Map<String, String> viewValues, final NodeID containerNodeId, final boolean useAsDefault) throws IOException {
try (WorkflowLock lock = getWorkflowManager().lock()) {
/*ObjectMapper mapper = new ObjectMapper();
for (String key : viewValues.keySet()) {
String content = mapper.writeValueAsString(viewValues.get(key));
viewValues.put(key, content);
}*/
if (!viewValues.isEmpty()) {
SinglePageWebResourceController sec = getController(containerNodeId);
sec.loadValuesIntoPage(viewValues, false, useAsDefault);
}
}
}
use of org.knime.core.node.workflow.WorkflowLock in project knime-core by knime.
the class AbstractPageManager method validateValueMap.
/**
* Validates a value map using a JSON mapper.
* @param valueMap the map to validate
* @return a validated map of view values
* @throws IOException on serialization error
*/
protected Map<String, String> validateValueMap(final Map<String, String> valueMap) throws IOException {
try (WorkflowLock lock = m_wfm.lock()) {
ObjectMapper mapper = new ObjectMapper();
for (String key : valueMap.keySet()) {
String content = mapper.writeValueAsString(valueMap.get(key));
valueMap.put(key, content);
}
return valueMap;
}
}
use of org.knime.core.node.workflow.WorkflowLock 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);
}
}
}
}
use of org.knime.core.node.workflow.WorkflowLock in project knime-core by knime.
the class MetaNodeToSubNodeResult method undo.
/**
* Perform the undo.
*/
public void undo() {
try (WorkflowLock lock = m_wfm.lock()) {
// prevent events to be sent too early
m_wfm.removeNode(m_nodeID);
m_wfm.paste(m_undoPersistor);
}
}
use of org.knime.core.node.workflow.WorkflowLock in project knime-core by knime.
the class CollapseIntoMetaNodeResult method undo.
public void undo() {
WorkflowManager hostWFM = m_hostWFM;
try (WorkflowLock l = m_hostWFM.lock()) {
m_hostWFM.removeNode(m_collapsedMetanodeID);
hostWFM.paste(m_undoCopyPersistor);
}
}
Aggregations