use of org.openforis.idm.metamodel.CodeList in project collect by openforis.
the class CodeAttributeVM method confirmCodeListChange.
private void confirmCodeListChange(final Binder binder, final CodeList list) {
CodeList oldList = ((CodeAttributeDefinitionFormObject) getFormObject()).getList();
ConfirmParams confirmParams = new ConfirmParams(new MessageUtil.ConfirmHandler() {
@Override
public void onOk() {
performListChange(binder, list);
}
}, "survey.schema.attribute.code.confirm_change_list.message");
confirmParams.setOkLabelKey("global.change");
confirmParams.setCancelLabelKey("global.leave_original_value");
confirmParams.setMessageArgs(new String[] { oldList.getName(), list.getName() });
MessageUtil.showConfirm(confirmParams);
}
use of org.openforis.idm.metamodel.CodeList in project collect by openforis.
the class CodeListsVM method getReferences.
protected List<NodeDefinition> getReferences(CodeList item) {
List<NodeDefinition> references = new ArrayList<NodeDefinition>();
Schema schema = survey.getSchema();
List<EntityDefinition> rootEntities = schema.getRootEntityDefinitions();
Stack<NodeDefinition> stack = new Stack<NodeDefinition>();
stack.addAll(rootEntities);
while (!stack.isEmpty()) {
NodeDefinition defn = stack.pop();
if (defn instanceof EntityDefinition) {
stack.addAll(((EntityDefinition) defn).getChildDefinitions());
} else if (defn instanceof CodeAttributeDefinition) {
CodeList list = ((CodeAttributeDefinition) defn).getList();
if (list.equals(item)) {
references.add(defn);
}
}
;
}
return references;
}
use of org.openforis.idm.metamodel.CodeList in project collect by openforis.
the class CodeListsVM method closeCodeListItemPopUp.
@GlobalCommand
public void closeCodeListItemPopUp(@BindingParam("undoChanges") boolean undoChanges, @BindingParam("imageModified") boolean imageModified, @BindingParam("imageFileWrapper") FileWrapper imageFileWrapper) {
if (codeListItemPopUp == null) {
// handling code list from node editor form?
return;
}
closePopUp(codeListItemPopUp);
codeListItemPopUp = null;
if (undoChanges) {
dispatchCurrentFormValidatedCommand(true);
} else {
if (newChildItem) {
addChildItemToCodeList();
} else {
dispatchSurveySaveCommand();
if (editedChildItem instanceof PersistedCodeListItem) {
codeListManager.save((PersistedCodeListItem) editedChildItem);
}
BindUtils.postNotifyChange(null, null, editedChildItem, "*");
}
if (imageModified) {
PersistedCodeListItem persistedItem;
if (editedChildItem instanceof PersistedCodeListItem) {
persistedItem = (PersistedCodeListItem) editedChildItem;
} else {
CodeList codeList = editedChildItem.getCodeList();
codeListManager.persistCodeListItems(codeList);
reloadSelectedItems();
initItemsPerLevel();
persistedItem = codeListManager.loadItem(codeList, editedChildItem.getId());
}
if (imageFileWrapper == null) {
codeListManager.deleteImageContent(persistedItem);
} else {
codeListManager.saveImageContent(persistedItem, imageFileWrapper);
}
}
}
}
use of org.openforis.idm.metamodel.CodeList in project collect by openforis.
the class CodeListsVM method createItemInstance.
@Override
protected CodeList createItemInstance() {
CodeList instance = survey.createCodeList();
instance.setCodeScope(CodeScope.LOCAL);
return instance;
}
use of org.openforis.idm.metamodel.CodeList in project collect by openforis.
the class CodeListController method exportCodeList.
protected String exportCodeList(HttpServletResponse response, int surveyId, int codeListId) throws IOException {
CollectSurvey survey = surveyManager.getOrLoadSurveyById(surveyId);
CodeList list = survey.getCodeListById(codeListId);
String fileName = list.getName() + CSV_EXTENSION;
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
response.setContentType(CSV_CONTENT_TYPE);
ServletOutputStream out = response.getOutputStream();
CodeListExportProcess process = new CodeListExportProcess(codeListManager);
process.exportToCSV(out, survey, codeListId);
return "ok";
}
Aggregations