Search in sources :

Example 1 with ConnectionContainerTemplate

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

the class SubNodeContainer method getConvertToMetaNodeCopyPersistor.

/**
 * @return a persistor containing all but the virtual nodes and that is also fixing the in/out connections
 * once the node is unwrapped to a metanode.
 */
WorkflowPersistor getConvertToMetaNodeCopyPersistor() {
    assert isLockedByCurrentThread();
    Collection<WorkflowAnnotationID> workflowAnnotations = m_wfm.getWorkflowAnnotationIDs();
    // all but virtual in and output node
    NodeID[] nodes = m_wfm.getNodeContainers().stream().map(nc -> nc.getID()).filter(id -> id.getIndex() != m_virtualInNodeIDSuffix).filter(id -> id.getIndex() != m_virtualOutNodeIDSuffix).toArray(NodeID[]::new);
    WorkflowCopyContent.Builder cnt = WorkflowCopyContent.builder();
    cnt.setNodeIDs(nodes);
    cnt.setAnnotationIDs(workflowAnnotations.toArray(new WorkflowAnnotationID[workflowAnnotations.size()]));
    cnt.setIncludeInOutConnections(true);
    WorkflowPersistor persistor = m_wfm.copy(true, cnt.build());
    final Set<ConnectionContainerTemplate> additionalConnectionSet = persistor.getAdditionalConnectionSet();
    for (Iterator<ConnectionContainerTemplate> it = additionalConnectionSet.iterator(); it.hasNext(); ) {
        ConnectionContainerTemplate c = it.next();
        if (c.getSourceSuffix() == m_virtualInNodeIDSuffix) {
            if (c.getSourcePort() == 0) {
                it.remove();
                continue;
            }
            c.setSourceSuffix(-1);
            c.setSourcePort(c.getSourcePort() - 1);
        }
        if (c.getDestSuffix() == m_virtualOutNodeIDSuffix) {
            if (c.getDestPort() == 0) {
                it.remove();
                continue;
            }
            c.setDestSuffix(-1);
            c.setDestPort(c.getDestPort() - 1);
        }
    }
    return persistor;
}
Also used : WizardNode(org.knime.core.node.wizard.WizardNode) VirtualSubNodeInputNodeFactory(org.knime.core.node.workflow.virtual.subnode.VirtualSubNodeInputNodeFactory) Arrays(java.util.Arrays) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) ReferencedFile(org.knime.core.internal.ReferencedFile) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) StringUtils(org.apache.commons.lang3.StringUtils) NodeContainerExecutionStatus(org.knime.core.node.workflow.execresult.NodeContainerExecutionStatus) VirtualSubNodeOutputNodeModel(org.knime.core.node.workflow.virtual.subnode.VirtualSubNodeOutputNodeModel) Node(org.knime.core.node.Node) Document(org.w3c.dom.Document) Map(java.util.Map) ComponentMetadataBuilder(org.knime.core.node.workflow.ComponentMetadata.ComponentMetadataBuilder) NodeDescription(org.knime.core.node.NodeDescription) LockFailedException(org.knime.core.util.LockFailedException) ExecutionMonitor(org.knime.core.node.ExecutionMonitor) ThreadPool(org.knime.core.util.ThreadPool) Set(java.util.Set) ThreadNodeExecutionJobManager(org.knime.core.node.exec.ThreadNodeExecutionJobManager) FlowVariablePortObject(org.knime.core.node.port.flowvariable.FlowVariablePortObject) Callable(java.util.concurrent.Callable) SplitType(org.knime.core.node.workflow.NodeContainer.NodeContainerSettings.SplitType) ArrayList(java.util.ArrayList) NotConfigurableException(org.knime.core.node.NotConfigurableException) WorkflowExecutionResult(org.knime.core.node.workflow.execresult.WorkflowExecutionResult) DialogNode(org.knime.core.node.dialog.DialogNode) InactiveBranchPortObject(org.knime.core.node.port.inactive.InactiveBranchPortObject) InteractiveView(org.knime.core.node.interactive.InteractiveView) FileOutputStream(java.io.FileOutputStream) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) IOException(java.io.IOException) DialogNodeValue(org.knime.core.node.dialog.DialogNodeValue) File(java.io.File) ViewContent(org.knime.core.node.interactive.ViewContent) ExecutionException(java.util.concurrent.ExecutionException) EnabledDialogNodeModelFilter(org.knime.core.node.dialog.EnabledDialogNodeModelFilter) CSSModifiable(org.knime.core.node.wizard.CSSModifiable) XmlException(org.apache.xmlbeans.XmlException) TreeMap(java.util.TreeMap) VirtualSubNodeOutputNodeFactory(org.knime.core.node.workflow.virtual.subnode.VirtualSubNodeOutputNodeFactory) FlowVariablePortObjectSpec(org.knime.core.node.port.flowvariable.FlowVariablePortObjectSpec) NodeType(org.knime.core.node.NodeFactory.NodeType) ViewHideable(org.knime.core.node.wizard.ViewHideable) Builder(org.knime.core.node.workflow.action.InteractiveWebViewsResult.Builder) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) URL(java.net.URL) NodeConfigureHelper(org.knime.core.node.NodeConfigureHelper) NodeDialogPane(org.knime.core.node.NodeDialogPane) ByteArrayInputStream(java.io.ByteArrayInputStream) VirtualSubNodeExchange(org.knime.core.node.workflow.virtual.subnode.VirtualSubNodeExchange) AbstractNodeView(org.knime.core.node.AbstractNodeView) URI(java.net.URI) InactiveBranchPortObjectSpec(org.knime.core.node.port.inactive.InactiveBranchPortObjectSpec) PortType(org.knime.core.node.port.PortType) Collection(java.util.Collection) VirtualSubNodeInputNodeModel(org.knime.core.node.workflow.virtual.subnode.VirtualSubNodeInputNodeModel) NodeModel(org.knime.core.node.NodeModel) Collectors(java.util.stream.Collectors) List(java.util.List) BufferedDataTable(org.knime.core.node.BufferedDataTable) WorkflowPortTemplate(org.knime.core.node.workflow.WorkflowPersistor.WorkflowPortTemplate) NodeContainerTemplateLinkUpdateResult(org.knime.core.node.workflow.WorkflowPersistor.NodeContainerTemplateLinkUpdateResult) HiLiteHandler(org.knime.core.node.property.hilite.HiLiteHandler) Optional(java.util.Optional) CheckUtils(org.knime.core.node.util.CheckUtils) PortObject(org.knime.core.node.port.PortObject) NodeContainerExecutionResult(org.knime.core.node.workflow.execresult.NodeContainerExecutionResult) SubNodeDescriptionProvider(org.knime.core.node.dialog.SubNodeDescriptionProvider) NodeExecutionJobManagerPool(org.knime.core.node.util.NodeExecutionJobManagerPool) LoadVersion(org.knime.core.util.LoadVersion) HashMap(java.util.HashMap) ArrayUtils(org.apache.commons.lang3.ArrayUtils) NodeSettings(org.knime.core.node.NodeSettings) ConnectionType(org.knime.core.node.workflow.ConnectionContainer.ConnectionType) Function(java.util.function.Function) Pair(org.knime.core.util.Pair) ExecutionContext(org.knime.core.node.ExecutionContext) ConnectionContainerTemplate(org.knime.core.node.workflow.WorkflowPersistor.ConnectionContainerTemplate) ObjectUtils(org.apache.commons.lang3.ObjectUtils) NodeLogger(org.knime.core.node.NodeLogger) DOMException(org.w3c.dom.DOMException) EXECUTED(org.knime.core.node.workflow.InternalNodeContainerState.EXECUTED) LoadResult(org.knime.core.node.workflow.WorkflowPersistor.LoadResult) Role(org.knime.core.node.workflow.MetaNodeTemplateInformation.Role) InteractiveWebViewsResult(org.knime.core.node.workflow.action.InteractiveWebViewsResult) NodeDescription27Proxy(org.knime.core.node.NodeDescription27Proxy) OutputStream(java.io.OutputStream) Iterator(java.util.Iterator) ReentrantLock(java.util.concurrent.locks.ReentrantLock) TemplateType(org.knime.core.node.workflow.MetaNodeTemplateInformation.TemplateType) NodeModelFilter(org.knime.core.node.workflow.WorkflowManager.NodeModelFilter) MetaPortInfo(org.knime.core.node.port.MetaPortInfo) NodeSettingsWO(org.knime.core.node.NodeSettingsWO) Type(org.knime.core.node.workflow.NodeMessage.Type) TimeUnit(java.util.concurrent.TimeUnit) Collectors.toList(java.util.stream.Collectors.toList) Element(org.w3c.dom.Element) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) ConfigurationLayoutUtil(org.knime.core.node.dialog.util.ConfigurationLayoutUtil) NodeProperty(org.knime.core.node.workflow.NodePropertyChangedEvent.NodeProperty) MetaNodeDialogType(org.knime.core.node.workflow.MetaNodeDialogPane.MetaNodeDialogType) SubnodeContainerExecutionResult(org.knime.core.node.workflow.execresult.SubnodeContainerExecutionResult) Collections(java.util.Collections) InputStream(java.io.InputStream) ConnectionContainerTemplate(org.knime.core.node.workflow.WorkflowPersistor.ConnectionContainerTemplate)

