Search in sources :

Example 1 with LoadResult

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

the class FileNativeNodeContainerPersistor method guessPortTypesFromConnectedNodes.

/**
 * {@inheritDoc}
 */
@Override
public void guessPortTypesFromConnectedNodes(final NodeAndBundleInformation nodeInfo, final NodeSettingsRO additionalFactorySettings, final ArrayList<PersistorWithPortIndex> upstreamNodes, final ArrayList<List<PersistorWithPortIndex>> downstreamNodes) {
    if (m_node == null) {
        /* Input ports from the connection table. */
        // first is flow var port
        PortType[] inPortTypes = new PortType[Math.max(upstreamNodes.size() - 1, 0)];
        // default to BDT for unconnected ports
        Arrays.fill(inPortTypes, BufferedDataTable.TYPE);
        for (int i = 0; i < inPortTypes.length; i++) {
            // first is flow var port
            PersistorWithPortIndex p = upstreamNodes.get(i + 1);
            if (p != null) {
                PortType portTypeFromUpstreamNode = p.getPersistor().getUpstreamPortType(p.getPortIndex());
                if (portTypeFromUpstreamNode != null) {
                    // null if upstream is missing, too
                    inPortTypes[i] = portTypeFromUpstreamNode;
                }
            }
        }
        /* Output ports from node settings (saved ports) -- if possible (executed) */
        String nodeName = nodeInfo.getNodeNameNotNull();
        PortType[] outPortTypes;
        try {
            LoadResult guessLoadResult = new LoadResult("Port type guessing for missing node \"" + nodeName + "\"");
            NodeSettingsRO settingsForNode = loadSettingsForNode(guessLoadResult);
            FileNodePersistor nodePersistor = createNodePersistor(settingsForNode);
            outPortTypes = nodePersistor.guessOutputPortTypes(guessLoadResult, nodeName);
            if (guessLoadResult.hasErrors()) {
                getLogger().debug("Errors guessing port types for missing node \"" + nodeName + "\": " + guessLoadResult.getFilteredError("", LoadResultEntryType.Error));
            }
        } catch (Exception e) {
            getLogger().debug("Unable to guess port types for missing node \"" + nodeName + "\"", e);
            outPortTypes = null;
        }
        if (outPortTypes == null) {
            // couldn't guess port types from looking at node settings (e.g. not executed)
            // default to BDT for unconnected ports
            outPortTypes = new PortType[Math.max(downstreamNodes.size() - 1, 0)];
        }
        for (int i = 0; i < outPortTypes.length; i++) {
            PortType type = outPortTypes[i];
            // output types may be partially filled by settings guessing above, list may be empty or too short
            List<PersistorWithPortIndex> list = i < downstreamNodes.size() - 1 ? downstreamNodes.get(i + 1) : null;
            if (list != null) {
                assert !list.isEmpty();
                for (PersistorWithPortIndex p : list) {
                    PortType current = p.getPersistor().getDownstreamPortType(p.getPortIndex());
                    if (current == null) {
                    // ignore, downstream node is also missing
                    } else if (type == null) {
                        type = current;
                    } else if (type.equals(current)) {
                    // keep type
                    } else {
                        // this shouldn't really happen - someone changed port types between versions
                        type = PortObject.TYPE;
                    }
                }
                outPortTypes[i] = type;
            }
            if (outPortTypes[i] == null) {
                // might still be null if missing node is only connected to missing node, fallback: BDT
                outPortTypes[i] = BufferedDataTable.TYPE;
            }
        }
        MissingNodeFactory nodefactory = new MissingNodeFactory(nodeInfo, additionalFactorySettings, inPortTypes, outPortTypes);
        if (getLoadVersion().ordinal() < FileWorkflowPersistor.VERSION_LATEST.ordinal()) {
            nodefactory.setCopyInternDirForWorkflowVersionChange(true);
        }
        nodefactory.init();
        m_node = new Node((NodeFactory) nodefactory);
    }
}
Also used : Node(org.knime.core.node.Node) FileNodePersistor(org.knime.core.node.FileNodePersistor) LoadResult(org.knime.core.node.workflow.WorkflowPersistor.LoadResult) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) NodeFactoryUnknownException(org.knime.core.node.workflow.WorkflowPersistor.NodeFactoryUnknownException) IOException(java.io.IOException) NodeFactory(org.knime.core.node.NodeFactory) MissingNodeFactory(org.knime.core.node.missing.MissingNodeFactory) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) MissingNodeFactory(org.knime.core.node.missing.MissingNodeFactory) PortType(org.knime.core.node.port.PortType)

