}
public Boolean assignUserToDepartment(String userId, String departmentId) {
try {
User user = userDao.getUserById(userId);
Department department = departmentDao.getDepartment(departmentId);
//get only 1st employment
if (user != null && user.getEmployments() != null && user.getEmployments().size() > 0 && department != null) {
Employment employment = (Employment) user.getEmployments().iterator().next();
if (!department.getId().equals(employment.getDepartmentId())) {
if (employment.getHods() != null && !employment.getHods().isEmpty() && employment.getDepartment() != null) {
Department orgDepartment = employment.getDepartment();
orgDepartment.setHod(null);
departmentDao.updateDepartment(orgDepartment);
}
employment.setOrganizationId(department.getOrganization().getId());
employment.setDepartmentId(department.getId());