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);
}
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);
}
}
}
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);
}
}
}
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);
}
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);
}
Aggregations