use of com.emc.metalnx.core.domain.exceptions.DataGridTemplateAttrException in project metalnx-web by irods-contrib.
the class TemplateController method addFieldToCurrentTemplate.
@RequestMapping(value = "/addFieldToCurrentTemplate")
public String addFieldToCurrentTemplate(final Model model, @ModelAttribute final TemplateFieldForm templateFieldForm) {
updateAddTemplateFieldsList();
boolean isAddFieldsEmpty = false;
try {
List<DataGridTemplateField> existingTemplateFields = templateService.listTemplateFields(templateFieldForm.getTemplateName());
DataGridTemplateField newDataGridField = mapTempFieldFormToDataGridTemp(templateFieldForm);
List<TemplateFieldForm> templateFields = new ArrayList<TemplateFieldForm>();
TemplateFieldForm newField = this.mapDataGridTempToFieldForm(newDataGridField, addTemplateFields.size());
templateFields.add(newField);
if (addTemplateFields.isEmpty()) {
isAddFieldsEmpty = true;
}
// prevent an AVU from being added twice to a template
if (!addTemplateFields.contains(newField) || addTemplateFields.contains(newField) && newField.getValue().equals("")) {
addTemplateFields.add(newField.getFormListPosition(), newField);
}
model.addAttribute("templateFields", templateFields);
model.addAttribute("resultSize", templateFields.size());
model.addAttribute("foundTemplateFields", templateFields.size() > 0);
if (isAddFieldsEmpty && existingTemplateFields.isEmpty()) {
return "template/templateFieldList";
}
} catch (DataGridTemplateAttrException e) {
logger.error(e.getMessage());
} catch (DataGridTemplateValueException e) {
logger.error(e.getMessage());
} catch (DataGridTemplateUnitException e) {
logger.error(e.getMessage());
}
return "template/templateFieldList :: avuRow";
}
Aggregations