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);
}
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);
}
}
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 + "\")");
}
}
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();
}
}
}
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();
}
}
Aggregations