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();
}
});
}
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());
}
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());
}
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;
}
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"));
}
Aggregations