Search in sources :

Example 1 with Builder

use of org.knime.core.node.workflow.action.InteractiveWebViewsResult.Builder in project knime-core by knime.

the class SubNodeContainer method getInteractiveWebViews.

/**
 * A {@link InteractiveWebViewsResult} for a subnode containing either a single page view on all appropriate wizard views or a set of all individual wizard views (no recursion).
 *
 * @param combinedView
 * @return
 */
public InteractiveWebViewsResult getInteractiveWebViews(final boolean combinedView) {
    try (WorkflowLock lock = m_wfm.lock()) {
        Builder builder = InteractiveWebViewsResult.newBuilder();
        if (combinedView) {
        } else {
            // collect all the nodes first, then do make names unique (in case there are 2+ scatterplot)
            NativeNodeContainer[] nodesWithViews = m_wfm.getWorkflow().getNodeValues().stream().filter(n -> n instanceof NativeNodeContainer).filter(n -> n.getInteractiveWebViews().size() > 0).map(n -> (NativeNodeContainer) n).toArray(NativeNodeContainer[]::new);
            // count how often certain names are in use
            Map<String, Long> uniqueNameBag = Arrays.stream(nodesWithViews).map(n -> n.getInteractiveViewName()).collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
            for (NativeNodeContainer n : nodesWithViews) {
                String name = n.getInteractiveViewName();
                if (uniqueNameBag.get(name) >= 2L) {
                    name = name.concat(" (ID " + n.getID().getIndex() + ")");
                }
                builder.add(n, name);
            }
        }
        return builder.build();
    }
}
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) FileStoreHandlerRepository(org.knime.core.data.filestore.internal.FileStoreHandlerRepository) 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) QuickFormRepresentation(org.knime.core.quickform.QuickFormRepresentation) FlowVariablePortObject(org.knime.core.node.port.flowvariable.FlowVariablePortObject) DialogNodeRepresentation(org.knime.core.node.dialog.DialogNodeRepresentation) 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) LoadVersion(org.knime.core.node.workflow.FileWorkflowPersistor.LoadVersion) 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) XmlException(org.apache.xmlbeans.XmlException) VirtualSubNodeOutputNodeFactory(org.knime.core.node.workflow.virtual.subnode.VirtualSubNodeOutputNodeFactory) FlowVariablePortObjectSpec(org.knime.core.node.port.flowvariable.FlowVariablePortObjectSpec) NodeType(org.knime.core.node.NodeFactory.NodeType) 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) VirtualSubNodeExchange(org.knime.core.node.workflow.virtual.subnode.VirtualSubNodeExchange) AbstractNodeView(org.knime.core.node.AbstractNodeView) URI(java.net.URI) ContainerTable(org.knime.core.data.container.ContainerTable) 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) WizardNodeLayoutInfo(org.knime.core.node.wizard.WizardNodeLayoutInfo) 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) NodeExecutionJobManagerPool(org.knime.core.node.util.NodeExecutionJobManagerPool) HashMap(java.util.HashMap) ArrayUtils(org.apache.commons.lang3.ArrayUtils) NodeSettings(org.knime.core.node.NodeSettings) 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) MetaNodeDialogNode(org.knime.core.node.dialog.MetaNodeDialogNode) NodeSettingsWO(org.knime.core.node.NodeSettingsWO) Type(org.knime.core.node.workflow.NodeMessage.Type) TimeUnit(java.util.concurrent.TimeUnit) Element(org.w3c.dom.Element) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) NodeProperty(org.knime.core.node.workflow.NodePropertyChangedEvent.NodeProperty) SubnodeContainerExecutionResult(org.knime.core.node.workflow.execresult.SubnodeContainerExecutionResult) Builder(org.knime.core.node.workflow.action.InteractiveWebViewsResult.Builder)

Aggregations

File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 URI (java.net.URI)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Callable (java.util.concurrent.Callable)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeUnit (java.util.concurrent.TimeUnit)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1 Function (java.util.function.Function)1