Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit 384774d

Browse files
1 parent 5514e0d commit 384774d

1 file changed

Lines changed: 21 additions & 13 deletions

File tree

sormas-ui/src/main/java/de/symeda/sormas/ui/symptoms/SymptomsForm.java

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
import java.util.Arrays;
3434
import java.util.List;
35+
import java.util.Set;
3536
import java.util.stream.Collectors;
3637
import java.util.stream.Stream;
3738

@@ -50,7 +51,6 @@
5051
import com.vaadin.v7.ui.ComboBox;
5152
import com.vaadin.v7.ui.DateField;
5253
import com.vaadin.v7.ui.Field;
53-
import com.vaadin.v7.ui.OptionGroup;
5454
import com.vaadin.v7.ui.TextField;
5555

5656
import de.symeda.sormas.api.Disease;
@@ -1037,27 +1037,35 @@ public Button createButtonSetClearedToSymptomState(String caption, SymptomState
10371037

10381038
Button button = ButtonHelper.createButton(caption, event -> {
10391039
for (Object symptomId : unconditionalSymptomFieldIds) {
1040-
Field<SymptomState> symptom = (Field<SymptomState>) getFieldGroup().getField(symptomId);
1041-
if (symptom.isVisible() && symptom.getValue() == null) {
1042-
symptom.setValue(symptomState);
1040+
Field<Object> symptom = (Field<Object>) getFieldGroup().getField(symptomId);
1041+
if (symptom.isVisible() && (Set.class.isAssignableFrom(symptom.getValue().getClass()) && ((Set) symptom.getValue()).size() == 0)) {
1042+
Set<SymptomState> value = (Set<SymptomState>) symptom.getValue();
1043+
value.add(symptomState);
1044+
symptom.setValue(value);
10431045
}
10441046
}
10451047
for (Object symptomId : conditionalBleedingSymptomFieldIds) {
1046-
Field<SymptomState> symptom = (Field<SymptomState>) getFieldGroup().getField(symptomId);
1047-
if (symptom.isVisible() && symptom.getValue() == null) {
1048-
symptom.setValue(symptomState);
1048+
Field<Object> symptom = (Field<Object>) getFieldGroup().getField(symptomId);
1049+
if (symptom.isVisible() && (Set.class.isAssignableFrom(symptom.getValue().getClass()) && ((Set) symptom.getValue()).size() == 0)) {
1050+
Set<SymptomState> value = (Set<SymptomState>) symptom.getValue();
1051+
value.add(symptomState);
1052+
symptom.setValue(value);
10491053
}
10501054
}
10511055
for (Object symptomId : lesionsFieldIds) {
1052-
Field<SymptomState> symptom = (Field<SymptomState>) getFieldGroup().getField(symptomId);
1053-
if (symptom.isVisible() && symptom.getValue() == null) {
1054-
symptom.setValue(symptomState);
1056+
Field<Object> symptom = (Field<Object>) getFieldGroup().getField(symptomId);
1057+
if (symptom.isVisible() && (Set.class.isAssignableFrom(symptom.getValue().getClass()) && ((Set) symptom.getValue()).size() == 0)) {
1058+
Set<SymptomState> value = (Set<SymptomState>) symptom.getValue();
1059+
value.add(symptomState);
1060+
symptom.setValue(value);
10551061
}
10561062
}
10571063
for (Object symptomId : monkeypoxImageFieldIds) {
1058-
Field<SymptomState> symptom = (Field<SymptomState>) getFieldGroup().getField(symptomId);
1059-
if (symptom.isVisible() && symptom.getValue() == null) {
1060-
symptom.setValue(symptomState);
1064+
Field<Object> symptom = (Field<Object>) getFieldGroup().getField(symptomId);
1065+
if (symptom.isVisible() && (Set.class.isAssignableFrom(symptom.getValue().getClass()) && ((Set) symptom.getValue()).size() == 0)) {
1066+
Set<SymptomState> value = (Set<SymptomState>) symptom.getValue();
1067+
value.add(symptomState);
1068+
symptom.setValue(value);
10611069
}
10621070
}
10631071
}, ValoTheme.BUTTON_LINK);

0 commit comments

Comments
 (0)