Search in sources :

Example 1 with NodeMessage

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

the class Node method createWarningMessageAndNotify.

/**
 * Creates a new {@link NodeMessage} object of type warning and notifies
 * registered {@link NodeMessageListener}s. Also logs a warning message.
 * If a throwable is provided its stacktrace is logged at debug level.
 *
 * @noreference This method is not intended to be referenced by clients.
 * @param warningMessage the new warning message
 * @param t its stacktrace is logged at debug level.
 */
public void createWarningMessageAndNotify(final String warningMessage, final Throwable t) {
    LOGGER.warn(warningMessage);
    if (t != null) {
        LOGGER.debug(warningMessage, t);
    }
    notifyMessageListeners(new NodeMessage(NodeMessage.Type.WARNING, warningMessage));
}
Also used : NodeMessage(org.knime.core.node.workflow.NodeMessage)

Example 2 with NodeMessage

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

the class ExecutionResultFixtures method setGeneralNodeContainerProperties.

/**
 * Sets the properties defined by the abstract {@link NodeContainerExecutionResult} class to fixture values.
 *
 * @param execResult Object to set properties on.
 * @param errorMsg An error message to set (as part of {@link NodeMessage})
 */
public static void setGeneralNodeContainerProperties(final NodeContainerExecutionResult execResult, final String errorMsg) {
    execResult.setMessage(new NodeMessage(Type.ERROR, errorMsg));
    execResult.setNeedsResetAfterLoad();
    execResult.setSuccess(true);
}
Also used : NodeMessage(org.knime.core.node.workflow.NodeMessage)

Example 3 with NodeMessage

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

the class Node method createErrorMessageAndNotify.

/**
 * Creates a new {@link NodeMessage} object of type error and notifies
 * registered {@link NodeMessageListener}s. Also logs an error message.
 * If a throwable is provided its stacktrace is logged at debug level.
 *
 * @noreference This method is not intended to be referenced by clients.
 * @param errorMessage the new error message
 * @param t its stacktrace is logged at debug level.
 */
public void createErrorMessageAndNotify(final String errorMessage, final Throwable t) {
    LOGGER.error(errorMessage);
    if (t != null) {
        LOGGER.debug(errorMessage, t);
    }
    notifyMessageListeners(new NodeMessage(NodeMessage.Type.ERROR, errorMessage));
}
Also used : NodeMessage(org.knime.core.node.workflow.NodeMessage)

Example 4 with NodeMessage

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

the class AbstractPageManager method createWizardPageInternal.

/**
 * Performs a transformation from {@link WizardPageContent} to {@link JSONWebNodePage} which can be used for serialization.
 * @param page the {@link WizardPageContent} to transform
 * @return the transformed {@link JSONWebNodePage}
 * @throws IOException if layout of page can not be generated
 */
