Search in sources :

Example 46 with InvalidSettingsException

use of org.knime.core.node.InvalidSettingsException in project knime-core by knime.

the class MetaNodeTemplateInformation method load.

/**
 * Load information from argument, throw {@link InvalidSettingsException}
 * if that fails.
 * @param settings To load from.
 * @param version The version this workflow is loading from
 * @return a new template loading from the argument settings.
 * @throws InvalidSettingsException If that fails.
 */
public static MetaNodeTemplateInformation load(final NodeSettingsRO settings, final FileWorkflowPersistor.LoadVersion version) throws InvalidSettingsException {
    if (!settings.containsKey(CFG_TEMPLATE_INFO)) {
        return NONE;
    }
    NodeSettingsRO nestedSettings = settings.getNodeSettings(CFG_TEMPLATE_INFO);
    String roleS = nestedSettings.getString("role");
    Role role;
    Date timestamp;
    URI sourceURI;
    TemplateType templateType;
    try {
        role = Role.valueOf(roleS);
    } catch (Exception e) {
        throw new InvalidSettingsException("Cannot parse template role \"" + roleS + "\": " + e.getMessage(), e);
    }
    switch(role) {
        case None:
            return NONE;
        case Template:
            sourceURI = null;
            timestamp = readTimestamp(nestedSettings);
            templateType = readTemplateType(nestedSettings, version);
            break;
        case Link:
            sourceURI = readURI(nestedSettings);
            templateType = null;
            timestamp = readTimestamp(nestedSettings);
            break;
        default:
            throw new InvalidSettingsException("Unsupported role: " + role);
    }
    return new MetaNodeTemplateInformation(role, templateType, sourceURI, timestamp);
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) URI(java.net.URI) Date(java.util.Date) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) ParseException(java.text.ParseException)

Example 47 with InvalidSettingsException

use of org.knime.core.node.InvalidSettingsException in project knime-core by knime.

the class MetaNodeTemplateInformation method readTemplateType.

/**
 * Read type, only called for templates.
 * @param settings ...
 * @param loadVersion ...
 * @return non-null template type.
 * @throws InvalidSettingsException ...
 */
private static TemplateType readTemplateType(final NodeSettingsRO settings, final LoadVersion loadVersion) throws InvalidSettingsException {
    if (loadVersion.isOlderThan(LoadVersion.V2100)) {
        // no subnode prio 2.10
        return TemplateType.MetaNode;
    }
    String s = settings.getString("templateType");
    CheckUtils.checkSetting(s != null, "Template type must not be null");
    try {
        return TemplateType.valueOf(s);
    } catch (IllegalArgumentException iae) {
        throw new InvalidSettingsException("Invalid template type \"" + s + "\"", iae);
    }
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException)

Example 48 with InvalidSettingsException

use of org.knime.core.node.InvalidSettingsException in project knime-core by knime.

the class MetaNodeTemplateInformation method createLinkWithUpdatedSource.

/**
 * Create a new link template info based on this template (which must be a link already), which is supposed to be
 * accessible under the argument URI.
 *
 * @param newSource The sourceURI, must not be null.
 * @return a new template linking to the argument URI, using the timestamp of this object.
 * @throws InvalidSettingsException If this object is not a template.
 * @since 2.8
 */
public MetaNodeTemplateInformation createLinkWithUpdatedSource(final URI newSource) throws InvalidSettingsException {
    if (newSource == null) {
        throw new NullPointerException("Can't create link to null URI");
    }
    switch(getRole()) {
        case Link:
            Date ts = getTimestamp();
            assert ts != null : "Templates must not have null timestamp";
            MetaNodeTemplateInformation newInfo = new MetaNodeTemplateInformation(Role.Link, null, newSource, ts);
            newInfo.m_updateStatus = m_updateStatus;
            return newInfo;
        default:
            throw new InvalidSettingsException("Can't link to metanode of role" + " \"" + getRole() + "\" (URI: \"" + m_sourceURI + "\")");
    }
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) Date(java.util.Date)

Example 49 with InvalidSettingsException

use of org.knime.core.node.InvalidSettingsException in project knime-core by knime.

the class NodeContainer method continueExecutionOnLoad.

/**
 * Called upon load when the node has been saved as remotely executing.
 * @param inData The input data for continued execution.
 * @param settings the reconnect settings.
 * @throws InvalidSettingsException If the settings are invalid
 * @throws NodeExecutionJobReconnectException If that fails for any reason.
 */
void continueExecutionOnLoad(final PortObject[] inData, final NodeSettingsRO settings) throws InvalidSettingsException, NodeExecutionJobReconnectException {
    synchronized (m_nodeMutex) {
        switch(getInternalState()) {
            case EXECUTINGREMOTELY:
                NodeExecutionJobManager jobManager = findJobManager();
                try {
                    NodeExecutionJob job = jobManager.loadFromReconnectSettings(settings, inData, this);
                    setExecutionJob(job);
                // setState(State.EXECUTINGREMOTELY, false);
                } catch (NodeExecutionJobReconnectException t) {
                    throw t;
                } catch (InvalidSettingsException t) {
                    throw t;
                } catch (Throwable t) {
                    throw new InvalidSettingsException("Failed to continue job on job manager \"" + jobManager + "\": " + t.getMessage(), t);
                }
                return;
            default:
                throwIllegalStateException();
        }
    }
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) ThreadNodeExecutionJobManager(org.knime.core.node.exec.ThreadNodeExecutionJobManager)

Example 50 with InvalidSettingsException

use of org.knime.core.node.InvalidSettingsException in project knime-core by knime.

the class NodeContainer method areDialogSettingsValid.

public boolean areDialogSettingsValid() {
    CheckUtils.checkState(hasDialog(), "Node \"%s\" has no dialog", getName());
    NodeSettings sett = new NodeSettings("node settings");
    NodeContext.pushContext(this);
    try {
        getDialogPane().finishEditingAndSaveSettingsTo(sett);
        validateSettings(sett);
        return true;
    } catch (InvalidSettingsException nce) {
        return false;
    } finally {
        NodeContext.removeLastContext();
    }
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) InvalidSettingsException(org.knime.core.node.InvalidSettingsException)

Aggregations

InvalidSettingsException (org.knime.core.node.InvalidSettingsException)818 DataTableSpec (org.knime.core.data.DataTableSpec)278 DataColumnSpec (org.knime.core.data.DataColumnSpec)211 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)153 NodeSettingsRO (org.knime.core.node.NodeSettingsRO)121 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)113 IOException (java.io.IOException)109 DataCell (org.knime.core.data.DataCell)99 ArrayList (java.util.ArrayList)96 DataType (org.knime.core.data.DataType)89 PortObjectSpec (org.knime.core.node.port.PortObjectSpec)82 File (java.io.File)72 DataColumnSpecCreator (org.knime.core.data.DataColumnSpecCreator)69 DataRow (org.knime.core.data.DataRow)66 DoubleValue (org.knime.core.data.DoubleValue)58 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)48 SettingsModelFilterString (org.knime.core.node.defaultnodesettings.SettingsModelFilterString)47 FileInputStream (java.io.FileInputStream)43 LinkedHashMap (java.util.LinkedHashMap)42 NotConfigurableException (org.knime.core.node.NotConfigurableException)41