Search in sources :

Example 11 with CountryDto

use of de.symeda.sormas.api.infrastructure.country.CountryDto in project SORMAS-Project by hzi-braunschweig.

the class CountryFacadeEjbTest method testArchive.

@Test
public void testArchive() {
    Country country = creator.createCountry("Romania", "ROU", "642");
    getCountryFacade().archive(country.getUuid());
    CountryDto actual = getCountryFacade().getByUuid(country.getUuid());
    assertTrue(actual.isArchived());
}
Also used : CountryDto(de.symeda.sormas.api.infrastructure.country.CountryDto) Country(de.symeda.sormas.backend.infrastructure.country.Country) Test(org.junit.Test) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest)

Example 12 with CountryDto

use of de.symeda.sormas.api.infrastructure.country.CountryDto 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;
    }
}
Also used : ImportErrorException(de.symeda.sormas.api.importexport.ImportErrorException) CountryDto(de.symeda.sormas.api.infrastructure.country.CountryDto) InvalidColumnException(de.symeda.sormas.api.importexport.InvalidColumnException) EmptyValueException(de.symeda.sormas.api.utils.EmptyValueException) ValidationRuntimeException(de.symeda.sormas.api.utils.ValidationRuntimeException)

Aggregations

CountryDto (de.symeda.sormas.api.infrastructure.country.CountryDto)12 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)8 Test (org.junit.Test)8 Country (de.symeda.sormas.backend.infrastructure.country.Country)5 EmptyValueException (de.symeda.sormas.api.utils.EmptyValueException)3 ValidationRuntimeException (de.symeda.sormas.api.utils.ValidationRuntimeException)3 ImportErrorException (de.symeda.sormas.api.importexport.ImportErrorException)2 InvalidColumnException (de.symeda.sormas.api.importexport.InvalidColumnException)2 CsvValidationException (com.opencsv.exceptions.CsvValidationException)1 IntrospectionException (java.beans.IntrospectionException)1 PropertyDescriptor (java.beans.PropertyDescriptor)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Date (java.util.Date)1