use of org.knime.core.util.LoadVersion in project knime-core by knime.
the class FileWorkflowPersistor method loadEditorUIInformation.
/**
* Load editor information (grid settings & zoom level).
*
* @param settings ...
* @return null
* @since 2.6
* @throws InvalidSettingsException ...
*/
EditorUIInformation loadEditorUIInformation(final NodeSettingsRO settings) throws InvalidSettingsException {
final LoadVersion loadVersion = getLoadVersion();
if (loadVersion.isOlderThan(LoadVersion.V260) || !settings.containsKey(CFG_EDITOR_INFO)) {
return EditorUIInformation.builder().build();
}
NodeSettingsRO editorCfg = settings.getNodeSettings(CFG_EDITOR_INFO);
EditorUIInformation.Builder builder = EditorUIInformation.builder();
builder.setSnapToGrid(editorCfg.getBoolean(CFG_EDITOR_SNAP_GRID));
builder.setShowGrid(editorCfg.getBoolean(CFG_EDITOR_SHOW_GRID));
builder.setGridX(editorCfg.getInt(CFG_EDITOR_X_GRID));
builder.setGridY(editorCfg.getInt(CFG_EDITOR_Y_GRID));
builder.setZoomLevel(editorCfg.getDouble(CFG_EDITOR_ZOOM));
if (editorCfg.containsKey(CFG_EDITOR_CURVED_CONNECTIONS)) {
builder.setHasCurvedConnections(editorCfg.getBoolean(CFG_EDITOR_CURVED_CONNECTIONS));
}
if (editorCfg.containsKey(CFG_EDITOR_CONNECTION_WIDTH)) {
builder.setConnectionLineWidth(editorCfg.getInt(CFG_EDITOR_CONNECTION_WIDTH));
}
return builder.build();
}
use of org.knime.core.util.LoadVersion in project knime-core by knime.
the class BugAP7982_FutureKNIMEVersion_AllCompatible method loadWorkflow.
/**
* Load workflow, expect no errors.
*/
@Test
public void loadWorkflow() throws Exception {
File wkfDir = getDefaultWorkflowDirectory();
WorkflowLoadResult loadWorkflow = loadWorkflow(wkfDir, new ExecutionMonitor(), new ConfigurableWorkflowLoadHelper(wkfDir) {
@Override
public UnknownKNIMEVersionLoadPolicy getUnknownKNIMEVersionLoadPolicy(final LoadVersion workflowKNIMEVersion, final Version createdByKNIMEVersion, final boolean isNightlyBuild) {
throw new AssertionFailedError("Not to be called - workflow is expected to be compatible");
}
});
setManager(loadWorkflow.getWorkflowManager());
assertThat("Expected to loaded without errors", loadWorkflow.getType(), is(LoadResultEntryType.Ok));
assertThat("Workflow version incorrect", getManager().getLoadVersion(), is(LoadVersion.V280));
}
use of org.knime.core.util.LoadVersion in project knime-core by knime.
the class BugAP7982_FutureKNIMEVersion_FutureVersion method loadWorkflow.
private WorkflowLoadResult loadWorkflow(final boolean tryToLoadInsteadOfFail) throws Exception {
File wkfDir = getDefaultWorkflowDirectory();
WorkflowLoadResult loadWorkflow = loadWorkflow(wkfDir, new ExecutionMonitor(), new ConfigurableWorkflowLoadHelper(wkfDir) {
@Override
public UnknownKNIMEVersionLoadPolicy getUnknownKNIMEVersionLoadPolicy(final LoadVersion workflowKNIMEVersion, final Version createdByKNIMEVersion, final boolean isNightlyBuild) {
assertThat("Unexpected KNIME version in file", workflowKNIMEVersion, is(LoadVersion.FUTURE));
assertThat("Nightly flag wrong", isNightlyBuild, is(m_isExpectNightly));
if (tryToLoadInsteadOfFail) {
return UnknownKNIMEVersionLoadPolicy.Try;
} else {
return UnknownKNIMEVersionLoadPolicy.Abort;
}
}
});
return loadWorkflow;
}
use of org.knime.core.util.LoadVersion in project knime-core by knime.
the class NodeAndBundleInformationPersistor method load.
/**
* Restores the information object from the given node settings object. Used in persistor.
*
* @param settings a node settings object
* @param version the workflow version
* @return bundle info object, at least the factory name will not be <code>null</code>
* @throws InvalidSettingsException if the node settings contain invalid entries
* @noreference This method is not intended to be referenced by clients.
*/
public static NodeAndBundleInformationPersistor load(final NodeSettingsRO settings, final LoadVersion version) throws InvalidSettingsException {
String factoryClass = settings.getString("factory");
if (factoryClass == null) {
throw new InvalidSettingsException("Factory class is null");
}
String bundleSymbolicName;
String bundleName;
String bundleVendor;
String nodeName;
Version bundleVersion;
String featureSymbolicName;
String featureName;
String featureVendor;
Version featureVersion;
if (version.ordinal() < LoadVersion.V260.ordinal()) {
nodeName = null;
bundleName = null;
bundleVendor = null;
bundleSymbolicName = null;
featureSymbolicName = null;
featureName = null;
featureVendor = null;
featureVersion = null;
} else {
nodeName = settings.getString("node-name");
bundleName = settings.getString("node-bundle-name");
bundleSymbolicName = fixExtensionName(settings.getString("node-bundle-symbolic-name"));
bundleVendor = settings.getString("node-bundle-vendor");
featureSymbolicName = fixExtensionName(settings.getString("node-feature-symbolic-name", null));
featureName = settings.getString("node-feature-name", null);
featureVendor = settings.getString("node-feature-vendor", null);
String v = settings.getString("node-feature-version", "");
try {
if (!v.isEmpty()) {
featureVersion = new Version(v);
} else {
featureVersion = null;
}
} catch (IllegalArgumentException iae) {
throw new InvalidSettingsException("Invalid feature version \"" + v + "\"", iae);
}
}
String v = settings.getString("node-bundle-version", "");
try {
if (!v.isEmpty()) {
bundleVersion = new Version(v);
} else {
bundleVersion = null;
}
} catch (IllegalArgumentException iae) {
throw new InvalidSettingsException("Invalid version \"" + v + "\"", iae);
}
return new NodeAndBundleInformationPersistor(factoryClass, bundleSymbolicName, bundleName, bundleVendor, nodeName, bundleVersion, featureSymbolicName, featureName, featureVendor, featureVersion);
}
use of org.knime.core.util.LoadVersion in project knime-core by knime.
the class SubNodeContainer method performLoadContent.
/**
* {@inheritDoc}
*/
@Override
WorkflowCopyContent performLoadContent(final SingleNodeContainerPersistor nodePersistor, final Map<Integer, BufferedDataTable> tblRep, final FlowObjectStack inStack, final ExecutionMonitor exec, final LoadResult loadResult, final boolean preserveNodeMessage) throws CanceledExecutionException {
SubNodeContainerPersistor subNodePersistor = (SubNodeContainerPersistor) nodePersistor;
WorkflowPersistor workflowPersistor = subNodePersistor.getWorkflowPersistor();
// TODO pass in a filter input stack
m_wfm.loadContent(workflowPersistor, tblRep, inStack, exec, loadResult, preserveNodeMessage);
if (workflowPersistor.isDirtyAfterLoad() || m_wfm.isDirty()) {
setDirty();
}
InternalNodeContainerState loadState = nodePersistor.getMetaPersistor().getState();
if (!m_wfm.getInternalState().equals(loadState)) {
// can happen for workflows that were exported without data;
// the same check is done by the caller (WorkflowManager#postLoad) and handled appropriately
setInternalState(m_wfm.getInternalState(), false);
}
NodeSettingsRO modelSettings = subNodePersistor.getSNCSettings().getModelSettings();
if (modelSettings != null) {
try {
loadModelSettingsIntoDialogNodes(modelSettings, false);
} catch (InvalidSettingsException e) {
final String msg = "Could not load Component configuration into dialog-nodes: " + e.getMessage();
LOGGER.error(msg, e);
loadResult.addError(msg);
setDirty();
}
}
checkInOutNodesAfterLoad(subNodePersistor, loadResult);
loadLegacyPortNamesAndDescriptionsFromInOutNodes();
// put data input output node if it was executed;
final NativeNodeContainer virtualOutNode = getVirtualOutNode();
LoadVersion l = nodePersistor instanceof FileSingleNodeContainerPersistor ? ((FileSingleNodeContainerPersistor) nodePersistor).getLoadVersion() : LoadVersion.V3010;
if (l.isOlderThan(LoadVersion.V3010) && virtualOutNode.getInternalState().isExecuted()) {
VirtualSubNodeOutputNodeModel outNodeModel = getVirtualOutNodeModel();
PortObject[] outputData = new PortObject[virtualOutNode.getNrInPorts()];
m_wfm.assembleInputData(getVirtualOutNodeID(), outputData);
outNodeModel.postLoadExecute(ArrayUtils.removeAll(outputData, 0));
// allow node to receive the internal held objects so that the next save operation also persists the
// array of internal held objects - otherwise we get strange errors with nodes saved in 2.x, then loaded
// and saved in 3.1+ (and converted ... although unmodified)
getVirtualOutNode().getNode().assignInternalHeldObjects(outputData, null, getVirtualOutNode().createExecutionContext(), new PortObject[0]);
}
setVirtualOutputIntoOutport(m_wfm.getInternalState());
m_wfmStateChangeListener = createAndAddStateListener();
m_wfmListener = createAndAddWorkflowListener();
getInPort(0).setPortName("Variable Inport");
getOutPort(0).setPortName("Variable Outport");
getVirtualInNode().addNodeStateChangeListener(new RefreshPortNamesListener());
getVirtualOutNode().addNodeStateChangeListener(new RefreshPortNamesListener());
refreshPortNames();
return null;
}
Aggregations