Example 2 with ConnectionContainerTemplate

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

the class WorkflowManager method copy.

/**
 * Copy the nodes with the given ids.
 *
 * @param isUndoableDeleteCommand <code>true</code> if the returned persistor is used in the delete command (which
 *            supports undo). This has two effects:
 *            <ol>
 *            <li>It keeps the locations of the node's directories (e.g. &lt;workflow&gt;/File Reader (#xy)/). This
 *            is true if the copy serves as backup of an undoable delete command (undoable = undo enabled). If it is
 *            undone, the directories must not be cleared before the next save (in order to keep the drop folder)
 *            </li>
 *            <li>The returned persistor will insert a reference to the contained workflow annotations instead of
 *            copying them (enables undo on previous move or edit commands.</li>
 *            </ol>
 * @param content The content to copy (must exist).
 * @return A workflow persistor hosting the node templates, ready to be used in the
 *         {@link #paste(WorkflowPersistor)} method.
 */
public WorkflowPersistor copy(final boolean isUndoableDeleteCommand, final WorkflowCopyContent content) {
    NodeID[] nodeIDs = content.getNodeIDs();
    HashSet<NodeID> idsHashed = new HashSet<NodeID>(Arrays.asList(nodeIDs));
    if (idsHashed.size() != nodeIDs.length) {
        throw new IllegalArgumentException("argument list contains duplicates");
    }
    Map<Integer, NodeContainerPersistor> loaderMap = new LinkedHashMap<Integer, NodeContainerPersistor>();
    Set<ConnectionContainerTemplate> connTemplates = new HashSet<ConnectionContainerTemplate>();
    Set<ConnectionContainerTemplate> additionalConnTemplates = new HashSet<ConnectionContainerTemplate>();
    boolean isIncludeInOut = content.isIncludeInOutConnections();
    try (WorkflowLock lock = lock()) {
        for (int i = 0; i < nodeIDs.length; i++) {
            // throws exception if not present in workflow
            NodeContainer cont = getNodeContainer(nodeIDs[i]);
            final NodeContainerPersistor copyPersistor = cont.getCopyPersistor(false, isUndoableDeleteCommand);
            NodeContainerMetaPersistor copyMetaPersistor = copyPersistor.getMetaPersistor();
            NodeUIInformation overwrittenUIInfo = content.getOverwrittenUIInfo(nodeIDs[i]);
            Integer suggestedNodeIDSuffix = content.getSuggestedNodIDSuffix(nodeIDs[i]);
            if (overwrittenUIInfo != null) {
                copyMetaPersistor.setUIInfo(overwrittenUIInfo);
            }
            int nodeIDSuffix;
            if (suggestedNodeIDSuffix != null) {
                nodeIDSuffix = suggestedNodeIDSuffix.intValue();
                copyMetaPersistor.setNodeIDSuffix(nodeIDSuffix);
            } else {
                nodeIDSuffix = cont.getID().getIndex();
            }
            loaderMap.put(nodeIDSuffix, copyPersistor);
            NodeUIInformation uiInfo = copyMetaPersistor.getUIInfo();
            if (uiInfo != null) {
                // 
                content.getPositionOffset().map(// 
                off -> NodeUIInformation.builder(uiInfo).translate(off).build()).ifPresent(ui -> copyMetaPersistor.setUIInfo(ui));
            }
            for (ConnectionContainer out : m_workflow.getConnectionsBySource(nodeIDs[i])) {
                if (idsHashed.contains(out.getDest())) {
                    ConnectionContainerTemplate t = new ConnectionContainerTemplate(out, false);
                    t.fixPostionOffsetIfPresent(content.getPositionOffset());
                    connTemplates.add(t);
                } else if (isIncludeInOut) {
                    ConnectionContainerTemplate t = new ConnectionContainerTemplate(out, false);
                    t.fixPostionOffsetIfPresent(content.getPositionOffset());
                    additionalConnTemplates.add(t);
                }
            }
            if (isIncludeInOut) {
                for (ConnectionContainer in : m_workflow.getConnectionsByDest(nodeIDs[i])) {
                    ConnectionContainerTemplate t = new ConnectionContainerTemplate(in, false);
                    t.fixPostionOffsetIfPresent(content.getPositionOffset());
                    additionalConnTemplates.add(t);
                }
            }
        }
        return new PasteWorkflowContentPersistor(loaderMap, connTemplates, additionalConnTemplates, getWorkflowAnnotations(content.getAnnotationIDs()), isUndoableDeleteCommand);
    }
}
Also used : WorkflowSegment(org.knime.core.node.workflow.capture.WorkflowSegment) Arrays(java.util.Arrays) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) EXECUTING(org.knime.core.node.workflow.InternalNodeContainerState.EXECUTING) ReferencedFile(org.knime.core.internal.ReferencedFile) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) InteractiveNode(org.knime.core.node.interactive.InteractiveNode) CoreException(org.eclipse.core.runtime.CoreException) StringUtils(org.apache.commons.lang3.StringUtils) AbstractQuickFormValueInConfiguration(org.knime.core.quickform.AbstractQuickFormValueInConfiguration) NodeView(org.knime.core.node.NodeView) NodeContainerExecutionStatus(org.knime.core.node.workflow.execresult.NodeContainerExecutionStatus) Node(org.knime.core.node.Node) Vector(java.util.Vector) Matcher(java.util.regex.Matcher) Map(java.util.Map) ModifiableNodeCreationConfiguration(org.knime.core.node.context.ModifiableNodeCreationConfiguration) LockFailedException(org.knime.core.util.LockFailedException) ExecutionMonitor(org.knime.core.node.ExecutionMonitor) EXECUTINGREMOTELY(org.knime.core.node.workflow.InternalNodeContainerState.EXECUTINGREMOTELY) Set(java.util.Set) ResolverUtil(org.knime.core.util.pathresolve.ResolverUtil) Executors(java.util.concurrent.Executors) POSTEXECUTE(org.knime.core.node.workflow.InternalNodeContainerState.POSTEXECUTE) InputNode(org.knime.core.node.dialog.InputNode) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) Stream(java.util.stream.Stream) CONFIGURED(org.knime.core.node.workflow.InternalNodeContainerState.CONFIGURED) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) ThreadNodeExecutionJobManager(org.knime.core.node.exec.ThreadNodeExecutionJobManager) JsonException(javax.json.JsonException) CollapseIntoMetaNodeResult(org.knime.core.node.workflow.action.CollapseIntoMetaNodeResult) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) VirtualParallelizedChunkPortObjectInNodeModel(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkPortObjectInNodeModel) FlowVariablePortObject(org.knime.core.node.port.flowvariable.FlowVariablePortObject) VMFileLocker(org.knime.core.util.VMFileLocker) RestoredFlowLoopContext(org.knime.core.node.workflow.FlowLoopContext.RestoredFlowLoopContext) SplitType(org.knime.core.node.workflow.NodeContainer.NodeContainerSettings.SplitType) AbstractQuickFormConfiguration(org.knime.core.quickform.AbstractQuickFormConfiguration) EXECUTED_QUEUED(org.knime.core.node.workflow.InternalNodeContainerState.EXECUTED_QUEUED) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) NotConfigurableException(org.knime.core.node.NotConfigurableException) UpdateStatus(org.knime.core.node.workflow.MetaNodeTemplateInformation.UpdateStatus) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) WorkflowExecutionResult(org.knime.core.node.workflow.execresult.WorkflowExecutionResult) DialogNode(org.knime.core.node.dialog.DialogNode) LinkedHashSet(java.util.LinkedHashSet) IntFunction(java.util.function.IntFunction) VirtualParallelizedChunkNodeInput(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkNodeInput) KNIMEConstants(org.knime.core.node.KNIMEConstants) QuickFormInputNode(org.knime.core.quickform.in.QuickFormInputNode) Executor(java.util.concurrent.Executor) PREEXECUTE(org.knime.core.node.workflow.InternalNodeContainerState.PREEXECUTE) InteractiveView(org.knime.core.node.interactive.InteractiveView) AuthorInformation(org.knime.core.util.workflowalizer.AuthorInformation) FileOutputStream(java.io.FileOutputStream) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) DialogNodeValue(org.knime.core.node.dialog.DialogNodeValue) File(java.io.File) ViewContent(org.knime.core.node.interactive.ViewContent) UNCONFIGURED_MARKEDFOREXEC(org.knime.core.node.workflow.InternalNodeContainerState.UNCONFIGURED_MARKEDFOREXEC) OutputNode(org.knime.core.node.dialog.OutputNode) Platform(org.eclipse.core.runtime.Platform) LoopStatus(org.knime.core.node.workflow.NativeNodeContainer.LoopStatus) FileUtil(org.knime.core.util.FileUtil) CONFIGURED_QUEUED(org.knime.core.node.workflow.InternalNodeContainerState.CONFIGURED_QUEUED) FlowVirtualScopeContext(org.knime.core.node.workflow.virtual.parchunk.FlowVirtualScopeContext) NodeType(org.knime.core.node.NodeFactory.NodeType) ExpandSubnodeResult(org.knime.core.node.workflow.action.ExpandSubnodeResult) NodeCreationConfiguration(org.knime.core.node.context.NodeCreationConfiguration) ListIterator(java.util.ListIterator) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) URL(java.net.URL) WorkflowLoadResult(org.knime.core.node.workflow.WorkflowPersistor.WorkflowLoadResult) ReexecutionCallback(org.knime.core.node.interactive.ReexecutionCallback) MetaNodeLinkUpdateResult(org.knime.core.node.workflow.WorkflowPersistor.MetaNodeLinkUpdateResult) FileFilterUtils(org.apache.commons.io.filefilter.FileFilterUtils) NodeDialogPane(org.knime.core.node.NodeDialogPane) JsonValue(javax.json.JsonValue) VirtualParallelizedChunkPortObjectInNodeFactory(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkPortObjectInNodeFactory) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry) ReplaceNodeResult(org.knime.core.node.workflow.action.ReplaceNodeResult) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) AbstractNodeView(org.knime.core.node.AbstractNodeView) ConvenienceMethods(org.knime.core.node.util.ConvenienceMethods) URI(java.net.URI) ThreadFactory(java.util.concurrent.ThreadFactory) MetaNodeToSubNodeResult(org.knime.core.node.workflow.action.MetaNodeToSubNodeResult) PortType(org.knime.core.node.port.PortType) NodeAndInports(org.knime.core.node.workflow.Workflow.NodeAndInports) CONFIGURED_MARKEDFOREXEC(org.knime.core.node.workflow.InternalNodeContainerState.CONFIGURED_MARKEDFOREXEC) AbstractPortObjectRepositoryNodeModel(org.knime.core.node.workflow.virtual.AbstractPortObjectRepositoryNodeModel) Predicate(java.util.function.Predicate) Collection(java.util.Collection) ReExecutable(org.knime.core.node.interactive.ReExecutable) CredentialsNode(org.knime.core.node.workflow.CredentialsStore.CredentialsNode) NodeModel(org.knime.core.node.NodeModel) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) BufferedDataTable(org.knime.core.node.BufferedDataTable) WorkflowPortTemplate(org.knime.core.node.workflow.WorkflowPersistor.WorkflowPortTemplate) LoadResultEntryType(org.knime.core.node.workflow.WorkflowPersistor.LoadResultEntry.LoadResultEntryType) NodeContainerTemplateLinkUpdateResult(org.knime.core.node.workflow.WorkflowPersistor.NodeContainerTemplateLinkUpdateResult) HiLiteHandler(org.knime.core.node.property.hilite.HiLiteHandler) Entry(java.util.Map.Entry) Optional(java.util.Optional) CheckUtils(org.knime.core.node.util.CheckUtils) CheckUtils.checkState(org.knime.core.node.util.CheckUtils.checkState) PortObject(org.knime.core.node.port.PortObject) NodeContainerExecutionResult(org.knime.core.node.workflow.execresult.NodeContainerExecutionResult) IntStream(java.util.stream.IntStream) IOCase(org.apache.commons.io.IOCase) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) NodeExecutionJobManagerPool(org.knime.core.node.util.NodeExecutionJobManagerPool) SingleNodeContainerSettings(org.knime.core.node.workflow.SingleNodeContainer.SingleNodeContainerSettings) EXECUTED_MARKEDFOREXEC(org.knime.core.node.workflow.InternalNodeContainerState.EXECUTED_MARKEDFOREXEC) LoadVersion(org.knime.core.util.LoadVersion) HashMap(java.util.HashMap) NodeSettings(org.knime.core.node.NodeSettings) ConnectionType(org.knime.core.node.workflow.ConnectionContainer.ConnectionType) Function(java.util.function.Function) Pair(org.knime.core.util.Pair) HashSet(java.util.HashSet) ExecutionContext(org.knime.core.node.ExecutionContext) IDLE(org.knime.core.node.workflow.InternalNodeContainerState.IDLE) ExternalNodeData(org.knime.core.node.dialog.ExternalNodeData) ConnectionContainerTemplate(org.knime.core.node.workflow.WorkflowPersistor.ConnectionContainerTemplate) NodeLogger(org.knime.core.node.NodeLogger) EXECUTED(org.knime.core.node.workflow.InternalNodeContainerState.EXECUTED) LoadResult(org.knime.core.node.workflow.WorkflowPersistor.LoadResult) LinkedList(java.util.LinkedList) Role(org.knime.core.node.workflow.MetaNodeTemplateInformation.Role) InteractiveWebViewsResult(org.knime.core.node.workflow.action.InteractiveWebViewsResult) SubNodeToMetaNodeResult(org.knime.core.node.workflow.action.SubNodeToMetaNodeResult) OutputStream(java.io.OutputStream) NodeFactory(org.knime.core.node.NodeFactory) Iterator(java.util.Iterator) ReentrantLock(java.util.concurrent.locks.ReentrantLock) TemplateType(org.knime.core.node.workflow.MetaNodeTemplateInformation.TemplateType) MetaPortInfo(org.knime.core.node.port.MetaPortInfo) VirtualParallelizedChunkPortObjectOutNodeFactory(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkPortObjectOutNodeFactory) MetaNodeDialogNode(org.knime.core.node.dialog.MetaNodeDialogNode) CheckedExceptionBiConsumer(org.knime.core.util.CheckedExceptionBiConsumer) ParallelizedChunkContent(org.knime.core.node.workflow.virtual.parchunk.ParallelizedChunkContent) NodeSettingsWO(org.knime.core.node.NodeSettingsWO) Type(org.knime.core.node.workflow.NodeMessage.Type) TimeUnit(java.util.concurrent.TimeUnit) Condition(java.util.concurrent.locks.Condition) IEarlyStartup(org.knime.core.util.IEarlyStartup) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ParallelizedChunkContentMaster(org.knime.core.node.workflow.virtual.parchunk.ParallelizedChunkContentMaster) NodeProperty(org.knime.core.node.workflow.NodePropertyChangedEvent.NodeProperty) MetaNodeDialogType(org.knime.core.node.workflow.MetaNodeDialogPane.MetaNodeDialogType) Collections(java.util.Collections) PortObjectHolder(org.knime.core.node.port.PortObjectHolder) ConnectionContainerTemplate(org.knime.core.node.workflow.WorkflowPersistor.ConnectionContainerTemplate) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) LinkedHashMap(java.util.LinkedHashMap) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet)

