use of org.knime.core.node.workflow.action.CollapseIntoMetaNodeResult in project knime-core by knime.
the class BugAP5667_FileStoresInSubnode method tweakWorkflow.
private void tweakWorkflow(final WorkflowManager manager) {
SubNodeContainer subnode = manager.getNodeContainer(m_subnode_5, SubNodeContainer.class, true);
switch(m_testModification) {
case WithStreaming:
break;
case Plain:
subnode.setJobManager(ThreadNodeExecutionJobManagerFactory.INSTANCE.getInstance());
break;
case MetaNodeInSubnode:
case SubnodeInSubnode:
subnode.setJobManager(ThreadNodeExecutionJobManagerFactory.INSTANCE.getInstance());
WorkflowManager innerWFM = subnode.getWorkflowManager();
NodeID[] innerNodes = IntStream.of(2, 5).mapToObj(i -> innerWFM.getID().createChild(i)).toArray(NodeID[]::new);
CollapseIntoMetaNodeResult collapse = innerWFM.collapseIntoMetaNode(innerNodes, new WorkflowAnnotation[0], "yet another level");
if (m_testModification.equals(TestModifications.SubnodeInSubnode)) {
NodeID metaNodeID = collapse.getCollapsedMetanodeID();
innerWFM.convertMetaNodeToSubNode(metaNodeID);
}
break;
default:
throw new InternalError();
}
}
use of org.knime.core.node.workflow.action.CollapseIntoMetaNodeResult in project knime-core by knime.
the class TestCollapseAndWrapMetaNodeActions method testCollapseIntoMetaNodeThenWrapUnwrap.
/**
* Collect nodes, collapse them, convert to meta node and wrap/unwrap.
*/
@Test
public void testCollapseIntoMetaNodeThenWrapUnwrap() throws Exception {
WorkflowManager mgr = getManager();
executeAllAndWait();
checkState(mgr, EXECUTED);
mgr.resetAndConfigureAll();
// there is only one in the wfm
WorkflowAnnotation annotation = mgr.getWorkflowAnnotations().stream().findFirst().get();
final NodeID[] nodes = new NodeID[] { m_columnFilter_2, m_columnFilter_3, m_columnSplitter_4 };
CollapseIntoMetaNodeResult collapseResult = mgr.collapseIntoMetaNode(nodes, new WorkflowAnnotation[] { annotation }, "Test-Meta/Wrap Node");
WorkflowManager metaNode = mgr.getNodeContainer(collapseResult.getCollapsedMetanodeID(), WorkflowManager.class, true);
NodeID metaSubID = metaNode.getID();
assertFalse("Should have removed node: " + m_columnFilter_2, mgr.containsNodeContainer(m_columnFilter_2));
assertTrue("No annotation expected", mgr.getWorkflowAnnotations().isEmpty());
mgr.getNodeContainer(metaSubID, WorkflowManager.class, true);
executeAllAndWait();
checkState(mgr, EXECUTED);
mgr.resetAndConfigureNode(metaSubID);
MetaNodeToSubNodeResult convertObject = mgr.convertMetaNodeToSubNode(metaSubID);
mgr.getNodeContainer(metaSubID, SubNodeContainer.class, true);
executeAllAndWait();
checkState(mgr, EXECUTED);
mgr.resetAndConfigureNode(metaSubID);
assertTrue("Should be undo-able", convertObject.canUndo());
convertObject.undo();
mgr.getNodeContainer(metaSubID, WorkflowManager.class, true);
executeAllAndWait();
checkState(mgr, EXECUTED);
mgr.resetAndConfigureNode(metaSubID);
convertObject = mgr.convertMetaNodeToSubNode(metaSubID);
// no flow var ports at '0' for meta nodes
mgr.addConnection(m_javaEdit_7, 1, metaSubID, 0);
// no flow var ports at '0' for meta nodes
mgr.addConnection(metaSubID, 0, m_tableView_6, 0);
assertEquals("wrong number inputs", 3, mgr.getIncomingConnectionsFor(metaSubID).size());
assertEquals("wrong number outputs", 3, mgr.getOutgoingConnectionsFor(metaSubID).size());
executeAllAndWait();
checkState(mgr, EXECUTED);
mgr.resetAndConfigureNode(metaSubID);
SubNodeToMetaNodeResult convertSubNodeToMetaNodeResult = mgr.convertSubNodeToMetaNode(metaSubID);
mgr.getNodeContainer(metaSubID, WorkflowManager.class, true);
assertEquals("wrong number inputs", 2, mgr.getIncomingConnectionsFor(metaSubID).size());
assertEquals("wrong number outputs", 2, mgr.getOutgoingConnectionsFor(metaSubID).size());
executeAllAndWait();
checkState(mgr, EXECUTED);
convertSubNodeToMetaNodeResult.undo();
mgr.getNodeContainer(metaSubID, SubNodeContainer.class, true);
executeAllAndWait();
checkState(mgr, EXECUTED);
}
Aggregations