Search in sources :

Example 1 with TemplateFieldForm

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++;
        }
    }
}
Also used : TemplateFieldForm(com.emc.metalnx.modelattribute.template.field.TemplateFieldForm)

Example 2 with TemplateFieldForm

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";
}
Also used : TemplateFieldForm(com.emc.metalnx.modelattribute.template.field.TemplateFieldForm) MetadataTemplateForm(com.emc.metalnx.modelattribute.metadatatemplate.MetadataTemplateForm) DataGridTemplate(com.emc.metalnx.core.domain.entity.DataGridTemplate) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with TemplateFieldForm

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";
}
Also used : TemplateFieldForm(com.emc.metalnx.modelattribute.template.field.TemplateFieldForm) DataGridTemplate(com.emc.metalnx.core.domain.entity.DataGridTemplate) DataGridTemplateField(com.emc.metalnx.core.domain.entity.DataGridTemplateField) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with TemplateFieldForm

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;
}
Also used : TemplateFieldForm(com.emc.metalnx.modelattribute.template.field.TemplateFieldForm)

Example 5 with TemplateFieldForm

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;
}
Also used : TemplateFieldForm(com.emc.metalnx.modelattribute.template.field.TemplateFieldForm) ArrayList(java.util.ArrayList) DataGridTemplateField(com.emc.metalnx.core.domain.entity.DataGridTemplateField)

Aggregations

TemplateFieldForm (com.emc.metalnx.modelattribute.template.field.TemplateFieldForm)13 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 DataGridTemplateField (com.emc.metalnx.core.domain.entity.DataGridTemplateField)7 DataGridTemplate (com.emc.metalnx.core.domain.entity.DataGridTemplate)4 DataGridTemplateAttrException (com.emc.metalnx.core.domain.exceptions.DataGridTemplateAttrException)3 DataGridTemplateUnitException (com.emc.metalnx.core.domain.exceptions.DataGridTemplateUnitException)3 DataGridTemplateValueException (com.emc.metalnx.core.domain.exceptions.DataGridTemplateValueException)3 MetadataTemplateForm (com.emc.metalnx.modelattribute.metadatatemplate.MetadataTemplateForm)3 ArrayList (java.util.ArrayList)3 DataGridUser (com.emc.metalnx.core.domain.entity.DataGridUser)2 DataGridConnectionRefusedException (com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException)2 DataGridException (com.emc.metalnx.core.domain.exceptions.DataGridException)2 DataGridTooLongTemplateNameException (com.emc.metalnx.core.domain.exceptions.DataGridTooLongTemplateNameException)2 IOException (java.io.IOException)2 JAXBException (javax.xml.bind.JAXBException)2 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)1