From 17f3299c3e2b0dae9c6b58c833126b502bc1005f Mon Sep 17 00:00:00 2001 From: tomas-muller Date: Fri, 15 Sep 2023 18:21:55 +0200 Subject: [PATCH] Instructional Offering Cross Lists - fix the instructors and offering coordinators when the controlling department is changed - this means that each instructor/coordinator gets replaced with an instructor/coordinator from the controlling department with the matching external id - an instructor/coordinator assignment gets deleted otherwise (the instructor has no external id or no matching instructor in the new controlling department) --- .../action/CrossListsModifyAction.java | 39 +++++++++++++++++++ WebContent/help/Release-Notes.xml | 9 +++++ 2 files changed, 48 insertions(+) diff --git a/JavaSource/org/unitime/timetable/action/CrossListsModifyAction.java b/JavaSource/org/unitime/timetable/action/CrossListsModifyAction.java index 2d757dd58c..e0582288b2 100644 --- a/JavaSource/org/unitime/timetable/action/CrossListsModifyAction.java +++ b/JavaSource/org/unitime/timetable/action/CrossListsModifyAction.java @@ -49,15 +49,18 @@ import org.unitime.timetable.model.AdvisorCourseRequest; import org.unitime.timetable.model.AdvisorSectioningPref; import org.unitime.timetable.model.ChangeLog; +import org.unitime.timetable.model.ClassInstructor; import org.unitime.timetable.model.Class_; import org.unitime.timetable.model.CourseOffering; import org.unitime.timetable.model.CourseRequest; import org.unitime.timetable.model.CurriculumCourse; import org.unitime.timetable.model.Department; +import org.unitime.timetable.model.DepartmentalInstructor; import org.unitime.timetable.model.Event; import org.unitime.timetable.model.Exam; import org.unitime.timetable.model.InstrOfferingConfig; import org.unitime.timetable.model.InstructionalOffering; +import org.unitime.timetable.model.OfferingCoordinator; import org.unitime.timetable.model.SchedulingSubpart; import org.unitime.timetable.model.SubjectArea; import org.unitime.timetable.model.comparators.CourseOfferingComparator; @@ -537,9 +540,45 @@ private void doUpdate() cls.setManagingDept(dept, sessionContext.getUser(), hibSession); hibSession.saveOrUpdate(cls); } + // Fix class instructors + for (Iterator i = cls.getClassInstructors().iterator(); i.hasNext();) { + ClassInstructor ci = i.next(); + if (!ci.getInstructor().getDepartment().equals(dept)) { + ci.getInstructor().getClasses().remove(ci); + DepartmentalInstructor di = (ci.getInstructor().getExternalUniqueId() == null ? null : + DepartmentalInstructor.findByPuidDepartmentId(ci.getInstructor().getExternalUniqueId(), dept.getUniqueId(), hibSession)); + if (di == null) { + hibSession.delete(ci); + i.remove(); + } else { + ci.setInstructor(di); + di.getClasses().add(ci); + hibSession.update(ci); + } + } + } } } } + if (io.getOfferingCoordinators() != null) { + // Fix offering coordinators + for (Iterator i = io.getOfferingCoordinators().iterator(); i.hasNext(); ) { + OfferingCoordinator oc = i.next(); + if (!oc.getInstructor().getDepartment().equals(dept)) { + oc.getInstructor().getOfferingCoordinators().remove(oc); + DepartmentalInstructor di = (oc.getInstructor().getExternalUniqueId() == null ? null : + DepartmentalInstructor.findByPuidDepartmentId(oc.getInstructor().getExternalUniqueId(), dept.getUniqueId(), hibSession)); + if (di == null) { + hibSession.delete(oc); + i.remove(); + } else { + oc.setInstructor(di); + di.getOfferingCoordinators().add(oc); + hibSession.update(oc); + } + } + } + } ChangeLog.addChange( diff --git a/WebContent/help/Release-Notes.xml b/WebContent/help/Release-Notes.xml index d69052f88f..b6ddc9bcd6 100644 --- a/WebContent/help/Release-Notes.xml +++ b/WebContent/help/Release-Notes.xml @@ -76,6 +76,15 @@ Added ability to select an imported solution (that does not have any GlobalInfo saved). + + Instructional Offering Cross Lists + + Fix the instructors and offering coordinators when the controlling department is changed. + This means that each instructor/coordinator gets replaced with an instructor/coordinator from the controlling department with the matching external id. + An instructor/coordinator assignment gets deleted otherwise (the instructor has no external id or no matching instructor in the new controlling department). + + + Administration