When exporting to World and PDF with world list field return it's label instead of it's value (ref #287)

This commit is contained in:
George Kalampokis 2020-09-03 10:46:11 +03:00
parent 8951b61b3b
commit fc7f8d4278
1 changed files with 15 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import eu.eudat.logic.utilities.documents.types.ParagraphStyle;
import eu.eudat.logic.utilities.interfaces.ApplierWithValue; import eu.eudat.logic.utilities.interfaces.ApplierWithValue;
import eu.eudat.models.data.components.commons.datafield.CheckBoxData; import eu.eudat.models.data.components.commons.datafield.CheckBoxData;
import eu.eudat.models.data.components.commons.datafield.ComboBoxData; import eu.eudat.models.data.components.commons.datafield.ComboBoxData;
import eu.eudat.models.data.components.commons.datafield.WordListData;
import eu.eudat.models.data.user.components.datasetprofile.Field; import eu.eudat.models.data.user.components.datasetprofile.Field;
import eu.eudat.models.data.user.components.datasetprofile.FieldSet; import eu.eudat.models.data.user.components.datasetprofile.FieldSet;
import eu.eudat.models.data.user.components.datasetprofile.Section; import eu.eudat.models.data.user.components.datasetprofile.Section;
@ -284,7 +285,20 @@ public class WordBuilder {
} }
return sb.toString(); return sb.toString();
} else if (comboboxType.equals("wordlist")) { } else if (comboboxType.equals("wordlist")) {
return field.getValue() != null ? field.getValue().toString() : ""; WordListData wordListData = (WordListData) field.getData();
if (wordListData.getOptions().isEmpty() && field.getValue() != null) {
logger.warn("World List has no values but the field has");
return field.getValue().toString();
} else if (field.getValue() != null){
ComboBoxData<WordListData>.Option selectedOption = null;
for (ComboBoxData<WordListData>.Option option: wordListData.getOptions()) {
if (option.getValue().equals(field.getValue())) {
selectedOption = option;
}
}
return selectedOption != null ? selectedOption.getLabel() : field.getValue().toString();
}
return "";
} }
} }
case "booleanDecision": case "booleanDecision":