Example 2 with LoadResult

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

the class Node method createNodeExecutionResult.

/**
 * Creates an execution result containing all calculated values in a
 * execution. The returned value is suitable to be used in
 * {@link #loadDataAndInternals(
 * NodeContentPersistor, ExecutionMonitor, LoadResult)}.
 * If this node is not executed, it will assign null values to the fields
 * in the returned execution result.
 * @param exec For progress information.
 * @return A new execution result containing the values being calculated.
 * @throws CanceledExecutionException If canceled
 */
public NodeExecutionResult createNodeExecutionResult(final ExecutionMonitor exec) throws CanceledExecutionException {
    NodeExecutionResult result = new NodeExecutionResult();
    result.setWarningMessage(m_model.getWarningMessage());
    if (hasContent()) {
        File internTempDir;
        try {
            internTempDir = FileUtil.createTempDir("knime_node_internDir");
            exec.setMessage("Saving internals");
            saveInternals(internTempDir, exec.createSubProgress(0.0));
            result.setNodeInternDir(new ReferencedFile(internTempDir));
        } catch (IOException ioe) {
            LOGGER.error("Unable to save internals", ioe);
        }
    }
    if (m_internalHeldPortObjects != null) {
        PortObject[] internalHeldPortObjects = Arrays.copyOf(m_internalHeldPortObjects, m_internalHeldPortObjects.length);
        result.setInternalHeldPortObjects(internalHeldPortObjects);
    }
    PortObject[] pos = new PortObject[getNrOutPorts()];
    PortObjectSpec[] poSpecs = new PortObjectSpec[getNrOutPorts()];
    for (int i = 0; i < pos.length; i++) {
        PortObject po = getOutputObject(i);
        if (po != null) {
            pos[i] = po;
            poSpecs[i] = po.getSpec();
        }
    }
    result.setPortObjects(pos);
    result.setPortObjectSpecs(poSpecs);
    // Add the outgoing flow variables to the execution result
    FlowObjectStack outgoingStack = m_model.getOutgoingFlowObjectStack();
    List<FlowVariable> nodeFlowVars = outgoingStack.getAvailableFlowVariables().values().stream().filter(f -> f.getScope().equals(FlowVariable.Scope.Flow)).collect(Collectors.toList());
    // the bottom most element should remain at the bottom of the stack
    Collections.reverse(nodeFlowVars);
    result.setFlowVariables(nodeFlowVars);
    return result;
}
Also used : WizardNode(org.knime.core.node.wizard.WizardNode) ScopeEndNode(org.knime.core.node.workflow.ScopeEndNode) NodeType(org.knime.core.node.NodeFactory.NodeType) Arrays(java.util.Arrays) BufferedInputStream(java.io.BufferedInputStream) NodeMessageEvent(org.knime.core.node.workflow.NodeMessageEvent) ReferencedFile(org.knime.core.internal.ReferencedFile) FileStoreUtil(org.knime.core.data.filestore.FileStoreUtil) IWriteFileStoreHandler(org.knime.core.data.filestore.internal.IWriteFileStoreHandler) InteractiveNode(org.knime.core.node.interactive.InteractiveNode) StringUtils(org.apache.commons.lang3.StringUtils) ExecutionEnvironment(org.knime.core.node.workflow.ExecutionEnvironment) ByteArrayInputStream(java.io.ByteArrayInputStream) Map(java.util.Map) FlowTryCatchContext(org.knime.core.node.workflow.FlowTryCatchContext) ContainerTable(org.knime.core.data.container.ContainerTable) InactiveBranchPortObjectSpec(org.knime.core.node.port.inactive.InactiveBranchPortObjectSpec) PortType(org.knime.core.node.port.PortType) PrintWriter(java.io.PrintWriter) PortObjectZipOutputStream(org.knime.core.node.port.PortObjectZipOutputStream) VirtualSubNodeInputNodeModel(org.knime.core.node.workflow.virtual.subnode.VirtualSubNodeInputNodeModel) Set(java.util.Set) CopyOnWriteArraySet(java.util.concurrent.CopyOnWriteArraySet) Collectors(java.util.stream.Collectors) InterruptibleNodeModel(org.knime.core.node.interrupt.InterruptibleNodeModel) List(java.util.List) HiLiteHandler(org.knime.core.node.property.hilite.HiLiteHandler) InteractiveNodeFactoryExtension(org.knime.core.node.interactive.InteractiveNodeFactoryExtension) CheckUtils(org.knime.core.node.util.CheckUtils) PortObject(org.knime.core.node.port.PortObject) PortObjectZipInputStream(org.knime.core.node.port.PortObjectZipInputStream) NodeMessage(org.knime.core.node.workflow.NodeMessage) Rectangle(java.awt.Rectangle) FileStorePortObject(org.knime.core.data.filestore.FileStorePortObject) NodeMessageListener(org.knime.core.node.workflow.NodeMessageListener) FlowVariablePortObject(org.knime.core.node.port.flowvariable.FlowVariablePortObject) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ValueControlledDialogPane(org.knime.core.node.dialog.ValueControlledDialogPane) DataTableSpec(org.knime.core.data.DataTableSpec) LoopEndNode(org.knime.core.node.workflow.LoopEndNode) NodeExecutionJobManagerPool(org.knime.core.node.util.NodeExecutionJobManagerPool) FlowVariable(org.knime.core.node.workflow.FlowVariable) HashMap(java.util.HashMap) ArrayUtils(org.apache.commons.lang3.ArrayUtils) SplitType(org.knime.core.node.workflow.NodeContainer.NodeContainerSettings.SplitType) AtomicReference(java.util.concurrent.atomic.AtomicReference) PortObjectSpecZipInputStream(org.knime.core.node.port.PortObjectSpecZipInputStream) HashSet(java.util.HashSet) PortTypeRegistry(org.knime.core.node.port.PortTypeRegistry) CredentialsProvider(org.knime.core.node.workflow.CredentialsProvider) PortUtil(org.knime.core.node.port.PortUtil) ViewUtils(org.knime.core.node.util.ViewUtils) LoadResult(org.knime.core.node.workflow.WorkflowPersistor.LoadResult) InactiveBranchPortObject(org.knime.core.node.port.inactive.InactiveBranchPortObject) LinkedHashSet(java.util.LinkedHashSet) FlowObjectStack(org.knime.core.node.workflow.FlowObjectStack) ScopeStartNode(org.knime.core.node.workflow.ScopeStartNode) StringWriter(java.io.StringWriter) DeferredFileOutputStream(org.apache.commons.io.output.DeferredFileOutputStream) InteractiveView(org.knime.core.node.interactive.InteractiveView) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) FlowScopeContext(org.knime.core.node.workflow.FlowScopeContext) IOException(java.io.IOException) InactiveBranchConsumer(org.knime.core.node.port.inactive.InactiveBranchConsumer) FileInputStream(java.io.FileInputStream) PortObjectSpecZipOutputStream(org.knime.core.node.port.PortObjectSpecZipOutputStream) WizardNodeFactoryExtension(org.knime.core.node.wizard.WizardNodeFactoryExtension) NodeContext(org.knime.core.node.workflow.NodeContext) File(java.io.File) ViewContent(org.knime.core.node.interactive.ViewContent) Element(org.w3c.dom.Element) NodeExecutionResult(org.knime.core.node.workflow.execresult.NodeExecutionResult) LoopStartNode(org.knime.core.node.workflow.LoopStartNode) NodeID(org.knime.core.node.workflow.NodeID) DataContainerException(org.knime.core.data.container.DataContainerException) FileUtil(org.knime.core.util.FileUtil) DataTableSpecCreator(org.knime.core.data.DataTableSpecCreator) IFileStoreHandler(org.knime.core.data.filestore.internal.IFileStoreHandler) ValueControlledNode(org.knime.core.node.dialog.ValueControlledNode) FlowVariablePortObjectSpec(org.knime.core.node.port.flowvariable.FlowVariablePortObjectSpec) FlowLoopContext(org.knime.core.node.workflow.FlowLoopContext) Collections(java.util.Collections) InputStream(java.io.InputStream) PortObjectHolder(org.knime.core.node.port.PortObjectHolder) NodeExecutionResult(org.knime.core.node.workflow.execresult.NodeExecutionResult) FlowObjectStack(org.knime.core.node.workflow.FlowObjectStack) IOException(java.io.IOException) ReferencedFile(org.knime.core.internal.ReferencedFile) InactiveBranchPortObjectSpec(org.knime.core.node.port.inactive.InactiveBranchPortObjectSpec) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) FlowVariablePortObjectSpec(org.knime.core.node.port.flowvariable.FlowVariablePortObjectSpec) ReferencedFile(org.knime.core.internal.ReferencedFile) File(java.io.File) PortObject(org.knime.core.node.port.PortObject) FileStorePortObject(org.knime.core.data.filestore.FileStorePortObject) FlowVariablePortObject(org.knime.core.node.port.flowvariable.FlowVariablePortObject) InactiveBranchPortObject(org.knime.core.node.port.inactive.InactiveBranchPortObject) FlowVariable(org.knime.core.node.workflow.FlowVariable)

