예제 #1
0
    @Override
    public boolean check(UserContext user, DepartmentalInstructor source) {
      if (!source.getClasses().isEmpty()) return false;

      if (!source.getExams().isEmpty()) return false;

      return super.check(user, source);
    }
예제 #2
0
 private String[] instructor(Class_ clazz) {
   List<DepartmentalInstructor> leads = clazz.getLeadInstructors();
   String[] instr = new String[leads.size()];
   for (int x = 0; x < clazz.getLeadInstructors().size(); x++) {
     DepartmentalInstructor in = (DepartmentalInstructor) leads.get(x);
     instr[x] = in.nameShort();
   }
   return instr;
 }
예제 #3
0
 @Override
 public boolean check(UserContext user, DepartmentalInstructor source) {
   return permissionDepartment.check(
       user, source.getDepartment(), DepartmentStatusType.Status.OwnerView);
 }
예제 #4
0
  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;
  }