Search in sources :

Example 41 with WorkflowManager

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

the class OpenWorkflowVariablesDialogAction method run.

/**
 * {@inheritDoc}
 */
@Override
public void run() {
    super.run();
    // get workflow
    final WorkflowManager wf = getWorkflow();
    // open the dialog
    final Display d = Display.getDefault();
    // run in UI thread
    d.asyncExec(new Runnable() {

        @Override
        public void run() {
            // and put it into the workflow variables dialog
            WorkflowVariablesDialog dialog = new WorkflowVariablesDialog(d.getActiveShell(), wf);
            dialog.open();
        }
    });
}
Also used : WorkflowManager(org.knime.core.node.workflow.WorkflowManager) WorkflowVariablesDialog(org.knime.workbench.ui.wfvars.WorkflowVariablesDialog) Display(org.eclipse.swt.widgets.Display)

Example 42 with WorkflowManager

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

the class ResetWorkflowAction method run.

/**
 * {@inheritDoc}
 */
@Override
public void run() {
    WorkflowManager workflow = getWorkflow();
    WorkflowManager.ROOT.resetAndConfigureNode(workflow.getID());
}
Also used : WorkflowManager(org.knime.core.node.workflow.WorkflowManager)

Example 43 with WorkflowManager

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

the class AbstractBlobsInWorkflowTest method setUp.

/**
 * {@inheritDoc}
 */
@Override
protected void setUp() throws Exception {
    m_wfmDir = FileUtil.createTempDir(getClass().getSimpleName());
    WorkflowCreationHelper creationHelper = new WorkflowCreationHelper();
    creationHelper.setWorkflowContext(new WorkflowContext.Factory(m_wfmDir).createContext());
    WorkflowManager m = WorkflowManager.ROOT.createAndAddProject("Blob test", creationHelper);
    RuntimeNodeModel createModel = new RuntimeNodeModel(0, 1) {

        /**
         * {@inheritDoc}
         */
        @Override
        protected BufferedDataTable[] execute(final BufferedDataTable[] inData, final ExecutionContext exec) throws Exception {
            return new BufferedDataTable[] { createBDT(exec) };
        }
    };
    NodeID createID = m.createAndAddNode(new RuntimeNodeFactory(createModel));
    // add a sequence of cache nodes
    NodeID[] cacheIDs = new NodeID[10];
    CacheNodeFactory cacheNodeFactory = new CacheNodeFactory();
    for (int i = 0; i < cacheIDs.length; i++) {
        cacheIDs[i] = m.createAndAddNode(cacheNodeFactory);
        if (i == 0) {
            m.addConnection(createID, 1, cacheIDs[i], 1);
        } else {
            m.addConnection(cacheIDs[i - 1], 1, cacheIDs[i], 1);
        }
    }
    final AtomicReference<Throwable> failure = new AtomicReference<Throwable>();
    RuntimeNodeModel checkModel = new RuntimeNodeModel(1, 0) {

        /**
         * {@inheritDoc}
         */
        @Override
        protected BufferedDataTable[] execute(final BufferedDataTable[] inData, final ExecutionContext exec) throws Exception {
            try {
                new DataTableDiffer().compare(inData[0], createBDT(exec));
            } catch (TestEvaluationException tee) {
                failure.set(tee);
                throw tee;
            }
            return new BufferedDataTable[] {};
        }
    };
    NodeID checkID = m.createAndAddNode(new RuntimeNodeFactory(checkModel));
    m.addConnection(cacheIDs[cacheIDs.length - 1], 1, checkID, 1);
    m_flow = m;
    m.executeAllAndWaitUntilDone();
    assertNull(failure.get());
    assertTrue(m.getNodeContainerState().isExecuted());
}
Also used : CacheNodeFactory(org.knime.base.node.util.cache.CacheNodeFactory) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) CacheNodeFactory(org.knime.base.node.util.cache.CacheNodeFactory) RuntimeNodeFactory(org.knime.testing.node.runtime.RuntimeNodeFactory) AtomicReference(java.util.concurrent.atomic.AtomicReference) TestEvaluationException(org.knime.testing.node.differNode.TestEvaluationException) DataTableDiffer(org.knime.testing.node.differNode.DataTableDiffer) WorkflowCreationHelper(org.knime.core.node.workflow.WorkflowCreationHelper) ExecutionContext(org.knime.core.node.ExecutionContext) RuntimeNodeModel(org.knime.testing.node.runtime.RuntimeNodeModel) BufferedDataTable(org.knime.core.node.BufferedDataTable) NodeID(org.knime.core.node.workflow.NodeID) RuntimeNodeFactory(org.knime.testing.node.runtime.RuntimeNodeFactory)

