I want to use methods from the org.knime.core.node.workflow.WorkflowManager library. I can successfully work with the org.knime.core.node.NodeLogger library, but I am unable to connect to WorkflowManager.
KNIME Analytics Platform v4.7.2.v202303231026
The code that I will run using the required library:
public void saveWorkflowState() {
try {
org.knime.core.data.columnar.schema.ColumnarValueSchemaUtils
// Getting the main Workflow Manager object for accessing the workflow
WorkflowManager workflowManager = WorkflowManager.ROOT;
// Creating a file to save the state
File file = new File("path/to/save/folder/workflow_state.txt");
try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
// Logging the status of all workflow nodes
workflowManager.getNodeContainers().forEach(nodeContainer -> {
try {
String nodeName = nodeContainer.getName();
String nodeStatus = nodeContainer.getState().toString();
writer.write("Node: " + nodeName + ", Status: " + nodeStatus);
writer.newLine();
} catch (Exception e) {
e.printStackTrace();
}
});
}
} catch (Exception e) {
e.printStackTrace();
}
}```
![image|689x249](upload://9gk8IloXU5m3YiYKu0FarmNKphI.png)