Search in sources :

Example 11 with TemplateFieldForm

use of com.emc.metalnx.modelattribute.template.field.TemplateFieldForm in project metalnx-web by irods-contrib.

the class TemplateController method listTemplateFieldsForCollections.

@RequestMapping(value = "/listTemplateFieldsForCollections", method = RequestMethod.POST)
public String listTemplateFieldsForCollections(final Model model, @RequestParam("templateIDsList") final long[] templateIDsList) {
    MetadataTemplateForm templateForm = new MetadataTemplateForm();
    List<TemplateFieldForm> templateFields = new ArrayList<TemplateFieldForm>();
    List<DataGridTemplateField> dataGridTemplateFields = new ArrayList<DataGridTemplateField>();
    if (templateIDsList.length > 0) {
        for (long id : templateIDsList) {
            dataGridTemplateFields.addAll(templateService.listTemplateFields(id));
        }
        templateFields = this.mapDataGridTempToFieldForm(dataGridTemplateFields);
    }
    model.addAttribute("templateForm", templateForm);
    model.addAttribute("requestMapping", "/browse/applyTemplatesToCollections/");
    model.addAttribute("templateFields", templateFields);
    model.addAttribute("resultSize", templateFields.size());
    model.addAttribute("foundTemplateFields", templateFields.size() > 0);
    return "collections/templateFieldListForCollections";
}
Also used : TemplateFieldForm(com.emc.metalnx.modelattribute.template.field.TemplateFieldForm) MetadataTemplateForm(com.emc.metalnx.modelattribute.metadatatemplate.MetadataTemplateForm) ArrayList(java.util.ArrayList) DataGridTemplateField(com.emc.metalnx.core.domain.entity.DataGridTemplateField) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with TemplateFieldForm

use of com.emc.metalnx.modelattribute.template.field.TemplateFieldForm in project metalnx-web by irods-contrib.

the class TemplateController method index.

@RequestMapping(value = "/")
public String index(final Model model, final HttpServletRequest request) throws DataGridConnectionRefusedException, DataGridException {
    addTemplateFields = new ArrayList<TemplateFieldForm>();
    removeTemplateFields = new ArrayList<TemplateFieldForm>();
    DataGridUser loggedUser = loggedUserUtils.getLoggedDataGridUser();
    String uiMode = (String) request.getSession().getAttribute("uiMode");
    if (uiMode == null || uiMode.isEmpty()) {
        if (loggedUser.isAdmin()) {
            uiMode = UI_ADMIN_MODE;
        } else {
            uiMode = UI_USER_MODE;
            model.addAttribute("homePath", collectionService.getHomeDirectyForCurrentUser());
            model.addAttribute("publicPath", collectionService.getHomeDirectyForPublic());
        }
    }
    selectedTemplates.clear();
    model.addAttribute("uiMode", uiMode);
    model.addAttribute("topnavHeader", headerService.getheader("template"));
    return "template/templateManagement";
}
Also used : TemplateFieldForm(com.emc.metalnx.modelattribute.template.field.TemplateFieldForm) DataGridUser(com.emc.metalnx.core.domain.entity.DataGridUser) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 13 with TemplateFieldForm

use of com.emc.metalnx.modelattribute.template.field.TemplateFieldForm in project metalnx-web by irods-contrib.

the class TemplateController method removeFieldFromDB.

@RequestMapping(value = "/removeFieldFromDB")
@ResponseStatus(value = HttpStatus.OK)
public void removeFieldFromDB(@RequestParam("templateFieldsIDList") final long[] templateFieldsIDList) {
    for (long templateFieldID : templateFieldsIDList) {
        DataGridTemplateField dataGridField = templateFieldService.findById(templateFieldID);
        TemplateFieldForm field = this.mapDataGridTempToFieldForm(dataGridField);
        if (addTemplateFields.contains(field)) {
            addTemplateFields.remove(field);
        }
        // adding the field to the list that is needed to be removed from a template
        if (!removeTemplateFields.contains(field)) {
            removeTemplateFields.add(field);
        }
    }
}
Also used : TemplateFieldForm(com.emc.metalnx.modelattribute.template.field.TemplateFieldForm) DataGridTemplateField(com.emc.metalnx.core.domain.entity.DataGridTemplateField) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

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