Example 44 with WorkflowManager

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

the class ReadContextPropertyConfiguration method extractContextProperty.

private static String extractContextProperty(final String property) {
    WorkflowManager manager = NodeContext.getContext().getWorkflowManager();
    if (CONTEXT_WORKFLOW_NAME.equals(property)) {
        return manager.getName();
    }
    if (CONTEXT_WORKFLOW_PATH.equals(property)) {
        WorkflowContext context = manager.getContext();
        File wfLocation = context.getOriginalLocation() == null ? context.getCurrentLocation() : context.getOriginalLocation();
        File mpLocation = context.getMountpointRoot();
        if (mpLocation == null || wfLocation == null) {
            return "";
        }
        String wfPath = wfLocation.getAbsolutePath();
        String mpPath = mpLocation.getAbsolutePath();
        assert wfPath.startsWith(mpPath);
        String resultPath = wfPath.substring(mpPath.length());
        return resultPath.replace("\\", "/");
    }
    if (CONTEXT_WORKFLOW_ABSOLUTE_PATH.equals(property)) {
        WorkflowContext context = manager.getContext();
        File wfLocation = context.getCurrentLocation();
        if (wfLocation == null) {
            return "";
        }
        return wfLocation.getAbsolutePath().replace("\\", "/");
    }
    if (CONTEXT_SERVER_USER.equals(property)) {
        return manager.getContext().getUserid();
    }
    if (CONTEXT_TEMP_LOCATION.equals(property)) {
        return manager.getContext().getTempLocation().getAbsolutePath();
    }
    AuthorInformation author = manager.getAuthorInformation();
    if (author != null) {
        if (CONTEXT_AUTHOR.equals(property)) {
            return author.getAuthor();
        }
        if (CONTEXT_EDITOR.equals(property)) {
            return author.getLastEditor();
        }
        if (CONTEXT_CREATION_DATE.equals(property)) {
            Date creationDate = author.getAuthoredDate();
            if (creationDate != null) {
                return creationDate.toString();
            }
        }
        if (CONTEXT_LAST_MODIFIED.equals(property)) {
            Date modDate = author.getLastEditDate();
            if (modDate != null) {
                return modDate.toString();
            }
        }
    }
    return null;
}
Also used : WorkflowManager(org.knime.core.node.workflow.WorkflowManager) WorkflowContext(org.knime.core.node.workflow.WorkflowContext) AuthorInformation(org.knime.core.node.workflow.WorkflowManager.AuthorInformation) File(java.io.File) Date(java.util.Date)

Example 45 with WorkflowManager

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

the class WizardPageUtilTest method testGetWizardPageNodes.

/**
 * Tests {@link WizardPageUtil#getWizardPageNodes(WorkflowManager)} etc.
 */
