for (Iterator i = instances.iterator(); i.hasNext(); ) {
Object pc = i.next();
// clear employee relationships
if (pc instanceof Employee) {
Employee employee = (Employee) pc;
if (employee.getDentalInsurance() != null) {
employee.getDentalInsurance().setEmployee(null);
}
if (employee.getMedicalInsurance() != null) {
employee.getMedicalInsurance().setEmployee(null);
}
if (employee.getDepartment() != null) {
((Department)employee.getDepartment()).removeEmployee(employee);
}
if (employee.getFundingDept() != null) {
((Department)employee.getFundingDept()).removeEmployee(employee);
}
if (employee.getManager() != null) {
((Employee)employee.getManager()).removeFromTeam(employee);
}
if (employee.getMentor() != null) {
employee.getMentor().setProtege(null);
}
if (employee.getProtege() != null) {
employee.getProtege().setMentor(null);
}
if (employee.getHradvisor() != null) {
((Employee)employee.getHradvisor()).removeAdvisee(employee);
}
if (employee.getReviewedProjects() != null) {
for (Iterator it=employee.getReviewedProjects().iterator();
it.hasNext(); ) {
Project other = (Project) it.next();
other.removeReviewer(employee);
}
}
if (employee.getProjects() != null) {
for (Iterator it=employee.getProjects().iterator();
it.hasNext(); ) {
Project other = (Project) it.next();
other.removeMember(employee);
}
}
if (employee.getTeam() != null) {
for (Iterator it=employee.getTeam().iterator(); it.hasNext(); ) {
Employee other = (Employee) it.next();
other.setManager(null);
}
}
if (employee.getHradvisees() != null) {
for (Iterator it=employee.getHradvisees().iterator(); it.hasNext(); ) {
Employee other = (Employee) it.next();
other.setHradvisor(employee);
}
}
}
// make the instance dirty.