User user = userDao.getUserById(userId);
Organization organization = organizationDao.getOrganization(organizationId);
//get only 1st employment
if (user != null && user.getEmployments() != null && user.getEmployments().size() > 0 && organization != null) {
Employment employment = (Employment) user.getEmployments().iterator().next();
if (!organization.getId().equals(employment.getOrganizationId())) {
if (employment.getHods() != null && !employment.getHods().isEmpty() && employment.getDepartment() != null) {
Department orgDepartment = employment.getDepartment();
orgDepartment.setHod(null);
departmentDao.updateDepartment(orgDepartment);
}
employment.setOrganizationId(organization.getId());
employment.setDepartmentId(null);
employment.setGradeId(null);
employment.getHods().clear();
saveOrUpdate("Employment", employment);
}
return true;
}
} catch (Exception e) {