use of org.knime.core.node.wizard.WizardNode in project knime-core by knime.
the class WebResourceController method loadViewValues.
@SuppressWarnings("rawtypes")
private static void loadViewValues(final Map<String, String> filteredViewContentMap, final Map<NodeID, NativeNodeContainer> wizardNodeSet, final WorkflowManager manager, final boolean useAsDefault) {
for (Map.Entry<String, String> entry : filteredViewContentMap.entrySet()) {
NodeID.NodeIDSuffix suffix = NodeID.NodeIDSuffix.fromString(entry.getKey());
NodeID id = suffix.prependParent(manager.getProjectWFM().getID());
NativeNodeContainer wizardNode = wizardNodeSet.get(id);
try {
if (wizardNode.getNodeModel() instanceof WizardNode) {
loadViewValueForWizardNode(wizardNode, (WizardNode) wizardNode.getNodeModel(), entry.getValue(), useAsDefault);
} else if (wizardNode.getNode().getFactory() instanceof WizardPageContribution) {
((WizardPageContribution) wizardNode.getNode().getFactory()).loadViewValue(wizardNode, entry.getValue());
} else {
throw new IllegalStateException("The node '" + wizardNode.getNameWithID() + "' doesn't contribute to a wizard page. View values can't be loaded.");
}
} catch (Exception e) {
LOGGER.error("Failed to load view value into node \"" + wizardNode.getID() + "\" although validation succeeded", e);
}
}
}
use of org.knime.core.node.wizard.WizardNode in project knime-core by knime.
the class WebResourceController method processViewRequestInternal.
/**
* Retrieves the response for a view request, which is from a node within a subnode
*
* @param subnodeID the node id of the subnode container
* @param nodeID the node id of the wizard node, as fetched from the combined view
* @param viewRequest the JSON serialized view request string
* @param exec the execution monitor to set progress and check possible cancellation
* @return a {@link WizardViewResponse} which is generated by the concrete node
* @throws ViewRequestHandlingException If the request handling or response generation fails for any
* reason.
* @throws InterruptedException If the thread handling the request is interrupted.
* @throws CanceledExecutionException If the handling of the request was canceled e.g. by user
* intervention.
* @since 3.7
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
protected WizardViewResponse processViewRequestInternal(final NodeID subnodeID, final String nodeID, final String viewRequest, final ExecutionMonitor exec) throws ViewRequestHandlingException, InterruptedException, CanceledExecutionException {
WorkflowManager manager = m_manager;
assert manager.isLockedByCurrentThread();
NodeID.NodeIDSuffix suffix = NodeID.NodeIDSuffix.fromString(nodeID);
NodeID id = suffix.prependParent(manager.getID());
WizardNode model = getWizardNodeForVerifiedID(subnodeID, id);
if (model == null || !(model instanceof WizardViewRequestHandler)) {
throw new ViewRequestHandlingException("Node model can not process view requests. Possible implementation error.");
}
WizardViewRequest req = ((WizardViewRequestHandler) model).createEmptyViewRequest();
try {
req.loadFromStream(new ByteArrayInputStream(viewRequest.getBytes(Charset.forName("UTF-8"))));
} catch (IOException ex) {
throw new ViewRequestHandlingException("Error deserializing request: " + ex.getMessage(), ex);
}
return (WizardViewResponse) ((WizardViewRequestHandler) model).handleRequest(req, exec);
}
Aggregations