Search in sources :

Example 1 with SinglePageWebResourceController

use of org.knime.core.node.workflow.SinglePageWebResourceController 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);
        }
    }
}
Also used : WorkflowLock(org.knime.core.node.workflow.WorkflowLock) SinglePageWebResourceController(org.knime.core.node.workflow.SinglePageWebResourceController)

Example 2 with SinglePageWebResourceController

use of org.knime.core.node.workflow.SinglePageWebResourceController in project knime-core by knime.

the class SinglePageManager method createWizardPage.

/**
 * Creates a wizard page object from a given node id
 *
 * @param containerNodeID the node id to create the wizard page for
 * @return a {@link JSONWebNodePage} object which can be used for serialization
 * @throws IOException if the layout of the wizard page can not be generated
 */
public JSONWebNodePage createWizardPage(final NodeID containerNodeID) throws IOException {
    SinglePageWebResourceController sec = getController(containerNodeID);
    WizardPageContent page = sec.getWizardPage();
    return createWizardPageInternal(page);
}
Also used : SinglePageWebResourceController(org.knime.core.node.workflow.SinglePageWebResourceController) WizardPageContent(org.knime.core.node.workflow.WebResourceController.WizardPageContent)

Example 3 with SinglePageWebResourceController

use of org.knime.core.node.workflow.SinglePageWebResourceController in project knime-core by knime.

the class SinglePageManager method createWizardPageViewValueMap.

/**
 * Creates a map of node id string to JSON view value string for all appropriate wizard nodes from a given node id.
 *
 * @param containerNodeID the node id to create the view value map for
 * @return a map containing all appropriate view values
 * @throws IOException on serialization error
 */
public Map<String, String> createWizardPageViewValueMap(final NodeID containerNodeID) throws IOException {
    SinglePageWebResourceController sec = getController(containerNodeID);
    Map<NodeIDSuffix, WebViewContent> viewMap = sec.getWizardPageViewValueMap();
    Map<String, String> resultMap = new HashMap<String, String>();
    for (Entry<NodeIDSuffix, WebViewContent> entry : viewMap.entrySet()) {
        WebViewContent c = entry.getValue();
        resultMap.put(entry.getKey().toString(), new String(((ByteArrayOutputStream) c.saveToStream()).toByteArray()));
    }
    return resultMap;
}
Also used : WebViewContent(org.knime.core.node.web.WebViewContent) NodeIDSuffix(org.knime.core.node.workflow.NodeID.NodeIDSuffix) HashMap(java.util.HashMap) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SinglePageWebResourceController(org.knime.core.node.workflow.SinglePageWebResourceController)

Aggregations

SinglePageWebResourceController (org.knime.core.node.workflow.SinglePageWebResourceController)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 HashMap (java.util.HashMap)1 WebViewContent (org.knime.core.node.web.WebViewContent)1 NodeIDSuffix (org.knime.core.node.workflow.NodeID.NodeIDSuffix)1 WizardPageContent (org.knime.core.node.workflow.WebResourceController.WizardPageContent)1 WorkflowLock (org.knime.core.node.workflow.WorkflowLock)1