Search in sources :

Example 56 with CodeList

use of org.openforis.idm.metamodel.CodeList in project collect by openforis.

the class CodeAttributeMapper method addNode.

@Override
CodeAttribute addNode(NodeDefinition defn, Record r, Entity parent) {
    String name = defn.getName();
    String qualifier = r.getValueAsString(DATA.TEXT2);
    CodeAttributeDefinition codeAttrDefn = (CodeAttributeDefinition) defn;
    CodeList list = codeAttrDefn.getList();
    String code = r.getValueAsString(DATA.TEXT1);
    Code value = new Code(code, qualifier);
    return parent.addValue(name, value);
}
Also used : CodeList(org.openforis.idm.metamodel.CodeList) CodeAttributeDefinition(org.openforis.idm.metamodel.CodeAttributeDefinition) Code(org.openforis.idm.model.Code)

Example 57 with CodeList

use of org.openforis.idm.metamodel.CodeList in project collect by openforis.

the class CodeAttributeVM method codeListsPopUpClosed.

@GlobalCommand
public void codeListsPopUpClosed(@ContextParam(ContextType.BINDER) Binder binder, @BindingParam(CodeListsVM.EDITING_ATTRIBUTE_PARAM) Boolean editingAttribute, @BindingParam(CodeListsVM.SELECTED_CODE_LIST_PARAM) CodeList selectedCodeList) {
    if (editingAttribute && selectedCodeList != null) {
        CodeAttributeDefinitionFormObject fo = (CodeAttributeDefinitionFormObject) getFormObject();
        CodeList oldList = fo.getList();
        if (oldList != null && !oldList.equals(selectedCodeList)) {
            if (oldList != survey.getSamplingDesignCodeList()) {
                confirmCodeListChange(binder, selectedCodeList);
            }
        } else {
            onListChanged(binder, selectedCodeList);
            validateForm(binder);
        }
    }
}
Also used : CodeList(org.openforis.idm.metamodel.CodeList) CodeAttributeDefinitionFormObject(org.openforis.collect.designer.form.CodeAttributeDefinitionFormObject) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Example 58 with CodeList

use of org.openforis.idm.metamodel.CodeList in project collect by openforis.

the class CodeAttributeVM method onListChanged.

@Command
public void onListChanged(@ContextParam(ContextType.BINDER) Binder binder, @BindingParam("list") CodeList list) {
    CodeAttributeDefinitionFormObject fo = (CodeAttributeDefinitionFormObject) getFormObject();
    CodeList oldList = fo.getList();
    boolean listChanged = oldList != null && !oldList.equals(list);
    if (oldList == null) {
        performListChange(binder, list);
    } else if (listChanged) {
        if (editedItem.hasDependentCodeAttributeDefinitions()) {
            confirmParentCodeListChange(binder, list);
        } else {
            performListChange(binder, list);
        }
    }
}
Also used : CodeList(org.openforis.idm.metamodel.CodeList) CodeAttributeDefinitionFormObject(org.openforis.collect.designer.form.CodeAttributeDefinitionFormObject) Command(org.zkoss.bind.annotation.Command) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Example 59 with CodeList

use of org.openforis.idm.metamodel.CodeList in project collect by openforis.

the class CodeAttributeVM method confirmParentCodeListChange.

private void confirmParentCodeListChange(final Binder binder, final CodeList list) {
    ConfirmParams confirmParams = new ConfirmParams(new MessageUtil.CompleteConfirmHandler() {

        @Override
        public void onOk() {
            performListChange(binder, list);
        }

        @Override
        public void onCancel() {
            CodeList oldList = editedItem.getList();
            setFormFieldValue(binder, "list", oldList);
            setTempFormObjectFieldValue("list", oldList);
        }
    }, "survey.schema.attribute.code.confirm_change_list_on_referenced_node.message");
    confirmParams.setOkLabelKey("survey.schema.attribute.code.confirm_change_list_on_referenced_node.ok");
    confirmParams.setTitleKey("survey.schema.attribute.code.confirm_change_list_on_referenced_node.title");
    List<String> dependentAttributePaths = new ArrayList<String>();
    for (CodeAttributeDefinition codeAttributeDefinition : editedItem.getDependentCodeAttributeDefinitions()) {
        dependentAttributePaths.add(codeAttributeDefinition.getPath());
    }
    confirmParams.setMessageArgs(new String[] { StringUtils.join(dependentAttributePaths, ", ") });
    MessageUtil.showConfirm(confirmParams);
}
Also used : ConfirmParams(org.openforis.collect.designer.util.MessageUtil.ConfirmParams) CodeList(org.openforis.idm.metamodel.CodeList) CodeAttributeDefinition(org.openforis.idm.metamodel.CodeAttributeDefinition) MessageUtil(org.openforis.collect.designer.util.MessageUtil) ArrayList(java.util.ArrayList)

Example 60 with CodeList

use of org.openforis.idm.metamodel.CodeList in project collect by openforis.

the class CodeAttributeVM method performListChange.

private void performListChange(Binder binder, CodeList list) {
    CodeAttributeDefinitionFormObject fo = (CodeAttributeDefinitionFormObject) getFormObject();
    CodeList oldList = fo.getList();
    fo.setParentCodeAttributeDefinition(null);
    fo.setList(list);
    setFormFieldValue(binder, "list", list);
    setFormFieldValue(binder, "list.hierarchical", list != null && list.isHierarchical());
    setFormFieldValue(binder, "parentCodeAttributeDefinitionPath", null);
    setFormFieldValue(binder, "hierarchicalLevel", null);
    dispatchApplyChangesCommand(binder);
    notifyChange("dependentCodePaths");
    dispatchCodeListAssignedCommand(list, oldList);
}
Also used : CodeList(org.openforis.idm.metamodel.CodeList) CodeAttributeDefinitionFormObject(org.openforis.collect.designer.form.CodeAttributeDefinitionFormObject)

Aggregations

CodeList (org.openforis.idm.metamodel.CodeList)88 CodeListItem (org.openforis.idm.metamodel.CodeListItem)24 CodeAttributeDefinition (org.openforis.idm.metamodel.CodeAttributeDefinition)20 ArrayList (java.util.ArrayList)16 CollectSurvey (org.openforis.collect.model.CollectSurvey)15 PersistedCodeListItem (org.openforis.idm.metamodel.PersistedCodeListItem)14 Test (org.junit.Test)10 CollectIntegrationTest (org.openforis.collect.CollectIntegrationTest)10 HashMap (java.util.HashMap)7 NameValueEntry (org.openforis.collect.model.NameValueEntry)7 CodeListService (org.openforis.idm.metamodel.CodeListService)7 ExternalCodeListItem (org.openforis.idm.metamodel.ExternalCodeListItem)6 List (java.util.List)5 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)5 ModelVersion (org.openforis.idm.metamodel.ModelVersion)5 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)5 Code (org.openforis.idm.model.Code)5 Record (org.openforis.idm.model.Record)5 CodeAttributeDefinitionFormObject (org.openforis.collect.designer.form.CodeAttributeDefinitionFormObject)4 CodeListImportProcess (org.openforis.collect.manager.codelistimport.CodeListImportProcess)4