use of org.openforis.collect.designer.model.LabelledItem in project collect by openforis.
the class BaseVM method initUserGroupsModel.
protected void initUserGroupsModel() {
List<LabelledItem> items = new ArrayList<LabelledItem>();
User loggedUser = getLoggedUser();
List<UserGroup> userGroups = userGroupManager.findAllRelatedUserGroups(loggedUser);
for (UserGroup userGroup : userGroups) {
String label = userGroup.getName().equals(UserGroupManager.DEFAULT_PUBLIC_USER_GROUP_NAME) ? Labels.getLabel(PUBLIC_USER_GROUP_LABEL_KEY) : userGroup.getName().equals(userGroupManager.getDefaultPrivateUserGroupName(loggedUser)) ? Labels.getLabel(PRIVATE_USER_GROUP_LABEL_KEY) : userGroup.getLabel();
items.add(new LabelledItem(userGroup.getName(), label));
}
userGroupsModel = new BindingListModelListModel<LabelledItem>(new ListModelList<LabelledItem>(items));
userGroupsModel.setMultiple(false);
}
use of org.openforis.collect.designer.model.LabelledItem in project collect by openforis.
the class NewSurveyParametersPopUpVM method initTemplatesModel.
private void initTemplatesModel() {
List<LabelledItem> templates = new ArrayList<LabelledItem>();
for (TemplateType templateType : TemplateType.values()) {
String name = templateType.name();
templates.add(new LabelledItem(name, Labels.getLabel("survey.template.type." + name.toLowerCase(Locale.ENGLISH))));
}
templateModel = new BindingListModelListModel<LabelledItem>(new ListModelList<LabelledItem>(templates));
templateModel.setMultiple(false);
LabelledItem defaultTemplate = LabelledItem.getByCode(templates, TemplateType.BLANK.name());
form.put(TEMPLATE_FIELD_NAME, defaultTemplate);
}
use of org.openforis.collect.designer.model.LabelledItem in project collect by openforis.
the class SurveyImportVM method startSurveyImport.
protected void startSurveyImport() {
String surveyName = getFormSurveyName();
LabelledItem userGroupItem = (LabelledItem) form.get(USER_GROUP_FIELD_NAME);
UserGroup userGroup = userGroupManager.findByName(userGroupItem.getCode());
String uploadedFileNameExtension = FilenameUtils.getExtension(this.uploadedFileName);
AbstractSurveyRestoreJob job;
if (XML_FILE_EXTENSION.equalsIgnoreCase(uploadedFileNameExtension)) {
job = jobManager.createJob(XMLSurveyRestoreJob.class);
} else if (CEP_FILE_EXTENSION.equalsIgnoreCase(uploadedFileNameExtension)) {
job = jobManager.createJob(CESurveyRestoreJob.class);
} else {
job = jobManager.createJob(SurveyRestoreJob.class);
}
job.setFile(uploadedFile);
job.setSurveyName(surveyName);
job.setSurveyUri(uploadedSurveyUri);
job.setUserGroup(userGroup);
job.setRestoreIntoPublishedSurvey(false);
job.setValidateSurvey(false);
job.setActiveUser(getLoggedUser());
jobManager.start(job);
this.restoreJob = job;
openSurveyRestoreStatusPopUp();
}
use of org.openforis.collect.designer.model.LabelledItem in project collect by openforis.
the class SurveyLanguageVM method getUnassignedLanguages.
@DependsOn("assignedLanguages")
public List<LabelledItem> getUnassignedLanguages() {
@SuppressWarnings("unchecked") List<LabelledItem> result = new ArrayList<LabelledItem>(org.apache.commons.collections.CollectionUtils.disjunction(languages, assignedLanguages));
Collections.sort(result, new LabelledItem.LabelComparator());
return result;
}
use of org.openforis.collect.designer.model.LabelledItem in project collect by openforis.
the class SurveyLanguageVM method init.
@Init
public void init() {
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());
assignedLanguages = getSurveyAssignedLanguages();
}
Aggregations