@Override
    public boolean check(UserContext user, TimetableManager source) {
      for (Department d : source.getDepartments())
        if (!permissionSession.check(user, d.getSession())) return false;

      return true;
    }
    @Override
    public boolean check(UserContext user, TimetableManager source) {
      for (Department d : source.getDepartments()) {
        if (d.getSessionId().equals(user.getCurrentAcademicSessionId())) {
          return permissionSession.check(user, d.getSession());
        }
      }

      return true;
    }
Esempio n. 3
0
  protected void saveSolution(org.hibernate.Session hibSession) {
    TimetableManager owner =
        TimetableManager.findByExternalId(
            getModel().getProperties().getProperty("General.OwnerPuid"));
    Collection exams = org.unitime.timetable.model.Exam.findAll(iSessionId, iExamTypeId);
    Hashtable<Long, ExamEvent> examEvents = new Hashtable();
    for (Iterator i =
            hibSession
                .createQuery(
                    "select e from ExamEvent e where e.exam.session.uniqueId=:sessionId and e.exam.examType.uniqueId=:examTypeId")
                .setLong("sessionId", iSessionId)
                .setLong("examTypeId", iExamTypeId)
                .iterate();
        i.hasNext(); ) {
      ExamEvent e = (ExamEvent) i.next();
      examEvents.put(e.getExam().getUniqueId(), e);
    }
    iProgress.setPhase("Saving assignments...", exams.size());
    Hashtable examTable = new Hashtable();
    for (Iterator i = exams.iterator(); i.hasNext(); ) {
      iProgress.incProgress();
      org.unitime.timetable.model.Exam exam = (org.unitime.timetable.model.Exam) i.next();
      ExamAssignment oldAssignment = new ExamAssignment(exam);
      exam.setAssignedPeriod(null);
      exam.setAssignedPreference(null);
      exam.getAssignedRooms().clear();
      ExamEvent event = examEvents.get(exam.getUniqueId());
      if (event != null) hibSession.delete(event);
      for (Iterator j = exam.getConflicts().iterator(); j.hasNext(); ) {
        ExamConflict conf = (ExamConflict) j.next();
        hibSession.delete(conf);
        j.remove();
      }
      Exam examVar = null;
      for (Exam x : getModel().variables()) {
        if (exam.getUniqueId().equals(x.getId())) {
          examVar = x;
          break;
        }
      }
      if (examVar == null) {
        iProgress.warn("Exam " + getExamLabel(exam) + " was not loaded.");
        if (oldAssignment.getPeriodId() != null) {
          SubjectArea subject = null;
          Department dept = null;
          for (Iterator j = new TreeSet(exam.getOwners()).iterator(); j.hasNext(); ) {
            ExamOwner xo = (ExamOwner) j.next();
            subject = xo.getCourse().getSubjectArea();
            dept = subject.getDepartment();
            break;
          }
          ChangeLog.addChange(
              hibSession,
              owner,
              exam.getSession(),
              exam,
              exam.getName()
                  + " ("
                  + oldAssignment.getPeriodAbbreviation()
                  + " "
                  + oldAssignment.getRoomsName(", ")
                  + " &rarr; N/A)",
              ChangeLog.Source.EXAM_SOLVER,
              ChangeLog.Operation.UNASSIGN,
              subject,
              dept);
        }
        continue;
      }
      examTable.put(examVar.getId(), exam);
      ExamPlacement placement = getAssignment().getValue(examVar);
      if (placement == null) {
        iProgress.warn("Exam " + getExamLabel(exam) + " has no assignment.");
        if (oldAssignment.getPeriodId() != null) {
          SubjectArea subject = null;
          Department dept = null;
          for (Iterator j = new TreeSet(exam.getOwners()).iterator(); j.hasNext(); ) {
            ExamOwner xo = (ExamOwner) j.next();
            subject = xo.getCourse().getSubjectArea();
            dept = subject.getDepartment();
            break;
          }
          ChangeLog.addChange(
              hibSession,
              owner,
              exam.getSession(),
              exam,
              exam.getName()
                  + " ("
                  + oldAssignment.getPeriodAbbreviation()
                  + " "
                  + oldAssignment.getRoomsName(", ")
                  + " &rarr; N/A)",
              ChangeLog.Source.EXAM_SOLVER,
              ChangeLog.Operation.UNASSIGN,
              subject,
              dept);
        }
        continue;
      }
      ExamPeriod period = new ExamPeriodDAO().get(placement.getPeriod().getId());
      if (period == null) {
        iProgress.warn(
            "Examination period "
                + placement.getPeriod().getDayStr()
                + " "
                + placement.getPeriod().getTimeStr()
                + " not found.");
        if (oldAssignment.getPeriodId() != null) {
          SubjectArea subject = null;
          Department dept = null;
          for (Iterator j = new TreeSet(exam.getOwners()).iterator(); j.hasNext(); ) {
            ExamOwner xo = (ExamOwner) j.next();
            subject = xo.getCourse().getSubjectArea();
            dept = subject.getDepartment();
            break;
          }
          ChangeLog.addChange(
              hibSession,
              owner,
              exam.getSession(),
              exam,
              exam.getName()
                  + " ("
                  + oldAssignment.getPeriodAbbreviation()
                  + " "
                  + oldAssignment.getRoomsName(", ")
                  + " &rarr; N/A)",
              ChangeLog.Source.EXAM_SOLVER,
              ChangeLog.Operation.UNASSIGN,
              subject,
              dept);
        }
        continue;
      }
      exam.setAssignedPeriod(period);
      for (Iterator j = placement.getRoomPlacements().iterator(); j.hasNext(); ) {
        ExamRoomPlacement room = (ExamRoomPlacement) j.next();
        Location location = new LocationDAO().get(room.getId());
        if (location == null) {
          iProgress.warn("Location " + room.getName() + " (id:" + room.getId() + ") not found.");
          continue;
        }
        exam.getAssignedRooms().add(location);
      }
      exam.setAssignedPreference(
          new ExamAssignment(placement, getAssignment()).getAssignedPreferenceString());

      hibSession.saveOrUpdate(exam);
      ExamAssignment newAssignment = new ExamAssignment(exam);
      if (!ToolBox.equals(newAssignment.getPeriodId(), oldAssignment.getPeriodId())
          || !ToolBox.equals(newAssignment.getRooms(), oldAssignment.getRooms())) {
        SubjectArea subject = null;
        Department dept = null;
        for (Iterator j = new TreeSet(exam.getOwners()).iterator(); j.hasNext(); ) {
          ExamOwner xo = (ExamOwner) j.next();
          subject = xo.getCourse().getSubjectArea();
          dept = subject.getDepartment();
          break;
        }
        ChangeLog.addChange(
            hibSession,
            owner,
            exam.getSession(),
            exam,
            exam.getName()
                + " ("
                + (oldAssignment.getPeriod() == null
                    ? "N/A"
                    : oldAssignment.getPeriodAbbreviation()
                        + " "
                        + oldAssignment.getRoomsName(", "))
                + " &rarr; "
                + newAssignment.getPeriodAbbreviation()
                + " "
                + newAssignment.getRoomsName(", ")
                + ")",
            ChangeLog.Source.EXAM_SOLVER,
            ChangeLog.Operation.ASSIGN,
            subject,
            dept);
      }
    }
    iProgress.setPhase("Saving conflicts...", getAssignment().nrAssignedVariables());
    for (Exam examVar : getAssignment().assignedVariables()) {
      iProgress.incProgress();
      org.unitime.timetable.model.Exam exam =
          (org.unitime.timetable.model.Exam) examTable.get(examVar.getId());
      if (exam == null) continue;
      ExamPlacement placement = (ExamPlacement) getAssignment().getValue(examVar);
      ExamAssignmentInfo info = new ExamAssignmentInfo(placement, getAssignment());
      for (Iterator i = info.getDirectConflicts().iterator(); i.hasNext(); ) {
        ExamAssignmentInfo.DirectConflict dc = (ExamAssignmentInfo.DirectConflict) i.next();
        if (dc.getOtherExam() == null) continue;
        if (examVar.getId() < dc.getOtherExam().getExamId().longValue()) {
          org.unitime.timetable.model.Exam otherExam =
              (org.unitime.timetable.model.Exam) examTable.get(dc.getOtherExam().getExamId());
          if (otherExam == null) {
            iProgress.warn(
                "Exam "
                    + dc.getOtherExam().getExamName()
                    + " (id:"
                    + dc.getOtherExam().getExamId()
                    + ") not found.");
            continue;
          }
          ExamConflict conf = new ExamConflict();
          conf.setConflictType(ExamConflict.sConflictTypeDirect);
          conf.setStudents(getStudents(hibSession, dc.getStudents()));
          conf.setNrStudents(conf.getStudents().size());
          hibSession.save(conf);
          exam.getConflicts().add(conf);
          otherExam.getConflicts().add(conf);
          iProgress.debug(
              "Direct conflict of "
                  + dc.getStudents().size()
                  + " students between "
                  + exam.getLabel()
                  + " and "
                  + otherExam.getLabel());
        }
      }
      for (Iterator i = info.getBackToBackConflicts().iterator(); i.hasNext(); ) {
        ExamAssignmentInfo.BackToBackConflict btb =
            (ExamAssignmentInfo.BackToBackConflict) i.next();
        if (examVar.getId() < btb.getOtherExam().getExamId().longValue()) {
          org.unitime.timetable.model.Exam otherExam =
              (org.unitime.timetable.model.Exam) examTable.get(btb.getOtherExam().getExamId());
          if (otherExam == null) {
            iProgress.warn(
                "Exam "
                    + btb.getOtherExam().getExamName()
                    + " (id:"
                    + btb.getOtherExam().getExamId()
                    + ") not found.");
            continue;
          }
          ExamConflict conf = new ExamConflict();
          conf.setConflictType(
              btb.isDistance()
                  ? ExamConflict.sConflictTypeBackToBackDist
                  : ExamConflict.sConflictTypeBackToBack);
          conf.setDistance(btb.getDistance());
          conf.setStudents(getStudents(hibSession, btb.getStudents()));
          conf.setNrStudents(conf.getStudents().size());
          exam.getConflicts().add(conf);
          otherExam.getConflicts().add(conf);
          hibSession.save(conf);
          iProgress.debug(
              "Back-to-back conflict of "
                  + btb.getStudents().size()
                  + " students between "
                  + exam.getLabel()
                  + " and "
                  + otherExam.getLabel());
        }
      }
      m2d:
      for (Iterator i = info.getMoreThanTwoADaysConflicts().iterator(); i.hasNext(); ) {
        ExamAssignmentInfo.MoreThanTwoADayConflict m2d =
            (ExamAssignmentInfo.MoreThanTwoADayConflict) i.next();
        HashSet confExams = new HashSet();
        confExams.add(exam);
        for (Iterator j = m2d.getOtherExams().iterator(); j.hasNext(); ) {
          ExamAssignment otherExamAsg = (ExamAssignment) j.next();
          if (examVar.getId() >= otherExamAsg.getExamId().longValue()) continue m2d;
          org.unitime.timetable.model.Exam otherExam =
              (org.unitime.timetable.model.Exam) examTable.get(otherExamAsg.getExamId());
          if (otherExam == null) {
            iProgress.warn(
                "Exam "
                    + otherExamAsg.getExamName()
                    + " (id:"
                    + otherExamAsg.getExamId()
                    + ") not found.");
            continue;
          }
          confExams.add(otherExam);
        }
        if (confExams.size() >= 3) {
          ExamConflict conf = new ExamConflict();
          conf.setConflictType(ExamConflict.sConflictTypeMoreThanTwoADay);
          conf.setStudents(getStudents(hibSession, m2d.getStudents()));
          conf.setNrStudents(conf.getStudents().size());
          hibSession.save(conf);
          for (Iterator j = confExams.iterator(); j.hasNext(); )
            ((org.unitime.timetable.model.Exam) j.next()).getConflicts().add(conf);
          iProgress.debug(
              "More than 2 a day conflict of "
                  + m2d.getStudents().size()
                  + " students between "
                  + exam.getLabel()
                  + " and "
                  + m2d.getOtherExams());
        }
      }

      for (Iterator i = info.getInstructorDirectConflicts().iterator(); i.hasNext(); ) {
        ExamAssignmentInfo.DirectConflict dc = (ExamAssignmentInfo.DirectConflict) i.next();
        if (dc.getOtherExam() == null) continue;
        if (examVar.getId() < dc.getOtherExam().getExamId().longValue()) {
          org.unitime.timetable.model.Exam otherExam =
              (org.unitime.timetable.model.Exam) examTable.get(dc.getOtherExam().getExamId());
          if (otherExam == null) {
            iProgress.warn(
                "Exam "
                    + dc.getOtherExam().getExamName()
                    + " (id:"
                    + dc.getOtherExam().getExamId()
                    + ") not found.");
            continue;
          }
          ExamConflict conf = new ExamConflict();
          conf.setConflictType(ExamConflict.sConflictTypeDirect);
          conf.setInstructors(getInstructors(hibSession, dc.getStudents()));
          conf.setNrInstructors(conf.getInstructors().size());
          hibSession.save(conf);
          exam.getConflicts().add(conf);
          otherExam.getConflicts().add(conf);
          iProgress.debug(
              "Direct conflict of "
                  + dc.getStudents().size()
                  + " instructors between "
                  + exam.getLabel()
                  + " and "
                  + otherExam.getLabel());
        }
      }
      for (Iterator i = info.getInstructorBackToBackConflicts().iterator(); i.hasNext(); ) {
        ExamAssignmentInfo.BackToBackConflict btb =
            (ExamAssignmentInfo.BackToBackConflict) i.next();
        if (examVar.getId() < btb.getOtherExam().getExamId().longValue()) {
          org.unitime.timetable.model.Exam otherExam =
              (org.unitime.timetable.model.Exam) examTable.get(btb.getOtherExam().getExamId());
          if (otherExam == null) {
            iProgress.warn(
                "Exam "
                    + btb.getOtherExam().getExamName()
                    + " (id:"
                    + btb.getOtherExam().getExamId()
                    + ") not found.");
            continue;
          }
          ExamConflict conf = new ExamConflict();
          conf.setConflictType(
              btb.isDistance()
                  ? ExamConflict.sConflictTypeBackToBackDist
                  : ExamConflict.sConflictTypeBackToBack);
          conf.setDistance(btb.getDistance());
          conf.setInstructors(getInstructors(hibSession, btb.getStudents()));
          conf.setNrInstructors(conf.getInstructors().size());
          exam.getConflicts().add(conf);
          otherExam.getConflicts().add(conf);
          hibSession.save(conf);
          iProgress.debug(
              "Back-to-back conflict of "
                  + btb.getStudents().size()
                  + " instructors between "
                  + exam.getLabel()
                  + " and "
                  + otherExam.getLabel());
        }
      }
      m2d:
      for (Iterator i = info.getInstructorMoreThanTwoADaysConflicts().iterator(); i.hasNext(); ) {
        ExamAssignmentInfo.MoreThanTwoADayConflict m2d =
            (ExamAssignmentInfo.MoreThanTwoADayConflict) i.next();
        HashSet confExams = new HashSet();
        confExams.add(exam);
        for (Iterator j = m2d.getOtherExams().iterator(); j.hasNext(); ) {
          ExamAssignment otherExamAsg = (ExamAssignment) j.next();
          if (examVar.getId() >= otherExamAsg.getExamId().longValue()) continue m2d;
          org.unitime.timetable.model.Exam otherExam =
              (org.unitime.timetable.model.Exam) examTable.get(otherExamAsg.getExamId());
          if (otherExam == null) {
            iProgress.warn(
                "Exam "
                    + otherExamAsg.getExamName()
                    + " (id:"
                    + otherExamAsg.getExamId()
                    + ") not found.");
            continue;
          }
          confExams.add(otherExam);
        }
        if (confExams.size() >= 3) {
          ExamConflict conf = new ExamConflict();
          conf.setConflictType(ExamConflict.sConflictTypeMoreThanTwoADay);
          conf.setInstructors(getInstructors(hibSession, m2d.getStudents()));
          conf.setNrInstructors(conf.getInstructors().size());
          hibSession.save(conf);
          for (Iterator j = confExams.iterator(); j.hasNext(); )
            ((org.unitime.timetable.model.Exam) j.next()).getConflicts().add(conf);
          iProgress.debug(
              "More than 2 a day conflict of "
                  + m2d.getStudents().size()
                  + " instructors between "
                  + exam.getLabel()
                  + " and "
                  + m2d.getOtherExams());
        }
      }
    }
    iProgress.setPhase("Saving events...", getAssignment().nrAssignedVariables());
    String ownerPuid = getModel().getProperties().getProperty("General.OwnerPuid");
    EventContact contact = EventContact.findByExternalUniqueId(ownerPuid);
    if (contact == null) {
      TimetableManager manager = TimetableManager.findByExternalId(ownerPuid);
      contact = new EventContact();
      contact.setFirstName(manager.getFirstName());
      contact.setMiddleName(manager.getMiddleName());
      contact.setLastName(manager.getLastName());
      contact.setExternalUniqueId(manager.getExternalUniqueId());
      contact.setEmailAddress(manager.getEmailAddress());
      hibSession.save(contact);
    }
    for (Exam examVar : getAssignment().assignedVariables()) {
      iProgress.incProgress();
      org.unitime.timetable.model.Exam exam =
          (org.unitime.timetable.model.Exam) examTable.get(examVar.getId());
      if (exam == null) continue;
      ExamEvent event = exam.generateEvent(null, true);
      if (event != null) {
        event.setEventName(examVar.getName());
        event.setMinCapacity(examVar.getSize());
        event.setMaxCapacity(examVar.getSize());
        event.setMainContact(contact);
        hibSession.saveOrUpdate(event);
      }
      if (event != null || !exam.getConflicts().isEmpty()) hibSession.saveOrUpdate(exam);
    }
  }
  public static GwtRpcResponseList<ClassAssignmentInterface.Enrollment> convert(
      Collection<StudentClassEnrollment> enrollments,
      Map<Long, List<Meeting>> conflicts,
      boolean canShowExtId,
      boolean canRegister,
      boolean canUseAssistant) {
    GwtRpcResponseList<ClassAssignmentInterface.Enrollment> converted =
        new GwtRpcResponseList<ClassAssignmentInterface.Enrollment>();
    Map<String, String> approvedBy2name = new Hashtable<String, String>();
    Hashtable<Long, ClassAssignmentInterface.Enrollment> student2enrollment =
        new Hashtable<Long, ClassAssignmentInterface.Enrollment>();
    for (StudentClassEnrollment enrollment : enrollments) {
      ClassAssignmentInterface.Enrollment enrl =
          student2enrollment.get(enrollment.getStudent().getUniqueId());
      if (enrl == null) {
        ClassAssignmentInterface.Student st = new ClassAssignmentInterface.Student();
        st.setId(enrollment.getStudent().getUniqueId());
        st.setExternalId(enrollment.getStudent().getExternalUniqueId());
        st.setCanShowExternalId(canShowExtId);
        st.setCanRegister(canRegister);
        st.setCanUseAssistant(canUseAssistant);
        st.setName(
            enrollment
                .getStudent()
                .getName(ApplicationProperty.OnlineSchedulingStudentNameFormat.value()));
        for (AcademicAreaClassification ac :
            enrollment.getStudent().getAcademicAreaClassifications()) {
          st.addArea(ac.getAcademicArea().getAcademicAreaAbbreviation());
          st.addClassification(ac.getAcademicClassification().getCode());
        }
        for (PosMajor m : enrollment.getStudent().getPosMajors()) {
          st.addMajor(m.getCode());
        }
        for (StudentGroup g : enrollment.getStudent().getGroups()) {
          st.addGroup(g.getGroupAbbreviation());
        }
        for (StudentAccomodation a : enrollment.getStudent().getAccomodations()) {
          st.addAccommodation(a.getAbbreviation());
        }
        enrl = new ClassAssignmentInterface.Enrollment();
        enrl.setStudent(st);
        enrl.setEnrolledDate(enrollment.getTimestamp());
        CourseAssignment c = new CourseAssignment();
        c.setCourseId(enrollment.getCourseOffering().getUniqueId());
        c.setSubject(enrollment.getCourseOffering().getSubjectAreaAbbv());
        c.setCourseNbr(enrollment.getCourseOffering().getCourseNbr());
        enrl.setCourse(c);
        student2enrollment.put(enrollment.getStudent().getUniqueId(), enrl);
        if (enrollment.getCourseRequest() != null) {
          enrl.setPriority(1 + enrollment.getCourseRequest().getCourseDemand().getPriority());
          if (enrollment.getCourseRequest().getCourseDemand().getCourseRequests().size() > 1) {
            CourseRequest first = null;
            for (CourseRequest r :
                enrollment.getCourseRequest().getCourseDemand().getCourseRequests()) {
              if (first == null || r.getOrder().compareTo(first.getOrder()) < 0) first = r;
            }
            if (!first.equals(enrollment.getCourseRequest()))
              enrl.setAlternative(first.getCourseOffering().getCourseName());
          }
          if (enrollment.getCourseRequest().getCourseDemand().isAlternative()) {
            CourseDemand first = enrollment.getCourseRequest().getCourseDemand();
            demands:
            for (CourseDemand cd : enrollment.getStudent().getCourseDemands()) {
              if (!cd.isAlternative()
                  && cd.getPriority().compareTo(first.getPriority()) < 0
                  && !cd.getCourseRequests().isEmpty()) {
                for (CourseRequest cr : cd.getCourseRequests())
                  if (cr.getClassEnrollments().isEmpty()) continue demands;
                first = cd;
              }
            }
            CourseRequest alt = null;
            for (CourseRequest r : first.getCourseRequests()) {
              if (alt == null || r.getOrder().compareTo(alt.getOrder()) < 0) alt = r;
            }
            enrl.setAlternative(alt.getCourseOffering().getCourseName());
          }
          enrl.setRequestedDate(enrollment.getCourseRequest().getCourseDemand().getTimestamp());
          enrl.setApprovedDate(enrollment.getApprovedDate());
          if (enrollment.getApprovedBy() != null) {
            String name = approvedBy2name.get(enrollment.getApprovedBy());
            if (name == null) {
              TimetableManager mgr =
                  (TimetableManager)
                      EventDAO.getInstance()
                          .getSession()
                          .createQuery("from TimetableManager where externalUniqueId = :externalId")
                          .setString("externalId", enrollment.getApprovedBy())
                          .setMaxResults(1)
                          .uniqueResult();
              if (mgr != null) {
                name = mgr.getName();
              } else {
                DepartmentalInstructor instr =
                    (DepartmentalInstructor)
                        EventDAO.getInstance()
                            .getSession()
                            .createQuery(
                                "from DepartmentalInstructor where externalUniqueId = :externalId and department.session.uniqueId = :sessionId")
                            .setString("externalId", enrollment.getApprovedBy())
                            .setLong(
                                "sessionId", enrollment.getStudent().getSession().getUniqueId())
                            .setMaxResults(1)
                            .uniqueResult();
                if (instr != null) name = instr.nameLastNameFirst();
              }
              if (name != null) approvedBy2name.put(enrollment.getApprovedBy(), name);
            }
            enrl.setApprovedBy(name == null ? enrollment.getApprovedBy() : name);
          }
        } else {
          enrl.setPriority(-1);
        }

        List<Meeting> conf =
            (conflicts == null ? null : conflicts.get(enrollment.getStudent().getUniqueId()));
        if (conf != null) {
          Map<Event, TreeSet<Meeting>> events = new HashMap<Event, TreeSet<Meeting>>();
          for (Meeting m : conf) {
            TreeSet<Meeting> ms = events.get(m.getEvent());
            if (ms == null) {
              ms = new TreeSet<Meeting>();
              events.put(m.getEvent(), ms);
            }
            ms.add(m);
          }
          for (Event confEvent : new TreeSet<Event>(events.keySet())) {
            Conflict conflict = new Conflict();
            conflict.setName(confEvent.getEventName());
            conflict.setType(confEvent.getEventTypeAbbv());
            String lastDate = null, lastTime = null, lastRoom = null;
            for (MultiMeeting mm : Event.getMultiMeetings(events.get(confEvent))) {
              String date =
                  getDateFormat().format(mm.getMeetings().first().getMeetingDate())
                      + (mm.getMeetings().size() == 1
                          ? ""
                          : " - "
                              + getDateFormat().format(mm.getMeetings().last().getMeetingDate()));
              if (lastDate == null) {
                conflict.setDate(date);
              } else if (lastDate.equals(date)) {
                conflict.setDate(conflict.getDate() + "<br>");
              } else {
                conflict.setDate(conflict.getDate() + "<br>" + date);
              }
              lastDate = date;

              String time =
                  mm.getDays(CONSTANTS.days(), CONSTANTS.shortDays())
                      + " "
                      + (mm.getMeetings().first().isAllDay()
                          ? "All Day"
                          : mm.getMeetings().first().startTime()
                              + " - "
                              + mm.getMeetings().first().stopTime());
              if (lastTime == null) {
                conflict.setTime(time);
              } else if (lastTime.equals(time)) {
                conflict.setTime(conflict.getTime() + "<br>");
              } else {
                conflict.setTime(conflict.getTime() + "<br>" + time);
              }
              lastTime = time;

              String room =
                  (mm.getMeetings().first().getLocation() == null
                      ? ""
                      : mm.getMeetings().first().getLocation().getLabel());
              if (lastRoom == null) {
                conflict.setRoom(room);
              } else if (lastRoom.equals(room)) {
                conflict.setRoom(conflict.getRoom() + "<br>");
              } else {
                conflict.setRoom(conflict.getRoom() + "<br>" + room);
              }
              lastRoom = room;
            }
            enrl.addConflict(conflict);
          }
        }

        converted.add(enrl);
      }
      ClassAssignmentInterface.ClassAssignment c = enrl.getCourse().addClassAssignment();
      c.setClassId(enrollment.getClazz().getUniqueId());
      c.setSection(enrollment.getClazz().getClassSuffix(enrollment.getCourseOffering()));
      if (c.getSection() == null) c.setSection(enrollment.getClazz().getSectionNumberString());
      c.setClassNumber(enrollment.getClazz().getSectionNumberString());
      c.setSubpart(enrollment.getClazz().getSchedulingSubpart().getItypeDesc());
    }
    return converted;
  }