Search in sources :

Example 1 with LabelledItem

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);
}
Also used : User(org.openforis.collect.model.User) LabelledItem(org.openforis.collect.designer.model.LabelledItem) ListModelList(org.zkoss.zul.ListModelList) ArrayList(java.util.ArrayList) UserGroup(org.openforis.collect.model.UserGroup)

Example 2 with LabelledItem

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);
}
Also used : LabelledItem(org.openforis.collect.designer.model.LabelledItem) ListModelList(org.zkoss.zul.ListModelList) ArrayList(java.util.ArrayList) TemplateType(org.openforis.collect.web.controller.SurveyController.SurveyCreationParameters.TemplateType)

Example 3 with LabelledItem

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();
}
Also used : LabelledItem(org.openforis.collect.designer.model.LabelledItem) AbstractSurveyRestoreJob(org.openforis.collect.io.AbstractSurveyRestoreJob) XMLSurveyRestoreJob(org.openforis.collect.io.XMLSurveyRestoreJob) UserGroup(org.openforis.collect.model.UserGroup)

Example 4 with LabelledItem

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;
}
Also used : LabelledItem(org.openforis.collect.designer.model.LabelledItem) ArrayList(java.util.ArrayList) LabelComparator(org.openforis.collect.designer.model.LabelledItem.LabelComparator) DependsOn(org.zkoss.bind.annotation.DependsOn)

Example 5 with LabelledItem

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();
}
Also used : LabelledItem(org.openforis.collect.designer.model.LabelledItem) LabelComparator(org.openforis.collect.designer.model.LabelledItem.LabelComparator) Init(org.zkoss.bind.annotation.Init)

Aggregations

LabelledItem (org.openforis.collect.designer.model.LabelledItem)8 ArrayList (java.util.ArrayList)5 LabelComparator (org.openforis.collect.designer.model.LabelledItem.LabelComparator)3 UserGroup (org.openforis.collect.model.UserGroup)3 ListModelList (org.zkoss.zul.ListModelList)3 TemplateType (org.openforis.collect.web.controller.SurveyController.SurveyCreationParameters.TemplateType)2 AbstractSurveyRestoreJob (org.openforis.collect.io.AbstractSurveyRestoreJob)1 XMLSurveyRestoreJob (org.openforis.collect.io.XMLSurveyRestoreJob)1 CollectSurvey (org.openforis.collect.model.CollectSurvey)1 User (org.openforis.collect.model.User)1 Command (org.zkoss.bind.annotation.Command)1 DependsOn (org.zkoss.bind.annotation.DependsOn)1 Init (org.zkoss.bind.annotation.Init)1