protected JSONWebNodePage createWizardPageInternal(final WizardPageContent page) throws IOException {
    // process layout
    JSONLayoutPage layout = new JSONLayoutPage();
    try {
        String lString = page.getLayoutInfo();
        if (StringUtils.isNotEmpty(lString)) {
            layout = getJSONLayoutFromSubnode(page.getPageNodeID(), page.getLayoutInfo());
        }
    } catch (IOException e) {
        throw new IOException("Layout for page could not be generated: " + e.getMessage(), e);
    }
    // process selection translators
    List<JSONSelectionTranslator> selectionTranslators = new ArrayList<JSONSelectionTranslator>();
    if (page.getHiLiteTranslators() != null) {
        for (HiLiteTranslator hiLiteTranslator : page.getHiLiteTranslators()) {
            if (hiLiteTranslator != null) {
                selectionTranslators.add(new JSONSelectionTranslator(hiLiteTranslator));
            }
        }
    }
    if (page.getHiliteManagers() != null) {
        for (HiLiteManager hiLiteManager : page.getHiliteManagers()) {
            if (hiLiteManager != null) {
                selectionTranslators.add(new JSONSelectionTranslator(hiLiteManager));
            }
        }
    }
    if (selectionTranslators.size() < 1) {
        selectionTranslators = null;
    }
    JSONWebNodePageConfiguration pageConfig = new JSONWebNodePageConfiguration(layout, null, selectionTranslators);
    Map<String, JSONWebNode> nodes = new HashMap<String, JSONWebNode>();
    for (Map.Entry<NodeIDSuffix, WizardPageNodeInfo> e : page.getInfoMap().entrySet()) {
        WizardPageNodeInfo pInfo = e.getValue();
        JSONWebNode jsonNode = new JSONWebNode();
        JSONWebNodeInfo info = new JSONWebNodeInfo();
        info.setNodeName(pInfo.getNodeName());
        info.setNodeAnnotation(pInfo.getNodeAnnotation());
        NodeContainerState state = pInfo.getNodeState();
        if (state.isIdle()) {
            info.setNodeState(JSONNodeState.IDLE);
        }
        if (state.isConfigured()) {
            info.setNodeState(JSONNodeState.CONFIGURED);
        }
        if (state.isExecutionInProgress() || state.isExecutingRemotely()) {
            info.setNodeState(JSONNodeState.EXECUTING);
        }
        if (state.isExecuted()) {
            info.setNodeState(JSONNodeState.EXECUTED);
        }
        NodeMessage message = pInfo.getNodeMessage();
        if (org.knime.core.node.workflow.NodeMessage.Type.ERROR.equals(message.getMessageType())) {
            info.setNodeErrorMessage(message.getMessage());
        }
        if (org.knime.core.node.workflow.NodeMessage.Type.WARNING.equals(message.getMessageType())) {
            info.setNodeWarnMessage(message.getMessage());
        }
        WizardNode<?, ?> wizardNode = page.getPageMap().get(e.getKey());
        if (wizardNode == null) {
            info.setDisplayPossible(false);
        } else {
            info.setDisplayPossible(true);
            WebTemplate template = WebResourceController.getWebTemplateFromJSObjectID(wizardNode.getJavascriptObjectID());
            List<String> jsList = new ArrayList<String>();
            List<String> cssList = new ArrayList<String>();
            for (WebResourceLocator locator : template.getWebResources()) {
                if (locator.getType() == WebResourceType.JAVASCRIPT) {
                    jsList.add(locator.getRelativePathTarget());
                } else if (locator.getType() == WebResourceType.CSS) {
                    cssList.add(locator.getRelativePathTarget());
                }
            }
            jsonNode.setJavascriptLibraries(jsList);
            jsonNode.setStylesheets(cssList);
            jsonNode.setNamespace(template.getNamespace());
            jsonNode.setInitMethodName(template.getInitMethodName());
            jsonNode.setValidateMethodName(template.getValidateMethodName());
            jsonNode.setSetValidationErrorMethodName(template.getSetValidationErrorMethodName());
            jsonNode.setGetViewValueMethodName(template.getPullViewContentMethodName());
            jsonNode.setViewRepresentation((JSONViewContent) wizardNode.getViewRepresentation());
            jsonNode.setViewValue((JSONViewContent) wizardNode.getViewValue());
        }
        jsonNode.setNodeInfo(info);
        nodes.put(e.getKey().toString(), jsonNode);
    }
    return new JSONWebNodePage(pageConfig, nodes);
}
Also used : JSONLayoutPage(org.knime.js.core.layout.bs.JSONLayoutPage) HashMap(java.util.HashMap) JSONWebNodePageConfiguration(org.knime.js.core.JSONWebNodePageConfiguration) ArrayList(java.util.ArrayList) JSONWebNode(org.knime.js.core.JSONWebNode) HiLiteTranslator(org.knime.core.node.property.hilite.HiLiteTranslator) IOException(java.io.IOException) HiLiteManager(org.knime.core.node.property.hilite.HiLiteManager) JSONWebNodePage(org.knime.js.core.JSONWebNodePage) NodeContainerState(org.knime.core.node.workflow.NodeContainerState) WebResourceLocator(org.knime.core.node.web.WebResourceLocator) JSONWebNodeInfo(org.knime.js.core.JSONWebNodeInfo) NodeIDSuffix(org.knime.core.node.workflow.NodeID.NodeIDSuffix) WebTemplate(org.knime.core.node.web.WebTemplate) JSONSelectionTranslator(org.knime.js.core.selections.json.JSONSelectionTranslator) NodeMessage(org.knime.core.node.workflow.NodeMessage) HashMap(java.util.HashMap) Map(java.util.Map) WizardPageNodeInfo(org.knime.core.node.workflow.WebResourceController.WizardPageContent.WizardPageNodeInfo)

Example 5 with NodeMessage

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

the class NodeContainerEditPart method updateNodeMessage.

/**
 * Checks the message of the this node and if there is a message in the <code>NodeStatus</code> object the message
 * is set. Otherwise the currently displayed message is removed.
 */
private void updateNodeMessage() {
    NodeContainerUI nc = getNodeContainer();
    NodeContainerFigure containerFigure = (NodeContainerFigure) getFigure();
    NodeMessage nodeMessage = nc.getNodeMessage();
    containerFigure.setMessage(nodeMessage);
    refreshBounds();
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) SubNodeContainerUI(org.knime.core.ui.node.workflow.SubNodeContainerUI) NodeMessage(org.knime.core.node.workflow.NodeMessage) NodeContainerFigure(org.knime.workbench.editor2.figures.NodeContainerFigure)

Aggregations

NodeMessage (org.knime.core.node.workflow.NodeMessage)5 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 HiLiteManager (org.knime.core.node.property.hilite.HiLiteManager)1 HiLiteTranslator (org.knime.core.node.property.hilite.HiLiteTranslator)1 WebResourceLocator (org.knime.core.node.web.WebResourceLocator)1 WebTemplate (org.knime.core.node.web.WebTemplate)1 NodeContainerState (org.knime.core.node.workflow.NodeContainerState)1 NodeIDSuffix (org.knime.core.node.workflow.NodeID.NodeIDSuffix)1 WizardPageNodeInfo (org.knime.core.node.workflow.WebResourceController.WizardPageContent.WizardPageNodeInfo)1 NodeContainerUI (org.knime.core.ui.node.workflow.NodeContainerUI)1 SubNodeContainerUI (org.knime.core.ui.node.workflow.SubNodeContainerUI)1 JSONWebNode (org.knime.js.core.JSONWebNode)1 JSONWebNodeInfo (org.knime.js.core.JSONWebNodeInfo)1 JSONWebNodePage (org.knime.js.core.JSONWebNodePage)1 JSONWebNodePageConfiguration (org.knime.js.core.JSONWebNodePageConfiguration)1 JSONLayoutPage (org.knime.js.core.layout.bs.JSONLayoutPage)1 JSONSelectionTranslator (org.knime.js.core.selections.json.JSONSelectionTranslator)1