Example 3 with ConnectionContainerTemplate

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

the class WorkflowManager method addConnectionsFromTemplates.

/**
 * @param connections
 * @param loadResult
 * @param translationMap
 */
private void addConnectionsFromTemplates(final Set<ConnectionContainerTemplate> connections, final LoadResult loadResult, final Map<Integer, NodeID> translationMap, final boolean currentlyLoadingFlow) {
    for (ConnectionContainerTemplate c : connections) {
        int sourceSuffix = c.getSourceSuffix();
        int destSuffix = c.getDestSuffix();
        assert sourceSuffix == -1 || sourceSuffix != destSuffix : "Can't insert connection, source and destination are equal";
        ConnectionType type = ConnectionType.STD;
        NodeID source;
        NodeID dest;
        if ((sourceSuffix == -1) && (destSuffix == -1)) {
            source = getID();
            dest = getID();
            type = ConnectionType.WFMTHROUGH;
        } else if (sourceSuffix == -1) {
            source = getID();
            dest = translationMap.get(destSuffix);
            type = ConnectionType.WFMIN;
        } else if (destSuffix == -1) {
            dest = getID();
            source = translationMap.get(sourceSuffix);
            type = ConnectionType.WFMOUT;
        } else {
            dest = translationMap.get(destSuffix);
            source = translationMap.get(sourceSuffix);
        }
        if (!canAddConnection(source, c.getSourcePort(), dest, c.getDestPort(), true, currentlyLoadingFlow)) {
            String warn = "Unable to insert connection \"" + c + "\"";
            LOGGER.warn(warn);
            loadResult.addError(warn);
            continue;
        }
        ConnectionContainer cc = addConnection(source, c.getSourcePort(), dest, c.getDestPort(), currentlyLoadingFlow);
        cc.setUIInfo(c.getUiInfo());
        cc.setDeletable(c.isDeletable());
        assert cc.getType().equals(type);
    }
}
Also used : ConnectionType(org.knime.core.node.workflow.ConnectionContainer.ConnectionType) ConnectionContainerTemplate(org.knime.core.node.workflow.WorkflowPersistor.ConnectionContainerTemplate) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint)

Aggregations

File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 OutputStream (java.io.OutputStream)2 URI (java.net.URI)2 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 List (java.util.List)2 Map (java.util.Map)2 Optional (java.util.Optional)2 Set (java.util.Set)2 TimeUnit (java.util.concurrent.TimeUnit)2 ReentrantLock (java.util.concurrent.locks.ReentrantLock)2 Function (java.util.function.Function)2 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)2