Hi @mario,
I have just begun to use the addon and it is working quite well for now.
However you have a small bug in de\diedavids\cuba\dataimport\web\importwizard\ImportWizard.groovy
In the case you use the wizard and check “save configuration for reuse” the statement importExecutionDs.item.file = importFileHandler.saveFile() will be executed twice. The 2nd time fails because it tries to save the same FileDescriptor
a second time.
void closeWizard() {
if (importConfigurationDs.item.reuse) {
// here, the following line will try to create a duplicate file descriptor
**importExecutionDs.item.file = importFileHandler.saveFile()**
importWizardService.saveImportConfiguration(
importConfigurationDs.item,
importAttributeMappersDatasource.items,
uniqueConfigurationDs.items,
importExecutionDs.item
)
}
close(CLOSE_ACTION_ID, true)
}
void startImport() {
try {
ImportExecution importExecution = genericDataImporterService.doDataImport(importConfigurationDs.item, importData)
importExecutionDs.item = importExecution
**importExecutionDs.item.file = importFileHandler.saveFile()**
dataManager.commit(importExecution)
toStep5()
} catch (Exception e) {
log.error('An Error occurred during import', e)
showNotification('An Error occurred during import. See logs for more information', NotificationType.ERROR)
}
}
The fix is simple, just comment out the line or eventually check the file has not been saved already.
As this is an addon and the class is not a bean that I can extend/replace, is there a way for me to fix it in my project ?
EDIT: Fixed.
I overlooked the fact ImportWizard is a screen and thus can be extended. Hereunder the complete fix. There were also issues with entities life cycle.
public void startImport() {
try {
ImportExecution importExecution = genericDataImporterService.doDataImport(importConfigurationDs.getItem(), getImportData());
importExecution.setFile(getImportFileHandler().getUploadedFileDescriptor());
importExecution = getDataManager().commit(importExecution);
importExecutionDs.setItem(importExecution);
toStep5();
} catch (Exception e) {
log.error("An Error occurred during import", e);
showNotification("An Error occurred during import. See logs for more information", NotificationType.ERROR);
}
}
@Override
public void closeWizard() {
if (importConfigurationDs.getItem() != null && nn(importConfigurationDs.getItem().getReuse())) {
importWizardService.saveImportConfiguration(
importConfigurationDs.getItem(),
importAttributeMappersDatasource.getItems(),
uniqueConfigurationDs.getItems(),
importExecutionDs.getItem()
);
}
close(CLOSE_ACTION_ID, true);
}
Regards
Michael