public String removeUser(Long id) {
   userToRemove = registrationDao.getEntityManager().find(User.class, id);
   registrationDao.remove(userToRemove);
   MessageService.displayFacesMessageInfo(
       "registration_properties", "REGISTRATION_REMOVED_SUMMARY", "REGISTRATION_REMOVED_DETAIL");
   allUsersByCreationDate = registrationDao.findAllUsersByRegistrationDate();
   userToRemove = null;
   return REMOVE_PATH;
 }
 private void prepareUpdatedGroupPickup() {
   targetGroup = new ArrayList<String>();
   sourceGroup = new ArrayList<String>();
   for (UserGroup userGroup : registrationDao.findGroupsByUser(userToUpdate)) {
     targetGroup.add(userGroup.getGroupName());
   }
   for (UserGroup group : registrationDao.findNotAssignedUserGroupsByUser(userToUpdate)) {
     sourceGroup.add(group.getGroupName());
   }
   groupDefinitions = new DualListModel<String>(sourceGroup, targetGroup);
 }
 private Set<Role> redefineRoles() {
   Set<Role> userRoles = new HashSet<Role>(userToUpdate.getRoles());
   for (String newRole : roleDefinitions.getSource()) {
     Role role = registrationDao.findRoleByRoleName(newRole);
     userRoles.remove(role);
   }
   for (String newRole : roleDefinitions.getTarget()) {
     Role role = registrationDao.findRoleByRoleName(newRole);
     userRoles.add(role);
   }
   return userRoles;
 }
 private Set<UserGroup> redefineGroups() {
   Set<UserGroup> userGroups = new HashSet<UserGroup>(userToUpdate.getGroups());
   for (String newGroup : groupDefinitions.getSource()) {
     UserGroup userGroup = registrationDao.findGroupByGroupName(newGroup);
     userGroups.remove(userGroup);
   }
   for (String newGroup : groupDefinitions.getTarget()) {
     UserGroup userGroup = registrationDao.findGroupByGroupName(newGroup);
     userGroups.add(userGroup);
   }
   return userGroups;
 }
 private void prepareUpdatedRolePickup() {
   targetRole = new ArrayList<String>();
   sourceRole = new ArrayList<String>();
   for (Role role : registrationDao.findRolesByUser(userToUpdate)) {
     targetRole.add(role.getRoleName());
   }
   for (Role role : registrationDao.findNotAssignedRolesByUser(userToUpdate)) {
     if (!role.getRoleName().toLowerCase().equals("administrator")) {
       sourceRole.add(role.getRoleName());
     }
   }
   roleDefinitions = new DualListModel<String>(sourceRole, targetRole);
 }
 public String prepareUpdateUser(Long id) {
   userListToUpdate = new ArrayList<User>();
   userToUpdate = registrationDao.getEntityManager().find(User.class, id);
   userName = userToUpdate.getUserName();
   firstName = userToUpdate.getFirstName();
   lastName = userToUpdate.getLastName();
   email = userToUpdate.getEmail();
   prepareUpdatedRolePickup();
   prepareUpdatedGroupPickup();
   userListToUpdate.add(userToUpdate);
   allUsersByCreationDate = registrationDao.findAllUsersByRegistrationDate();
   sortPickup();
   return UPDATE_PATH;
 }
 // ###################################################################
 // business methods
 // ###################################################################
 public String saveUserRegistration() {
   if (!roleDefinitions.getTarget().isEmpty() && !groupDefinitions.getTarget().isEmpty()) {
     User newUser = defineBasicUserAttributes();
     Set<Role> userRoles = defineRoles();
     newUser.setRoles(userRoles);
     Set<UserGroup> userGroups = defineGroups();
     newUser.setGroups(userGroups);
     registrationDao.persist(newUser);
     resetFields();
     MessageService.displayFacesMessageInfo(
         "registration_properties", "REGISTRATION_SUCCESS_SUMMARY", "REGISTRATION_SUCCESS_DETAIL");
   }
   allUsersByCreationDate = registrationDao.findAllUsersByRegistrationDate();
   return "/pages/administration/registration/new.jsf";
 }
 private Set<Role> defineRoles() {
   Set<Role> userRoles = new HashSet<Role>();
   for (String newRole : roleDefinitions.getTarget()) {
     Role role = registrationDao.findRoleByRoleName(newRole);
     userRoles.add(role);
   }
   return userRoles;
 }
 private Set<UserGroup> defineGroups() {
   Set<UserGroup> userGroups = new HashSet<UserGroup>();
   for (String newGroup : groupDefinitions.getTarget()) {
     UserGroup userGroup = registrationDao.findGroupByGroupName(newGroup);
     userGroups.add(userGroup);
   }
   return userGroups;
 }
