event when deleting a node

How I can know (in my node code) if the node has been deleted from the workflow ?

There is no way to find this out from within the node. Out of curiosity: why do you want to know it?

Hi,

you could overwrite the onDispose() method in your NodeModel which is called when the node is deleted or the workflow is closed.

Bye,

Tobias

1 Like

Hi,

you could overwrite the onDispose() method in your NodeModel which is called when the node is deleted or the workflow is closed.

Bye,

Tobias

Hi All (in particular Tobias):

The onDispose() method is not public API yet (not it available in v2.3.x!) but will be in v2.4. The method was added very recently.

v2.4 is planned for this summer.

Regards,
  Bernd

1 Like

Is there a way to differentiate between workflow “Delete” and “Close” states, in onDispose method? The idea is to do some cleanup only if the node is being deleted.

Many thanks!

Do you plan to write temporary files or what do you want to do? You can write them to the node local storage, which is the folder node is in within the workflow.
You can access that using a knime://knime.node/ url.

best,
Gabriel

Hi Gabriel,

Thanks for your prompt response!

The idea is to manage a few files that are associated with the node being deleted, please note that these files are NOT created/edited by the KNIME framework but by our own node, and these files live within the workflow directory.

The file name is linked to the node number (#), and as the node is being deleted, I would like to delete the corresponding file.

Let me know if that does not answer your questions.

Many thanks!

Hi @developer1

That sounds like the perfect use case for the method I described, how do you resolve the workflow location at the moment, to save the node related files? Maybe all you need to do is to change that path to be node relative.

best,
Gabriel