NodeMigrationRule for NodeFactorySet nodes

I have a set of nodes with a common NodeFactory class implementation, which takes a parameter for it’s constructor argument in order to determine which node is generated. A key from the parameter class is saved to the factory class settings as shown:

	@Override
	public void saveAdditionalFactorySettings(ConfigWO config) {
		super.saveAdditionalFactorySettings(config);
		config.addString("Connection Type Name", connDetails.name());	

and restored via a no-args constructor and reload:

	/**
	 * Internal constructor
	 */
	public VernalisDBConnectorNodeFactory() {
		super(true);
	}
	...

	@Override
	public void loadAdditionalFactorySettings(ConfigRO config)
			throws InvalidSettingsException {

		try {
			connDetails = VernalisConnectionDetails
					.valueOf(config.getString("Connection Type Name"));
		} catch (Exception e) {
			// We should never get here, but just in case either someone has
			// manually edited settings.xml, or the enum member has been
			// deleted...
			throw new InvalidSettingsException("Unable to restore node", e);
		}
		super.loadAdditionalFactorySettings(config);
	}

I wanted to create a NodeMigrationRule in order to allow automatic migration to a new implementation (these are some custom legacy database nodes and a new corresponding set of ‘DB’ versions) - but I cannot see how to do this?

I suspect it isn’t possible, as the NodeMigrationRule mechanism works by calling the no-argument constructor of the new NodeFactory class, and then tries to access the node name, but that is determined by the parameter argument which is not supplied to the constructor nor loaded from the factory class settings as these are not accessible to NodeMigrationRule

The only way I can think of to do this is to created a ‘dummy’ subclass of the new NodeFactory implementation for each possible parameter argument value - but with 113 possible values I’m a bit reluctant to go that way!

Am I missing something obvious?

Thanks

Steve

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