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.setDepartmentId(null);
employment.getHods().clear();
saveOrUpdate("Employment", employment);
return true;
}
}
} catch (Exception e) {