Пример #10
0
 // ###################################################################
 // private methods
 // ###################################################################
 private List<String> initBasicGroups() {
   List<String> sourceGroup = new ArrayList<String>();
   targetGroup = new ArrayList<String>();
   List<UserGroup> availableGroups = registrationDao.findAllGroups();
   for (UserGroup group : availableGroups) {
     sourceGroup.add(group.getGroupName());
   }
   Collections.sort(sourceGroup);
   groupDefinitions = new DualListModel<String>(sourceGroup, targetGroup);
   return sourceGroup;
 }
Пример #11
0
 private void initBasicRoles() {
   List<String> sourceRole = new ArrayList<String>();
   targetRole = new ArrayList<String>();
   List<Role> availableRoles = registrationDao.findAllRoles();
   for (Role role : availableRoles) {
     if (!role.getRoleName().toLowerCase().equals("administrator")) {
       sourceRole.add(role.getRoleName());
     }
   }
   Collections.sort(sourceRole);
   roleDefinitions = new DualListModel<String>(sourceRole, targetRole);
 }
Пример #12
0
 public String updateUser(User user) {
   userToUpdate = user;
   userToUpdate.setModifiedOn(new Date());
   User modifiedByUser = (User) SessionService.getSessionAttribute("user");
   userToUpdate.setModifiedBy(modifiedByUser.getUserName());
   Set<Role> userRoles = redefineRoles();
   userToUpdate.setRoles(userRoles);
   Set<UserGroup> userGroups = redefineGroups();
   userToUpdate.setGroups(userGroups);
   registrationDao.mergeUser(userToUpdate);
   sortPickup();
   resetFields();
   MessageService.displayFacesMessageInfo(
       "registration_properties",
       "REGISTRATION_USER_UPDATED_SUMMARY",
       "REGISTRATION_USER_UPDATED_DETAIL");
   return UPDATE_PATH;
 }
Пример #13
0
 public String toggleUserActivity(User user) {
   userToUpdate = user;
   userToUpdate.setDisabled(!userToUpdate.getDisabled());
   userToUpdate.setModifiedOn(new Date());
   User modifiedByUser = (User) SessionService.getSessionAttribute("user");
   userToUpdate.setModifiedBy(modifiedByUser.getUserName());
   registrationDao.mergeUser(userToUpdate);
   userToUpdate = null;
   if (user.getDisabled()) {
     MessageService.displayFacesMessageInfo(
         "registration_properties",
         "REGISTRATION_USER_DISABLED_SUMMARY",
         "REGISTRATION_USER_DISABLED_DETAIL");
   } else {
     MessageService.displayFacesMessageInfo(
         "registration_properties",
         "REGISTRATION_USER_ENABLED_SUMMARY",
         "REGISTRATION_USER_ENABLED_DETAIL");
   }
   return UPDATE_PATH;
 }
Пример #14
0
 // ###################################################################
 // constructors
 // ###################################################################
 public RegistrationController() {
   initBasicRoles();
   initBasicGroups();
   allUsersByCreationDate = registrationDao.findAllUsersByRegistrationDate();
 }