use of org.knime.core.node.wizard.WizardNodeLayoutInfo in project knime-core by knime.
the class FileSubNodeContainerPersistor method save.
/**
* @param subnodeNC
* @param settings
* @param exec
* @param nodeDirRef
* @param saveHelper
* @throws LockFailedException
* @throws CanceledExecutionException
* @throws IOException
*/
static void save(final SubNodeContainer subnodeNC, final NodeSettings settings, final ExecutionMonitor exec, final ReferencedFile nodeDirRef, final WorkflowSaveHelper saveHelper) throws IOException, CanceledExecutionException, LockFailedException {
NativeNodeContainer virtualInNode = subnodeNC.getVirtualInNode();
settings.addInt("virtual-in-ID", virtualInNode.getID().getIndex());
NodeSettingsWO inportsSettings = settings.addNodeSettings("inports");
// input of subnode is represented by output of virtual in node.
for (int i = 1; i < virtualInNode.getNrOutPorts(); i++) {
// start at one to skip the hidden flow var port
NodeSettingsWO inportSetting = inportsSettings.addNodeSettings("inport_" + (i - 1));
inportSetting.addInt("index", i - 1);
NodeSettingsWO portTypeSettings = inportSetting.addNodeSettings("type");
virtualInNode.getOutputType(i).save(portTypeSettings);
}
NativeNodeContainer virtualOutNode = subnodeNC.getVirtualOutNode();
settings.addInt("virtual-out-ID", virtualOutNode.getID().getIndex());
// output of subnode is represented by input of virtual in node.
NodeSettingsWO outportsSettings = settings.addNodeSettings("outports");
for (int i = 1; i < virtualOutNode.getNrInPorts(); i++) {
// start at one to skip the hidden flow var port
NodeSettingsWO inportSetting = outportsSettings.addNodeSettings("outport_" + (i - 1));
inportSetting.addInt("index", i - 1);
NodeSettingsWO portTypeSettings = inportSetting.addNodeSettings("type");
virtualOutNode.getInPort(i).getPortType().save(portTypeSettings);
}
subnodeNC.getTemplateInformation().save(settings);
Map<Integer, WizardNodeLayoutInfo> layoutInfoMap = subnodeNC.getLayoutInfo();
Integer[] layoutIDs = layoutInfoMap.keySet().toArray(new Integer[0]);
NodeSettingsWO layoutInfoSettings = settings.addNodeSettings("layoutInfos");
for (int i = 0; i < layoutInfoMap.size(); i++) {
NodeSettingsWO curLayoutInfoSettings = layoutInfoSettings.addNodeSettings("layoutInfo_" + (i));
curLayoutInfoSettings.addInt("nodeID", layoutIDs[i]);
WizardNodeLayoutInfo.saveToNodeSettings(curLayoutInfoSettings, layoutInfoMap.get(layoutIDs[i]));
}
settings.addString("layoutJSON", subnodeNC.getLayoutJSONString());
WorkflowManager workflowManager = subnodeNC.getWorkflowManager();
FileWorkflowPersistor.save(workflowManager, nodeDirRef, exec, saveHelper);
}
Aggregations