@Override
 public void updateRole(RoleDto role) {
   MotechRole motechRole = allMotechRoles.findByRoleName(role.getOriginalRoleName());
   motechRole.setRoleName(role.getRoleName());
   motechRole.setPermissionNames(role.getPermissionNames());
   List<MotechUser> users =
       (List<MotechUser>) allMotechUsers.findByRole(role.getOriginalRoleName());
   for (MotechUser user : users) {
     List<String> roleList = user.getRoles();
     roleList.remove(role.getOriginalRoleName());
     roleList.add(role.getRoleName());
     allMotechUsers.update(user);
   }
   allMotechRoles.update(motechRole);
 }
Example #2
0
 /**
  * Creates MotechRole if it doesn't exists
  *
  * @param role to be created
  */
 public void add(MotechRole role) {
   if (findByRoleName(role.getRoleName()) == null) {
     dataService.create(role);
   }
 }