Search in sources :

Example 6 with UserProfile

use of com.emc.metalnx.core.domain.entity.UserProfile in project metalnx-web by irods-contrib.

the class UserProfileController method createUserProfile.

@RequestMapping(value = "/create/action/")
public String createUserProfile(@ModelAttribute UserProfileForm userProfileForm, Model model, HttpServletRequest request, RedirectAttributes redirectAttributes) {
    UserProfile newUserProfile = new UserProfile();
    newUserProfile.setProfileName(userProfileForm.getProfileName());
    newUserProfile.setDescription(userProfileForm.getDescription());
    // Getting group list from UI
    // String[] groupList = request.getParameterValues("groupIdsList");
    String[] groupList = groupIdsList.toArray(new String[groupIdsList.size()]);
    List<DataGridGroup> groups = new ArrayList<DataGridGroup>();
    if (groupList != null && groupList.length != 0) {
        groups = groupService.findByIdList(groupList);
    }
    Set<DataGridGroup> groupSet = new HashSet<DataGridGroup>(groups);
    Long userProfileId = userProfileService.createUserProfile(newUserProfile);
    newUserProfile = userProfileService.findById(userProfileId);
    newUserProfile.setGroups(groupSet);
    userProfileService.modifyUserProfile(newUserProfile);
    if (newUserProfile != null) {
        redirectAttributes.addFlashAttribute("userProfileAddedSuccessfully", newUserProfile.getProfileName());
    }
    return "redirect:/users/profile/";
}
Also used : UserProfile(com.emc.metalnx.core.domain.entity.UserProfile) DataGridGroup(com.emc.metalnx.core.domain.entity.DataGridGroup)

Example 7 with UserProfile

use of com.emc.metalnx.core.domain.entity.UserProfile in project metalnx-web by irods-contrib.

the class UserProfileController method showModifyForm.

@RequestMapping(value = "/modify/{profileId}/")
public String showModifyForm(Model model, @PathVariable String profileId) {
    UserProfile userProfile = userProfileService.findById(Long.valueOf(profileId));
    List<DataGridGroup> groups = groupService.findAll();
    UserProfileForm userProfileForm = new UserProfileForm();
    if (userProfile != null) {
        userProfileForm.setProfileId(String.valueOf(userProfile.getProfileId()));
        userProfileForm.setProfileName(userProfile.getProfileName());
        userProfileForm.setDescription(userProfile.getDescription());
        int groupsQuantity = userProfile.getGroups().size(), i = 0;
        String[] groupsOnProfileList = new String[groupsQuantity];
        for (DataGridGroup group : userProfile.getGroups()) {
            groupsOnProfileList[i++] = String.valueOf(group.getId());
        }
        model.addAttribute("groupsOnProfileList", groupsOnProfileList);
        groupIdsList = new ArrayList<String>(Arrays.asList(groupsOnProfileList));
    }
    model.addAttribute("userProfileForm", userProfileForm);
    model.addAttribute("groups", groups);
    model.addAttribute("resultSize", groups.size());
    model.addAttribute("foundGroups", groups.size() > 0);
    model.addAttribute("requestMapping", "/users/profile/modify/action/");
    return "userProfile/userProfileForm";
}
Also used : UserProfileForm(com.emc.metalnx.modelattribute.user.profile.UserProfileForm) UserProfile(com.emc.metalnx.core.domain.entity.UserProfile) DataGridGroup(com.emc.metalnx.core.domain.entity.DataGridGroup)

Example 8 with UserProfile

use of com.emc.metalnx.core.domain.entity.UserProfile in project metalnx-web by irods-contrib.

the class UserProfileController method modifyUserProfile.

@RequestMapping(value = "/modify/action/")
public String modifyUserProfile(@ModelAttribute UserProfileForm userProfileForm, HttpServletRequest request, RedirectAttributes redirectAttributes) {
    // Getting group list from UI
    // String[] groupList = request.getParameterValues("groupIdsList");
    String[] groupList = groupIdsList.toArray(new String[groupIdsList.size()]);
    List<DataGridGroup> groups = new ArrayList<DataGridGroup>();
    if (groupList != null && groupList.length != 0) {
        groups = groupService.findByIdList(groupList);
    }
    Set<DataGridGroup> groupSet = new HashSet<DataGridGroup>(groups);
    // Updating the UserProfile entity
    UserProfile userProfile = userProfileService.findById(Long.valueOf(userProfileForm.getProfileId()));
    userProfile.setProfileName(userProfileForm.getProfileName());
    userProfile.setDescription(userProfileForm.getDescription());
    userProfile.setGroups(groupSet);
    userProfileService.modifyUserProfile(userProfile);
    if (userProfile != null) {
        redirectAttributes.addFlashAttribute("userProfileModifiedSuccessfully", userProfile.getProfileName());
    }
    return "redirect:/users/profile/";
}
Also used : UserProfile(com.emc.metalnx.core.domain.entity.UserProfile) DataGridGroup(com.emc.metalnx.core.domain.entity.DataGridGroup)

Aggregations

UserProfile (com.emc.metalnx.core.domain.entity.UserProfile)8 DataGridGroup (com.emc.metalnx.core.domain.entity.DataGridGroup)5 DataGridUser (com.emc.metalnx.core.domain.entity.DataGridUser)3 ArrayList (java.util.ArrayList)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 UserProfileForm (com.emc.metalnx.modelattribute.user.profile.UserProfileForm)1 IOException (java.io.IOException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ServletOutputStream (javax.servlet.ServletOutputStream)1 DuplicateDataException (org.irods.jargon.core.exception.DuplicateDataException)1 JargonException (org.irods.jargon.core.exception.JargonException)1