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/";
}
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";
}
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/";
}
Aggregations