hansva opened a new issue, #9566:
URL: https://github.com/apache/hop/issues/9566
### What needs to happen?
Several metadata types store a plugin-backed object: a pipeline/workflow run
configuration holds an engine run configuration, an execution data profile
holds samplers, an execution information location holds its location type, and
so on. When such an object is serialized, its factory's `getObjectId` writes
the plugin id as the key, and `createObject` reads it back.
For these factories `getObjectId` returns the id stored on the object and
nothing else:
| Factory | Returns |
|---|---|
| `PipelineRunConfigurationMetadataObjectFactory` | `getEnginePluginId()` |
| `WorkflowRunConfigurationMetadataObjectFactory` | `getEnginePluginId()` |
| `IExecutionDataSampler.ExecutionDataSamplerObjectFactory` |
`getPluginId()` |
| `IExecutionInfoLocation.ExecutionInfoLocationObjectFactory` |
`getPluginId()` |
| `IDataCatalog` factory | `getPluginId()` |
| `IDataStream` factory | `getPluginId()` |
`createObject` sets the id, so objects that were loaded keep it. But an
object created in code with its default constructor has none:
- `new LocalPipelineRunConfiguration()`, `new
LocalWorkflowRunConfiguration()`, `new RemotePipelineRunConfiguration()`, and
also what `LocalPipelineEngine.createDefaultPipelineEngineRunConfiguration()`
returns;
- `new FirstRowsExecutionDataSampler()` and the other samplers
(`ExecutionDataSamplerBase()` leaves `pluginId` empty; only the constructor
with a sample size sets it).
Saved like that, the object is written under a `null` key, and loading it
fails or silently loses the object. Hop's own code avoids this by setting the
id by hand each time: `PipelineExecutionConfigurationDialog`,
`WorkflowExecutionConfigurationDialog` and `ProjectsGuiPlugin` call
`setEnginePluginId("Local")` right after `new Local…RunConfiguration()`. Any
other code, including plugins, that forgets this writes metadata that can't be
read back.
The database, graph database and AI provider factories don't have this
problem: when the object has no id, their `getObjectId` looks the plugin up in
the registry by the object's class and sets it.
### Expected
An object created with its default constructor can be saved and loaded
again, without the caller setting its plugin id.
### Proposed fix
1. **Default constructors set their own id** where the object isn't the
plugin class itself, and the registry can't find it:
- each engine run configuration (`LocalPipelineRunConfiguration`,
`LocalWorkflowRunConfiguration`, `RemotePipelineRunConfiguration`, …) sets its
engine id and name;
- each sampler's default constructor passes its id and name, as its
sample-size constructor already does.
2. **`getObjectId` falls back to the plugin registry** in the sampler,
execution information location, data catalog and data stream factories, as
`DatabaseMetaObjectFactory` already does: `PluginRegistry.getPlugin(<plugin
type>.class, object)`, setting the id and name on the object.
3. **`getObjectId` fails with a clear error** if there is still no id, as
`AiProviderObjectFactory` does, instead of writing a `null` key.
4. Remove the `setEnginePluginId("Local")` calls that are then redundant.
### Tests
- For each run configuration, sampler and location type: an object made with
its default constructor round-trips through JSON serialization and comes back
as the same type, without setting the id by hand.
- A factory given an object whose plugin can't be found throws a
`HopException` naming the class.
### Issue Priority
Priority: 2
### Issue Component
Component: API
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]