use of org.openforis.idm.metamodel.CodeListItem in project collect by openforis.
the class CodeAttribute method getCodeListItem.
/**
* @deprecated Access code list items using manager class.
*
* @return
*/
@Deprecated
public CodeListItem getCodeListItem() {
Code code = getValue();
if (code != null) {
String codeValue = code.getCode();
if (StringUtils.isNotBlank(codeValue)) {
ModelVersion currentVersion = getRecord().getVersion();
CodeAttributeDefinition definition = getDefinition();
String parentExpression = definition.getParentExpression();
if (StringUtils.isBlank(parentExpression)) {
return findCodeListItem(definition.getList().getItems(), codeValue, currentVersion);
} else {
CodeAttribute codeParent = getCodeParent();
if (codeParent != null) {
CodeListItem codeListItemParent = codeParent.getCodeListItem();
if (codeListItemParent != null) {
return findCodeListItem(codeListItemParent.getChildItems(), codeValue, currentVersion);
}
}
}
}
}
return null;
}
use of org.openforis.idm.metamodel.CodeListItem in project collect by openforis.
the class CodeListsVM method closeCodeListImportPopUp.
@GlobalCommand
public void closeCodeListImportPopUp() {
closePopUp(codeListImportPopUp);
codeListImportPopUp = null;
if (editedItem != null) {
boolean hasMultipleLevels = editedItem.getHierarchy().size() > 1;
Type type = hasMultipleLevels ? Type.HIERARCHICAL : Type.FLAT;
CodeListFormObject fo = (CodeListFormObject) formObject;
fo.setType(type.name());
selectedItemsPerLevel = new ArrayList<CodeListItem>();
initItemsPerLevel();
notifyChange("formObject", "listLevels", "selectedItemsPerLevel");
}
}
use of org.openforis.idm.metamodel.CodeListItem in project collect by openforis.
the class CodeListsVM method moveChildItem.
@Command
public void moveChildItem(@ContextParam(ContextType.TRIGGER_EVENT) DropEvent event) {
Listitem dragged = (Listitem) event.getDragged();
Listitem dropped = (Listitem) event.getTarget();
CodeListItem draggedItem = dragged.getValue();
CodeListItem droppedItem = dropped.getValue();
int indexTo = getItemIndex(droppedItem);
moveChildItem(draggedItem, indexTo);
}
use of org.openforis.idm.metamodel.CodeListItem in project collect by openforis.
the class CodeListItemFormValidator method validateCodeUniqueness.
protected boolean validateCodeUniqueness(ValidationContext ctx) {
SurveyObjectBaseVM<CodeListItem> viewModel = getVM(ctx);
CodeListItem editedItem = viewModel.getEditedItem();
String code = (String) getValue(ctx, CODE_FIELD);
CodeListItem existingItem = getExistingCodeListItem(ctx, code);
if (existingItem != null && existingItem.getId() != editedItem.getId()) {
String message = Labels.getLabel(CODE_ALREADY_DEFINED_MESSAGE_KEY);
addInvalidMessage(ctx, CODE_FIELD, message);
return false;
} else {
return true;
}
}
use of org.openforis.idm.metamodel.CodeListItem in project collect by openforis.
the class CodeListController method toViews.
private List<CodeListItemView> toViews(List<CodeListItem> items) {
List<CodeListItemView> views = new ArrayList<CodeListItemView>(items.size());
for (CodeListItem item : items) {
CodeListItemView view = new CodeListItemView();
view.setCode(item.getCode());
view.setLabel(item.getLabel());
views.add(view);
}
return views;
}
Aggregations