@Test
public void testGetWizardPageNodes() {
    NodeID componentWithNodeViewNode = m_wfm.collapseIntoMetaNode(new NodeID[] { WorkflowManagerUtil.createAndAddNode(m_wfm, new NodeViewNodeFactory(0, 0)).getID() }, new WorkflowAnnotation[0], "component").getCollapsedMetanodeID();
    m_wfm.convertMetaNodeToSubNode(componentWithNodeViewNode);
    WorkflowManager componentWfm = ((SubNodeContainer) m_wfm.getNodeContainer(componentWithNodeViewNode)).getWorkflowManager();
    List<NativeNodeContainer> wizardPageNodes = WizardPageUtil.getWizardPageNodes(componentWfm);
    assertThat(wizardPageNodes.size(), is(1));
    assertThat(wizardPageNodes.get(0).getName(), is("NodeView"));
    NodeID componentWithAComponentWithNodeView = m_wfm.collapseIntoMetaNode(new NodeID[] { componentWithNodeViewNode }, new WorkflowAnnotation[0], "component of a component").getCollapsedMetanodeID();
    m_wfm.convertMetaNodeToSubNode(componentWithAComponentWithNodeView);
    componentWfm = ((SubNodeContainer) m_wfm.getNodeContainer(componentWithAComponentWithNodeView)).getWorkflowManager();
    wizardPageNodes = WizardPageUtil.getWizardPageNodes(componentWfm);
    assertTrue(wizardPageNodes.isEmpty());
    wizardPageNodes = WizardPageUtil.getWizardPageNodes(componentWfm, false);
    assertTrue(wizardPageNodes.isEmpty());
    wizardPageNodes = WizardPageUtil.getWizardPageNodes(componentWfm, true);
    assertThat(wizardPageNodes.size(), is(1));
    assertThat(wizardPageNodes.get(0).getName(), is("NodeView"));
    NodeID componentWithNodeWizardNode = m_wfm.collapseIntoMetaNode(new NodeID[] { WorkflowManagerUtil.createAndAddNode(m_wfm, new WizardNodeFactory()).getID() }, new WorkflowAnnotation[0], "component").getCollapsedMetanodeID();
    m_wfm.convertMetaNodeToSubNode(componentWithNodeWizardNode);
    componentWfm = ((SubNodeContainer) m_wfm.getNodeContainer(componentWithNodeWizardNode)).getWorkflowManager();
    wizardPageNodes = WizardPageUtil.getWizardPageNodes(componentWfm);
    assertThat(wizardPageNodes.size(), is(1));
    assertThat(wizardPageNodes.get(0).getName(), is("Wizard"));
}
Also used : NodeViewNodeFactory(org.knime.testing.node.view.NodeViewNodeFactory) SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NodeID(org.knime.core.node.workflow.NodeID) NativeNodeContainer(org.knime.core.node.workflow.NativeNodeContainer) WorkflowAnnotation(org.knime.core.node.workflow.WorkflowAnnotation) Test(org.junit.Test)

Aggregations

WorkflowManager (org.knime.core.node.workflow.WorkflowManager)99 NodeID (org.knime.core.node.workflow.NodeID)38 NodeContainer (org.knime.core.node.workflow.NodeContainer)22 SubNodeContainer (org.knime.core.node.workflow.SubNodeContainer)19 NativeNodeContainer (org.knime.core.node.workflow.NativeNodeContainer)15 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)15 File (java.io.File)14 ConnectionContainer (org.knime.core.node.workflow.ConnectionContainer)14 IOException (java.io.IOException)11 ArrayList (java.util.ArrayList)10 Map (java.util.Map)10 SingleNodeContainer (org.knime.core.node.workflow.SingleNodeContainer)10 WorkflowAnnotation (org.knime.core.node.workflow.WorkflowAnnotation)10 MessageBox (org.eclipse.swt.widgets.MessageBox)9 NodeContainerUI (org.knime.core.ui.node.workflow.NodeContainerUI)9 List (java.util.List)8 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)8 NodeUIInformation (org.knime.core.node.workflow.NodeUIInformation)8 WorkflowContext (org.knime.core.node.workflow.WorkflowContext)8 WorkflowCopyContent (org.knime.core.node.workflow.WorkflowCopyContent)8