NodeMigrationRule to convert node with ConfigurableNodeFactory

I am currently updating some of our public and internal database nodes to use the ‘DB’ framework, and as part of the process creating a NodeMigrationRule for each node as I figure a DB implementation. So far, so good, but at the same time it would seem like a good opportunity to modernise some of the nodes to be Configurable (e.g. there are several which could be combined into a single node with swappable port types) - what I cant see is how to configure the ‘configurable’ part of the new node (e.g. to ensure it has the correct port type selected)

Is this possible? (And if so, how is it possible!)



PS - I think I can possibly think of a cludgy workaround whereby a NodeMigrationRule works in tandem with a NodeFactoryClassMapper, but I’d really like to avoid that many moving parts, which sounds like a route to pain and bugs!

Hi Steve,

You can find example code of nodes with variable port types and ports using the following GitHub search

Most of the open-source nodes with dynamic ports (reachable via the github link above) should serve as reasonable examples and can be easily modified to support dynamic ports of arbitrary or multiple types.

A node with a dynamic port of a specific type (e.g. BufferedDataTable) would use a code

final var builder = new PortsConfigurationBuilder();
builder.addExtendableInputPortGroup("input", BufferedDataTable.TYPE);

Where as node with a dynamic port of any type uses:

builder.addExtendableInputPortGroup("input", p -> true);

If you want to restrict the port type to a handfull of predefined ones you can use

builder.addExtendableInputPortGroup("input", TYPE1, TYPE2, TYPE3);

Hope this helps,

1 Like

Hi @temesgen-dadi,

Yep, that bit I have working in a number of places, but what I am looking for is whether it is possible from within a NodeMigrationRule to set the configurable ports to a non-default set-up? I think it might not be, as in the KNIME core DB integration there is at least one place where, depending on circumstances, a NodeMigrationRule returns a new-but-deprecated node if the replacement is actually a Configurable node but not with the default configurable settings, as those don’t appear to be accessible to either NodeMigrationRule or in the NodeSettingsMigrationManager instance available in NodeMigrationRule#migrate()


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