use of de.symeda.sormas.api.infrastructure.country.CountryDto in project SORMAS-Project by hzi-braunschweig.
the class CountryImporter method insertColumnEntryIntoData.
/**
* Inserts the entry of a single cell into the infrastructure object.
*/
private void insertColumnEntryIntoData(CountryDto newEntityDto, String value, String[] entityPropertyPath) throws InvalidColumnException, ImportErrorException {
Object currentElement = newEntityDto;
for (int i = 0; i < entityPropertyPath.length; i++) {
String headerPathElementName = entityPropertyPath[i];
try {
if (i != entityPropertyPath.length - 1) {
currentElement = new PropertyDescriptor(headerPathElementName, currentElement.getClass()).getReadMethod().invoke(currentElement);
} else {
PropertyDescriptor pd = new PropertyDescriptor(headerPathElementName, currentElement.getClass());
Class<?> propertyType = pd.getPropertyType();
if (!executeDefaultInvoke(pd, currentElement, value, entityPropertyPath)) {
throw new UnsupportedOperationException(I18nProperties.getValidationError(Validations.importPropertyTypeNotAllowed, propertyType.getName()));
}
}
} catch (IntrospectionException e) {
throw new InvalidColumnException(buildEntityProperty(entityPropertyPath));
} catch (InvocationTargetException | IllegalAccessException e) {
throw new ImportErrorException(I18nProperties.getValidationError(Validations.importErrorInColumn, buildEntityProperty(entityPropertyPath)));
} catch (IllegalArgumentException e) {
throw new ImportErrorException(value, buildEntityProperty(entityPropertyPath));
} catch (ImportErrorException e) {
throw e;
} catch (Exception e) {
logger.error("Unexpected error when trying to import infrastructure data: " + e.getMessage());
throw new ImportErrorException(I18nProperties.getValidationError(Validations.importUnexpectedError));
}
}
ImportLineResultDto<CountryDto> constraintErrors = validateConstraints(newEntityDto);
if (constraintErrors.isError()) {
throw new ImportErrorException(constraintErrors.getMessage());
}
}
use of de.symeda.sormas.api.infrastructure.country.CountryDto in project SORMAS-Project by hzi-braunschweig.
the class CountryFacadeEjbTest method testSaveCountryIsoCodeExists.
@Test(expected = ValidationRuntimeException.class)
public void testSaveCountryIsoCodeExists() {
creator.createCountry("Romania", "ROU", "642");
CountryDto duplicate = new CountryDto();
duplicate.setDefaultName("Romania");
duplicate.setIsoCode("ROU");
getCountryFacade().save(duplicate);
}
use of de.symeda.sormas.api.infrastructure.country.CountryDto in project SORMAS-Project by hzi-braunschweig.
the class CountryFacadeEjbTest method testSaveCountryIsoCodeEmpty.
@Test(expected = EmptyValueException.class)
public void testSaveCountryIsoCodeEmpty() {
CountryDto country = new CountryDto();
country.setDefaultName("Romania");
getCountryFacade().save(country);
}
use of de.symeda.sormas.api.infrastructure.country.CountryDto in project SORMAS-Project by hzi-braunschweig.
the class CountryFacadeEjbTest method testSaveCountryUnoCodeExists.
@Test(expected = ValidationRuntimeException.class)
public void testSaveCountryUnoCodeExists() {
creator.createCountry("Romania", "ROU", "642");
CountryDto duplicate = new CountryDto();
duplicate.setDefaultName("Germany");
duplicate.setIsoCode("DEU");
duplicate.setUnoCode("642");
getCountryFacade().save(duplicate);
}
use of de.symeda.sormas.api.infrastructure.country.CountryDto in project SORMAS-Project by hzi-braunschweig.
the class InfrastructureController method editCountry.
public void editCountry(String uuid) {
CountryDto country = FacadeProvider.getCountryFacade().getByUuid(uuid);
CommitDiscardWrapperComponent<CountryEditForm> editComponent = getCountryEditComponent(country);
String caption = I18nProperties.getString(Strings.headingEditCountry);
VaadinUiUtil.showModalPopupWindow(editComponent, caption);
}
Aggregations