Skip to content

Commit

Permalink
Event API: Session
Browse files Browse the repository at this point in the history
- added academic session information for each event, containing session id, academic term, year, and initiative
  • Loading branch information
tomas-muller committed Jan 30, 2025
1 parent afdd1e6 commit 6875ae4
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ public static EventInterface getEventDetail(Session session, Event e, EventConte
event.addCourseName(courseOffering.getCourseName());
event.addCourseTitle(courseOffering.getTitle() == null ? "" : courseOffering.getTitle());
event.setDeptCode(courseOffering.getDepartment().getDeptCode());
event.setSession(EventLookupBackend.toSessionInterface(courseOffering.getInstructionalOffering().getSession()));
event.setInstruction(clazz.getSchedulingSubpart().getItype().getDesc().length() <= 20 ? clazz.getSchedulingSubpart().getItype().getDesc() : clazz.getSchedulingSubpart().getItype().getAbbv());
if (clazz.getSchedulingSubpart().getInstrOfferingConfig().getInstructionalMethod() != null)
event.setInstruction(event.getInstruction() + " (" + clazz.getSchedulingSubpart().getInstrOfferingConfig().getInstructionalMethod().getLabel() + ")");
Expand All @@ -321,6 +322,7 @@ public static EventInterface getEventDetail(Session session, Event e, EventConte
ExamEvent xe = (e instanceof ExamEvent ? (ExamEvent)e : ExamEventDAO.getInstance().get(e.getUniqueId(), hibSession));
event.setEnrollment(xe.getExam().countStudents());
event.setMaxCapacity(xe.getExam().getSize());
event.setSession(EventLookupBackend.toSessionInterface(xe.getExam().getSession()));
Set<Long> addedInstructorIds = new HashSet<Long>();
for (DepartmentalInstructor i: xe.getExam().getInstructors()) {
ContactInterface instructor = new ContactInterface();
Expand Down Expand Up @@ -607,6 +609,8 @@ public static EventInterface getEventDetail(Session session, Event e, EventConte
event.addCoordinator(coordinator);
}
}
if (event.getSession() == null)
event.setSession(EventLookupBackend.toSessionInterface(owner.getCourse().getInstructionalOffering().getSession()));
}
event.setEnrollment(enrl);
event.setMaxCapacity(limit);
Expand Down Expand Up @@ -725,6 +729,8 @@ public static EventInterface getEventDetail(Session session, Event e, EventConte
meeting.addConflict(conflict);
}
}
if (event.getSession() == null)
event.setSession(EventLookupBackend.toSessionInterface(m.getLocation().getSession()));
}
Set<Meeting> overlapsThisMeeting = overlaps.get(m.getUniqueId());
if (overlapsThisMeeting != null && m.getLocation() != null && !m.getLocation().isIgnoreRoomCheck()) {
Expand Down Expand Up @@ -1029,6 +1035,7 @@ public static EventInterface getArrangeHoursClassDetail(Class_ clazz, EventConte
event.addCourseName(correctedOffering.getCourseName());
event.addCourseTitle(correctedOffering.getTitle() == null ? "" : correctedOffering.getTitle());
event.setDeptCode(correctedOffering.getDepartment().getDeptCode());
event.setSession(EventLookupBackend.toSessionInterface(correctedOffering.getInstructionalOffering().getSession()));
event.setInstruction(clazz.getSchedulingSubpart().getItype().getDesc().length() <= 20 ? clazz.getSchedulingSubpart().getItype().getDesc() : clazz.getSchedulingSubpart().getItype().getAbbv());
if (clazz.getSchedulingSubpart().getInstrOfferingConfig().getInstructionalMethod() != null)
event.setInstruction(event.getInstruction() + " (" + clazz.getSchedulingSubpart().getInstrOfferingConfig().getInstructionalMethod().getLabel() + ")");
Expand Down
18 changes: 17 additions & 1 deletion JavaSource/org/unitime/timetable/events/EventLookupBackend.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import org.unitime.timetable.gwt.shared.EventInterface.NoteInterface;
import org.unitime.timetable.gwt.shared.EventInterface.ResourceInterface;
import org.unitime.timetable.gwt.shared.EventInterface.ResourceType;
import org.unitime.timetable.gwt.shared.EventInterface.SessionInterface;
import org.unitime.timetable.gwt.shared.EventInterface.SponsoringOrganizationInterface;
import org.unitime.timetable.model.ClassEvent;
import org.unitime.timetable.model.ClassInstructor;
Expand Down Expand Up @@ -1613,6 +1614,7 @@ else if (request.getResourceExternalId() != null)
}
CourseOffering correctedOffering = clazz.getSchedulingSubpart().getInstrOfferingConfig().getInstructionalOffering().getControllingCourseOffering();
event.setDeptCode(correctedOffering.getDepartment().getDeptCode());
event.setSession(toSessionInterface(correctedOffering.getInstructionalOffering().getSession()));
List<CourseOffering> courses = new ArrayList<CourseOffering>(clazz.getSchedulingSubpart().getInstrOfferingConfig().getInstructionalOffering().getCourseOfferings());
boolean instructing = false;
if (request.getResourceType() == ResourceType.PERSON && request.getResourceExternalId() != null) {
Expand Down Expand Up @@ -1708,6 +1710,7 @@ else if (request.getResourceExternalId() != null)
ExamEvent xe = ExamEventDAO.getInstance().get(m.getEvent().getUniqueId(), hibSession);
event.setEnrollment(xe.getExam().countStudents());
event.setMaxCapacity(xe.getExam().getSize());
event.setSession(toSessionInterface(xe.getExam().getSession()));
if (groupEnrollments) {
int enrl = 0;
Set<Long> studentIds = xe.getExam().getStudentIds();
Expand Down Expand Up @@ -1863,7 +1866,8 @@ else if (request.getResourceExternalId() != null)
break;
}
}
}
if (event.getSession() == null)
event.setSession(toSessionInterface(owner.getCourse().getInstructionalOffering().getSession())); }
event.setEnrollment(enrl);
event.setMaxCapacity(cap);
}
Expand Down Expand Up @@ -1932,6 +1936,8 @@ else if (request.getResourceExternalId() != null)
location.setPartitionParentId(m.getLocation().getPartitionParentId());
location.setEventEmail(m.getLocation().getEventEmail());
meeting.setLocation(location);
if (event.getSession() == null)
event.setSession(toSessionInterface(m.getLocation().getSession()));
}
if (request.getEventFilter().hasOptions("flag") && request.getEventFilter().getOptions("flag").contains("Conflicts")) {
if (m.getLocation() != null && m.getLocation().getEventAvailability() != null && m.getLocation().getEventAvailability().length() == Constants.SLOTS_PER_DAY * Constants.DAY_CODES.length) {
Expand Down Expand Up @@ -2761,6 +2767,7 @@ else if (request.getResourceExternalId() != null)
event.setClassId(clazz.getUniqueId());
event.setSessionId(clazz.getSessionId());
event.setDeptCode(correctedOffering.getDepartment().getDeptCode());
event.setSession(toSessionInterface(correctedOffering.getInstructionalOffering().getSession()));
List<CourseOffering> courses = new ArrayList<CourseOffering>(clazz.getSchedulingSubpart().getInstrOfferingConfig().getInstructionalOffering().getCourseOfferings());
switch (request.getResourceType()) {
case CURRICULUM:
Expand Down Expand Up @@ -2985,5 +2992,14 @@ public static TreeSet<MeetingInterface> generateUnavailabilityMeetings(Location
}
return ret;
}

protected static SessionInterface toSessionInterface(Session session) {
SessionInterface ret = new SessionInterface();
ret.setId(session.getUniqueId());
ret.setTerm(session.getAcademicTerm());
ret.setYear(session.getAcademicYear());
ret.setInitiative(session.getAcademicInitiative());
return ret;
}

}
28 changes: 28 additions & 0 deletions JavaSource/org/unitime/timetable/gwt/shared/EventInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public class EventInterface implements Comparable<EventInterface>, IsSerializabl
private Set<EventServiceProviderInterface> iRequestedServices = null;
private Long iClassId = null, iSessionId = null;
private String iDeptCode = null;
private SessionInterface iSession = null;

public static enum ResourceType implements IsSerializable {
ROOM("Room Timetable","room", true),
Expand Down Expand Up @@ -397,6 +398,8 @@ public String getRequestedServices(String separator) {

public Long getSessionId() { return iSessionId; }
public void setSessionId(Long sessionId) { iSessionId = sessionId; }
public SessionInterface getSession() { return iSession; }
public void setSession(SessionInterface session) { iSession = session; }
public Long getClassId() { return iClassId; }
public void setClassId(Long classId) { iClassId = classId; }

Expand Down Expand Up @@ -452,6 +455,7 @@ public EventInterface createConflictingEvent(EventInterface event) {
conflict.setInstructionType(event.getInstructionType());
conflict.setSectionNumber(event.getSectionNumber());
conflict.setDeptCode(event.getDeptCode());
conflict.setSession(event.getSession());
if (event.hasCourseIds())
for (Long courseId: event.getCourseIds())
conflict.addCourseId(courseId);
Expand Down Expand Up @@ -2844,4 +2848,28 @@ public SendStudentEmailsRpcRequest() {}
public Set<Long> getStudentIds() { return iStudentIds; }
public void setStudentIds(Set<Long> studentIds) { iStudentIds = studentIds; }
}

public static class SessionInterface implements IsSerializable {
private Long iSessionId = null;
private String iTerm;
private String iYear;
private String iInitiative;

public SessionInterface() {}
public SessionInterface(Long id, String term, String year, String initiative) {
iSessionId = id;
iTerm = term;
iYear = year;
iInitiative = initiative;
}

public Long getId() { return iSessionId; }
public void setId(Long id) { iSessionId = id; }
public String getTerm() { return iTerm; }
public void setTerm(String term) { iTerm = term; }
public String getYear() { return iYear; }
public void setYear(String year) { iYear = year; }
public String getInitiative() { return iInitiative; }
public void setInitiative(String initiative) { iInitiative = initiative; }
}
}

0 comments on commit 6875ae4

Please sign in to comment.