use of fi.otavanopisto.muikku.plugins.dnm.parser.content.OptionListOption in project muikku by otavanopisto.
the class FieldTranslator method translateOptionList.
public SelectFieldMeta translateOptionList(String name, String listType, List<OptionListOption> options) {
List<SelectFieldOptionMeta> translatedOptions = new ArrayList<>();
for (OptionListOption option : options) {
translatedOptions.add(new SelectFieldOptionMeta(option.getName(), option.getPoints() != null && option.getPoints() > 0, option.getText()));
}
// Fix for bug #499; generate unique values for empty option names
for (SelectFieldOptionMeta translatedOption : translatedOptions) {
if (StringUtils.isEmpty(translatedOption.getName())) {
translatedOption.setName(generateUniqueName(translatedOptions));
}
}
// Nexus: dropdown | list | radio | radio_horz
// Muikku: dropdown | list | radio-vertical | radio-horizontal
String newListType = listType;
if ("radio".equals(listType)) {
newListType = "radio-vertical";
} else if ("radio_horz".equals(listType)) {
newListType = "radio-horizontal";
}
return new SelectFieldMeta(name, newListType, translatedOptions, null);
}
Aggregations