use of org.openforis.collect.designer.model.LabelledItem in project collect by openforis.
the class NewSurveyParametersPopUpVM method initLanguageModel.
private void initLanguageModel() {
List<LabelledItem> languages = new ArrayList<LabelledItem>();
List<String> codes = Languages.getCodes(Standard.ISO_639_1);
for (String code : codes) {
LabelledItem item = new LabelledItem(code, Labels.getLabel(code));
languages.add(item);
}
Collections.sort(languages, new LabelComparator());
languageModel = new BindingListModelListModel<LabelledItem>(new ListModelList<LabelledItem>(languages));
LabelledItem defaultLanguage = LabelledItem.getByCode(languages, Locale.ENGLISH.getLanguage());
form.put(LANGUAGE_FIELD_NAME, defaultLanguage);
}
use of org.openforis.collect.designer.model.LabelledItem in project collect by openforis.
the class NewSurveyParametersPopUpVM method ok.
@Command
public void ok() throws IdmlParseException, SurveyValidationException, SurveyStoreException {
String name = (String) form.get(SURVEY_NAME_FIELD);
String langCode = ((LabelledItem) form.get(LANGUAGE_FIELD_NAME)).getCode();
String templateCode = ((LabelledItem) form.get(TEMPLATE_FIELD_NAME)).getCode();
TemplateType templateType = TemplateType.valueOf(templateCode);
String userGroupName = ((LabelledItem) form.get(USER_GROUP_FIELD_NAME)).getCode();
CollectSurvey survey;
switch(templateType) {
case BLANK:
survey = createEmptySurvey(name, langCode);
break;
default:
survey = createNewSurveyFromTemplate(name, langCode, templateType);
}
UserGroup userGroup = userGroupManager.findByName(userGroupName);
survey.setUserGroupId(userGroup.getId());
surveyManager.save(survey);
SurveyEditVM.redirectToSurveyEditPage(survey.getId());
}
use of org.openforis.collect.designer.model.LabelledItem in project collect by openforis.
the class SurveyLanguageVM method getSurveyAssignedLanguages.
protected List<LabelledItem> getSurveyAssignedLanguages() {
List<LabelledItem> result = new ArrayList<LabelledItem>();
List<String> assignedLanguageCodes = getSurveyAssignedLanguageCodes();
for (String code : assignedLanguageCodes) {
for (LabelledItem item : languages) {
if (item.getCode().equals(code)) {
result.add(item);
}
}
}
return result;
}
Aggregations