Example 3 with LoadResult

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

the class CopyContentIntoTempFlowNodeExecutionJob method mainExecute.

/**
 * {@inheritDoc}
 */
@Override
protected NodeContainerExecutionStatus mainExecute() {
    LoadResult lR = new LoadResult("load data into temp flow");
    getNodeContainer().loadExecutionResult(m_ncResult, new ExecutionMonitor(), lR);
    if (lR.hasErrors()) {
        LOGGER.error("Errors loading temporary data into workflow (to be submitted to cluster):\n" + lR.getFilteredError("", LoadResultEntryType.Warning));
    }
    return m_ncResult;
}
Also used : ExecutionMonitor(org.knime.core.node.ExecutionMonitor) LoadResult(org.knime.core.node.workflow.WorkflowPersistor.LoadResult)

Example 4 with LoadResult

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

the class WorkflowManager method loadExecutionResult.

/**
 * {@inheritDoc}
 */
@Override
public void loadExecutionResult(final NodeContainerExecutionResult result, final ExecutionMonitor exec, final LoadResult loadResult) {
    CheckUtils.checkArgument(result instanceof WorkflowExecutionResult, "Argument must be instance of \"%s\": %s", WorkflowExecutionResult.class.getSimpleName(), result == null ? "null" : result.getClass().getSimpleName());
    WorkflowExecutionResult r = (WorkflowExecutionResult) result;
    try (WorkflowLock lock = lock()) {
        super.loadExecutionResult(result, exec, loadResult);
        Map<NodeID, NodeContainerExecutionResult> map = r.getExecutionResultMap();
        final int count = map.size();
        // contains the corrected NodeID in this workflow (the node ids in
        // the execution result refer to the base id of the remote workflow)
        Map<NodeID, NodeID> transMap = new HashMap<NodeID, NodeID>();
        NodeID otherIDPrefix = r.getBaseID();
        for (NodeID otherID : map.keySet()) {
            assert otherID.hasSamePrefix(otherIDPrefix);
            transMap.put(new NodeID(getID(), otherID.getIndex()), otherID);
        }
        for (NodeID id : m_workflow.createBreadthFirstSortedList(transMap.keySet(), true).keySet()) {
            NodeID otherID = transMap.get(id);
            NodeContainer nc = m_workflow.getNode(id);
            NodeContainerExecutionResult exResult = map.get(otherID);
            if (exResult == null) {
                loadResult.addError("No execution result for node " + nc.getNameWithID());
                continue;
            }
            exec.setMessage(nc.getNameWithID());
            ExecutionMonitor subExec = exec.createSubProgress(1.0 / count);
            // Propagagte the flow variables
            if (nc instanceof SingleNodeContainer) {
                NodeOutPort[] predecessorOutPorts = assemblePredecessorOutPorts(id);
                FlowObjectStack[] sos = Arrays.stream(predecessorOutPorts).map(p -> p != null ? p.getFlowObjectStack() : null).toArray(FlowObjectStack[]::new);
                createAndSetFlowObjectStackFor((SingleNodeContainer) nc, sos);
            }
            nc.loadExecutionResult(exResult, subExec, loadResult);
            subExec.setProgress(1.0);
        }
    }
}
Also used : 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) IWriteFileStoreHandler(org.knime.core.data.filestore.internal.IWriteFileStoreHandler) 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) WorkflowFileStoreHandlerRepository(org.knime.core.data.filestore.internal.WorkflowFileStoreHandlerRepository) Map(java.util.Map) FileStoreHandlerRepository(org.knime.core.data.filestore.internal.FileStoreHandlerRepository) 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) 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) VirtualParallelizedChunkNodeInput(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkNodeInput) KNIMEConstants(org.knime.core.node.KNIMEConstants) LoadVersion(org.knime.core.node.workflow.FileWorkflowPersistor.LoadVersion) 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) FileOutputStream(java.io.FileOutputStream) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) 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) NodeType(org.knime.core.node.NodeFactory.NodeType) ExpandSubnodeResult(org.knime.core.node.workflow.action.ExpandSubnodeResult) ListIterator(java.util.ListIterator) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) URL(java.net.URL) Date(java.util.Date) URISyntaxException(java.net.URISyntaxException) 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) VirtualParallelizedChunkPortObjectInNodeFactory(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkPortObjectInNodeFactory) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry) 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) ContainerTable(org.knime.core.data.container.ContainerTable) 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) Collection(java.util.Collection) 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) 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) 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) NodeCreationContext(org.knime.core.node.NodeCreationContext) 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) 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) ParallelizedChunkContentMaster(org.knime.core.node.workflow.virtual.parchunk.ParallelizedChunkContentMaster) IFileStoreHandler(org.knime.core.data.filestore.internal.IFileStoreHandler) NodeProperty(org.knime.core.node.workflow.NodePropertyChangedEvent.NodeProperty) Collections(java.util.Collections) NodeContainerExecutionResult(org.knime.core.node.workflow.execresult.NodeContainerExecutionResult) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) WorkflowExecutionResult(org.knime.core.node.workflow.execresult.WorkflowExecutionResult) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) ExecutionMonitor(org.knime.core.node.ExecutionMonitor)

