Using the data import as a non-GUI service sort of a thing

Hi there. I think this is one for Mario.

I’d like to create a service to import a list of countries into the application into the app when it starts up (if the list of countries does not exist). I have the list in a CSV file, so I thought I could leverage the data import add-on to do the heavy lifting.

Is there a guide to using the data import in this way?

Hi,

jupp, it is possible. The main interaction point would be GenericDataImporterService (see: https://github.com/mariodavid/cuba-component-data-import/blob/master/modules/global/src/de/diedavids/cuba/dataimport/service/GenericDataImporterService.java)

You have to create ImportData instances manually (see https://github.com/mariodavid/cuba-component-data-import/blob/master/modules/global/test/de/diedavids/cuba/dataimport/dto/ImportDataImplSpec.groovy for a example usage).

However, the use-case you describe seems to be like the admin-tools-addon also covers your case. See: https://github.com/cuba-platform/admin-tools-addon#auto-import-subsystem for more details.

Bye
Mario

1 Like