JAVA snippet is repeated for each row in data table

Dear KNIME fanatics,

I wanted to pauze a complex workflow, depending on a variable, for the user to have the chance to manually correct a datatable in the middle of the workflow.

I thought I had found a solution: an ‘ok’’ pop-up in the middle of the workflow, giving the user the chance to adapt a datatable in another branch of the workflow . Once the user presses the ‘OK’ button in the pop-up, the entire workflow would continue.

KNIME_project.knwf (8.7 KB)

However, the pop-up reappears for every row in the data table feeding the java snippet, and it is important the datatable is kept. How can I make the JAVA snippet only appear once?

Big thanks in advance for your help^!

Kind regards,

Yves

Hello @yverhaeg,

maybe this topic helps:

Welcome to KNIME Community!

Br,
Ivan

Thanks Ivan,

Very helpful indeed:

I cannot do the first option (reduce the data table to 1 row) as I will loose my data, but I can add an IF-statement in the JAVA code, for example to only show the pop-up for RowID ‘Row0’.

2 Likes

Glad to hear that @yverhaeg!
Ivan

Hi @yverhaeg , when it comes to running any data node, it’s a common mistake to forget that whatever runs in that node will be applied and run on each of the rows from the input.

And indeed, if you want to have a popup, you have to somehow reduce the data to 1 row. I understand what you said about losing your data, but that would normally be done as a forked branch, and you can even use an IF Switch to control if needed. In your case, it does not look you need to control it, so it can be done just by forking alone, and by reducing the rows to just 1 in the forked branch.

Something like this would do:
image

Because Node 2 is linked to Node 4, Node 2 will only execute after Node 4 is completed, that is only after the OK from the popup is pressed.

image

As you can see from my execution of Node 2, it’s queued and waiting for Node 4 to complete. I get only one popup, and my original data remains untouched. My 5 rows are still there:
image

This is much faster than what you implemented. My Java code is going through only 1 row, but in your case, while it’s going to do only one popup, it’s still going through all the rows, and even worse, it will run that if statement all the time, and if statements are slow (compared to not having them), and you are running that if statement for each row.

Here’s the workflow if you are interested: Continue after OK from Popup message.knwf (10.1 KB)

3 Likes

Oh my…this kind of support I could not have imagined

I’ll be implementing this right away,

Bruno, thanks a lot for this!

Kind regards,

Yves

4 Likes

No problem @yverhaeg , happy to help

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.