use of de.symeda.sormas.api.utils.EmptyValueException in project SORMAS-Project by hzi-braunschweig.
the class CountryImporter method importDataFromCsvLine.
@Override
protected ImportLineResult importDataFromCsvLine(String[] values, String[] entityClasses, String[] entityProperties, String[][] entityPropertyPaths, boolean firstLine) throws IOException, InvalidColumnException {
if (values.length > entityProperties.length) {
writeImportError(values, I18nProperties.getValidationError(Validations.importLineTooLong));
return ImportLineResult.ERROR;
}
CountryDto newEntityDto = CountryDto.build();
boolean iHasImportError = insertRowIntoData(values, entityClasses, entityPropertyPaths, false, (cellData) -> {
try {
if (!StringUtils.isEmpty(cellData.getValue())) {
insertColumnEntryIntoData(newEntityDto, cellData.getValue(), cellData.getEntityPropertyPath());
}
} catch (ImportErrorException | InvalidColumnException e) {
return e;
}
return null;
});
if (!iHasImportError) {
try {
FacadeProvider.getCountryFacade().save(newEntityDto, allowOverwrite);
return ImportLineResult.SUCCESS;
} catch (EmptyValueException e) {
writeImportError(values, e.getMessage());
return ImportLineResult.ERROR;
} catch (ValidationRuntimeException e) {
writeImportError(values, e.getMessage());
return ImportLineResult.DUPLICATE;
}
} else {
return ImportLineResult.ERROR;
}
}
Aggregations