Skip to content

Commit 9f83e52

Browse files
Validating disease for environment samples
1 parent 243370d commit 9f83e52

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

sormas-backend/src/main/java/de/symeda/sormas/backend/customizableenum/CustomizableEnumFacadeEjb.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,8 @@ private CustomizableEnumValueIndexDto toIndexDto(CustomizableEnumValue entity) {
277277
@Override
278278
@SuppressWarnings("unchecked")
279279
public <T extends CustomizableEnum> T getEnumValue(CustomizableEnumType type, Disease disease, String value) {
280-
if (!enumValues.get(type).getOrDefault(disease, Collections.emptyList()).contains(value)) {
280+
//As of today diseases are not applicable for environment.
281+
if (disease!=null && !enumValues.get(type).getOrDefault(disease, Collections.emptyList()).contains(value)) {
281282
throw new IllegalArgumentException(String.format("Invalid enum value %s for customizable enum type %s", value, type.toString()));
282283
}
283284

@@ -360,7 +361,8 @@ private <T extends CustomizableEnum> T buildCustomizableEnum(
360361
T enumValue = enumClass.getDeclaredConstructor().newInstance();
361362
enumValue.setValue(value);
362363
enumValue.setCaption(enumValuesByLanguage.get(enumClass).get(language).get(value));
363-
enumValue.setProperties(getEnumInfo(type, disease, value).getProperties());
364+
// set the properties if the disease is not null, this disease check is happening in the getEnumInfo method
365+
enumValue.setProperties(getEnumInfo(type, disease, value)!=null?getEnumInfo(type, disease, value).getProperties():null);
364366
return enumValue;
365367
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
366368
throw new RuntimeException(e);

0 commit comments

Comments
 (0)