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