Closed reckart closed 6 years ago
@reckart Do you have an example importer/exporter that we can follow? I would put one into inception-recommondation
. For the functionality, I would just go through the list of recommenders (inject the recommenderservice), turn them into json and save them via exportedProject.setProperty
and vice versa.
What happens when I persist a recommender which has a project field inside it? Do I need to set the project again from the outside? What happens to the database generated IDs of the imported stuff? What about the layer?
You could have a look e.g. at the LayerExporter
and the TagSetExporter
.
Exporters can have dependencies on other exporters (mind that exporters also import - don't worry about the name). So when your exporter depends e.g. on layers, then getImportDependencies
needs to be overwritten and return a list containing the LayerExporter class.
Then during import, you need to look up already imported objects by their "business" key instead of their ID. E.g. layers have a unique name within the project, so you look them up by name. The target project to import to is passed as an argument to .ProjectExporter.importData(ProjectImportRequest, Project, ExportedProject, ZipFile)
.
Oh, and on export, you do not persist IDs, but you write the business key (e.g. the layer name). The project ID can be skipped because exports are per-project.
For every DB entity, we have a JSON DTO which is used during export/import (cf. LayerExporter
and TagSetExporter
).
Implement a
ProjectExporter
for the recommendation module: