use of com.emc.metalnx.modelattribute.template.field.TemplateFieldForm in project metalnx-web by irods-contrib.
the class TemplateController method updateAddTemplateFieldsList.
/**
* Updates the form list position of each element of the addTemplateFields array
* list.
*/
private void updateAddTemplateFieldsList() {
if (addTemplateFields != null) {
// updating form list position once an element was removed from the
// array
int i = 0;
for (TemplateFieldForm templateFieldForm : addTemplateFields) {
templateFieldForm.setFormListPosition(i);
i++;
}
}
}
use of com.emc.metalnx.modelattribute.template.field.TemplateFieldForm in project metalnx-web by irods-contrib.
the class TemplateController method showModifyTemplate.
@RequestMapping(value = "modify/")
public String showModifyTemplate(final Model model, final HttpServletRequest request) {
// DataGridTemplate template =
// templateService.findById(selectedTemplates.iterator().next());
DataGridTemplate template = templateService.findById(Long.parseLong(request.getParameter("templateId")));
if (template == null) {
return "redirect:/templates/";
}
MetadataTemplateForm templateForm = new MetadataTemplateForm();
templateForm.setId(template.getId());
templateForm.setTemplateName(template.getTemplateName());
templateForm.setDescription(template.getDescription());
templateForm.setUsageInformation(template.getUsageInformation());
templateForm.setOwner(template.getOwner());
templateForm.setAccessType(template.getAccessType());
templateForm.setVersion(template.getVersion());
TemplateFieldForm templateFieldForm = new TemplateFieldForm();
model.addAttribute("uiMode", request.getSession().getAttribute("uiMode"));
model.addAttribute("accessTypes", MetadataTemplateAccessType.values());
model.addAttribute("metadataTemplateForm", templateForm);
model.addAttribute("templateFieldForm", templateFieldForm);
model.addAttribute("requestMapping", "/templates/modify/action/");
return "template/templateForm";
}
use of com.emc.metalnx.modelattribute.template.field.TemplateFieldForm in project metalnx-web by irods-contrib.
the class TemplateController method listTemplateFields.
@RequestMapping(value = "/listTemplateFields", method = RequestMethod.POST)
public String listTemplateFields(final Model model, @RequestParam("template") final String template) {
updateAddTemplateFieldsList();
List<DataGridTemplateField> dataGridTemplateFields = templateService.listTemplateFields(template);
List<TemplateFieldForm> templateFields = this.mapDataGridTempToFieldForm(dataGridTemplateFields);
DataGridTemplate metadataTemplate = templateService.findByName(template);
if (addTemplateFields != null) {
templateFields.addAll(addTemplateFields);
}
if (removeTemplateFields != null) {
templateFields.removeAll(removeTemplateFields);
}
model.addAttribute("metadataTemplate", metadataTemplate);
model.addAttribute("templateFields", templateFields);
model.addAttribute("resultSize", templateFields.size());
model.addAttribute("foundTemplateFields", templateFields.size() > 0);
return "template/templateFieldList";
}
use of com.emc.metalnx.modelattribute.template.field.TemplateFieldForm in project metalnx-web by irods-contrib.
the class TemplateController method mapDataGridTempToFieldForm.
/**
* Maps a single instance of DataGridTemplateField into a TemplateFieldForm
* object
*
* @param dataGridTempField
* DataGridTemplateField object
* @param position
* DataGridTemplateField object position into the memory array list
* of fields to be added to a template
* @return TemplateFieldForm object
*/
private TemplateFieldForm mapDataGridTempToFieldForm(final DataGridTemplateField dataGridTempField, final int position) {
if (dataGridTempField == null) {
return null;
}
TemplateFieldForm tempField = new TemplateFieldForm();
tempField.setAttribute(dataGridTempField.getAttribute());
tempField.setValue(dataGridTempField.getValue());
tempField.setUnit(dataGridTempField.getUnit());
tempField.setStartRange(dataGridTempField.getStartRange());
tempField.setEndRange(dataGridTempField.getEndRange());
tempField.setOrder(dataGridTempField.getOrder());
tempField.setFormListPosition(position);
tempField.setId(dataGridTempField.getId());
if (dataGridTempField.getTemplate() != null) {
tempField.setTemplateName(dataGridTempField.getTemplate().getTemplateName());
}
return tempField;
}
use of com.emc.metalnx.modelattribute.template.field.TemplateFieldForm in project metalnx-web by irods-contrib.
the class TemplateController method mapDataGridTempToFieldForm.
/**
* Maps a list of DataGridTemplateField objects into a list of TemplateFieldForm
* objects
*
* @param tempFields
* list of data grid template objects
* @return list of TemplateFieldForm objects
*/
private List<TemplateFieldForm> mapDataGridTempToFieldForm(final List<DataGridTemplateField> tempFields) {
List<TemplateFieldForm> tempFieldFormList = new ArrayList<TemplateFieldForm>();
if (tempFields == null || tempFields.isEmpty()) {
return tempFieldFormList;
}
TemplateFieldForm tempField = null;
int position = 0;
for (DataGridTemplateField dataGridTemplateField : tempFields) {
tempField = this.mapDataGridTempToFieldForm(dataGridTemplateField, position);
tempFieldFormList.add(tempField);
}
return tempFieldFormList;
}
Aggregations