Example 5 with LoadResult

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

the class WorkflowManager method checkUpdateMetaNodeLink.

/**
 * Query the template to the linked metanode with the given ID and check whether a newer version is available.
 *
 * @param id The ID of the linked metanode
 * @param loadHelper The load helper to load the template
 * @return true if a newer revision is available, false if not or this is not a metanode link.
 * @throws IOException If that fails (template not accessible)
 */
public boolean checkUpdateMetaNodeLink(final NodeID id, final WorkflowLoadHelper loadHelper) throws IOException {
    final HashMap<URI, NodeContainerTemplate> visitedTemplateMap = new HashMap<URI, NodeContainerTemplate>();
    try {
        final LoadResult loadResult = new LoadResult("ignored");
        boolean result = checkUpdateMetaNodeLinkWithCache(id, loadHelper, loadResult, visitedTemplateMap, true);
        if (loadResult.hasErrors()) {
            throw new IOException("Errors checking updates:\n" + loadResult.getFilteredError("  ", LoadResultEntryType.Error));
        }
        return result;
    } finally {
        for (NodeContainerTemplate tempLink : visitedTemplateMap.values()) {
            tempLink.getParent().removeNode(tempLink.getID());
        }
    }
}
Also used : LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) IOException(java.io.IOException) URI(java.net.URI) WorkflowLoadResult(org.knime.core.node.workflow.WorkflowPersistor.WorkflowLoadResult) LoadResult(org.knime.core.node.workflow.WorkflowPersistor.LoadResult)

Aggregations

LoadResult (org.knime.core.node.workflow.WorkflowPersistor.LoadResult)8 IOException (java.io.IOException)7 WorkflowLoadResult (org.knime.core.node.workflow.WorkflowPersistor.WorkflowLoadResult)5 URI (java.net.URI)4 HashMap (java.util.HashMap)4 LinkedHashMap (java.util.LinkedHashMap)4 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)4 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)4 LinkedHashSet (java.util.LinkedHashSet)3 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)3 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)3 PortObject (org.knime.core.node.port.PortObject)3 PortType (org.knime.core.node.port.PortType)3 FlowVariablePortObject (org.knime.core.node.port.flowvariable.FlowVariablePortObject)3 File (java.io.File)2 URISyntaxException (java.net.URISyntaxException)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 Arrays (java.util.Arrays)2 Collections (java.util.Collections)2 HashSet (java.util.HashSet)2