@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); }
@Override public void createRole(RoleDto role) { MotechRole motechRole = new MotechRoleCouchdbImpl(role.getRoleName(), role.getPermissionNames()); allMotechRoles.add(motechRole); }