Ejemplo n.º 1
0
    @Override
    public boolean check(UserContext user, InstrOfferingConfig source) {
      if (permissionDepartment.check(
          user, source.getDepartment(), DepartmentStatusType.Status.OwnerLimitedEdit)) return true;

      // Manager can edit external department
      Set<Department> externals = new HashSet<Department>();
      for (SchedulingSubpart subpart : source.getSchedulingSubparts()) {
        for (Class_ clazz : subpart.getClasses()) {
          if (clazz.getManagingDept() != null && clazz.getManagingDept().isExternalManager()) {
            if (externals.add(clazz.getManagingDept())
                && permissionDepartment.check(
                    user, clazz.getManagingDept(), DepartmentStatusType.Status.ManagerLimitedEdit))
              return true;
          }
        }
      }

      return false;
    }
Ejemplo n.º 2
0
  public XSubpart(SchedulingSubpart subpart, boolean courseCredit, OnlineSectioningHelper helper) {
    iUniqueId = subpart.getUniqueId();
    iInstructionalType =
        sF3Z.format(subpart.getItype().getItype())
            + subpart.getSchedulingSubpartSuffix(helper.getHibSession());
    iAllowOverlap = subpart.isStudentAllowOverlap();
    iName = subpart.getItype().getAbbv().trim();
    iConfigId = subpart.getInstrOfferingConfig().getUniqueId();
    iParentId =
        subpart.getParentSubpart() == null ? null : subpart.getParentSubpart().getUniqueId();
    if (subpart.getCredit() != null) {
      iCreditAbbv = subpart.getCredit().creditAbbv();
      iCreditText = subpart.getCredit().creditText();
    }
    if (courseCredit) {
      for (CourseOffering co :
          subpart.getInstrOfferingConfig().getInstructionalOffering().getCourseOfferings()) {
        if (co.getCredit() != null)
          iCreditByCourse.put(
              co.getUniqueId(),
              new String[] {co.getCredit().creditAbbv(), co.getCredit().creditText()});
      }
    }
    for (Class_ clazz : subpart.getClasses()) iSections.add(new XSection(clazz, helper));

    Collections.sort(iSections);
  }
Ejemplo n.º 3
0
  protected void print(CourseOffering co) throws DocumentException {
    if (!iCurrentSubjectArea.equals(co.getSubjectArea())) {
      lastPage();
      iCurrentSubjectArea = co.getSubjectArea();
      iDoc.newPage();
      printHeader();
    } else {
      if (iLineNo + 5 >= sNrLines) newPage();
    }
    iCourseOffering = co;
    int courseLimit = -1;
    InstructionalOffering offering = co.getInstructionalOffering();
    if (co.getReservation() != null) courseLimit = co.getReservation();
    if (courseLimit < 0) {
      if (offering.getCourseOfferings().size() == 1 && offering.getLimit() != null)
        courseLimit = offering.getLimit().intValue();
    }
    boolean unlimited = false;
    String courseOrg = "";
    for (Iterator i = offering.getInstrOfferingConfigs().iterator(); i.hasNext(); ) {
      InstrOfferingConfig config = (InstrOfferingConfig) i.next();
      if (config.isUnlimitedEnrollment().booleanValue()) unlimited = true;
      Hashtable creditPerIType = new Hashtable();
      for (Iterator j = config.getSchedulingSubparts().iterator(); j.hasNext(); ) {
        SchedulingSubpart subpart = (SchedulingSubpart) j.next();
        if (subpart.getMinutesPerWk().intValue() <= 0) continue;
        Integer credit = (Integer) creditPerIType.get(subpart.getItype());
        creditPerIType.put(
            subpart.getItype(),
            new Integer(
                (credit == null ? 0 : credit.intValue()) + subpart.getMinutesPerWk().intValue()));
      }
      TreeSet itypes =
          new TreeSet(
              new Comparator() {
                public int compare(Object o1, Object o2) {
                  ItypeDesc i1 = (ItypeDesc) o1;
                  ItypeDesc i2 = (ItypeDesc) o2;
                  return i1.getItype().compareTo(i2.getItype());
                }
              });
      itypes.addAll(creditPerIType.keySet());
      for (Iterator j = itypes.iterator(); j.hasNext(); ) {
        ItypeDesc itype = (ItypeDesc) j.next();
        int minPerWeek = ((Integer) creditPerIType.get(itype)).intValue();
        if (courseOrg.length() > 0) courseOrg += ", ";
        courseOrg += itype.getAbbv().trim() + " " + ((minPerWeek + 49) / 50);
      }
      break;
    }
    int enrl = -1;
    String s1 =
        co.getSubjectArea().getSession().getAcademicTerm().substring(0, 1)
            + co.getSubjectArea().getSession().getAcademicYear().substring(2);
    String s2 =
        co.getSubjectArea().getSession().getAcademicTerm().substring(0, 1)
            + new DecimalFormat("00")
                .format(
                    Integer.parseInt(
                            co.getSubjectArea().getSession().getAcademicYear().substring(2))
                        - 1);
    if (co.getProjectedDemand() != null) enrl = co.getProjectedDemand().intValue();
    int lastLikeEnrl = co.getCourseOfferingDemands().size();
    String title = co.getTitle();
    if (title == null) title = "*** Title not set";
    println(
        "                                                                                              Proj  "
            + s2
            + "                     ");
    println(
        "Course     Title/Notes                           Credit Course Organization             Limit Enrl  Enrl  Consent    Cross List");
    println(
        "---------- ------------------------------------- ------ ------------------------------- ----- ----- ----- ---------- ----------");
    println(
        rpad(co.getCourseName(), 10)
            + " "
            + rpad(title, 37)
            + (title.length() > 37 ? "-" : " ")
            + " "
            + rpad(co.getCredit() == null ? "" : co.getCredit().creditAbbv(), 5)
            + " "
            + rpad(courseOrg, 31)
            + " "
            + lpad(courseLimit <= 0 ? unlimited ? "  inf" : "" : String.valueOf(courseLimit), 5)
            + " "
            + lpad(enrl <= 0 ? "" : String.valueOf(enrl), 5)
            + " "
            + lpad(lastLikeEnrl <= 0 ? "" : String.valueOf(lastLikeEnrl), 5)
            + " "
            + rpad(co.getConsentType() == null ? "" : co.getConsentType().getAbbv(), 10)
            + " "
            + rpad(offering.getCourseOfferings().size() > 1 ? offering.getCourseName() : "", 10));
    while (title.length() > 37) {
      title = title.substring(37);
      println("           " + rpad(title, 37) + (title.length() > 37 ? "-" : " "));
    }
    if (co.getScheduleBookNote() != null && co.getScheduleBookNote().trim().length() > 0) {
      String note = co.getScheduleBookNote();
      note = note.replaceAll("\\. ", "\\.\n");
      for (StringTokenizer s = new StringTokenizer(note, "\n\r"); s.hasMoreTokens(); ) {
        String line = s.nextToken().trim();
        while (line.length() > sNrChars - 7) {
          println("   " + line.substring(0, sNrChars - 7) + "-");
          line = line.substring(sNrChars - 7);
        }
        println("   " + line);
      }
    }
    if (iLineNo + 5 >= sNrLines) newPage();
    else println("");
    println("        " + s1 + "   " + s2 + "  Proj | Type");
    println(
        "Curr  Reqst  Enrl  Enrl | Instr Number Time                                     Limit Bldg-Room          Instructor            Mgr");
    println(
        "----  -----  ----  ---- | ----- ------ ---------------------------------------- ----- ------------------ --------------------- ------");

    Vector rTable = new Vector();
    // TODO: Print request data based on curricula
    /*
    int a=0,b=0,c=0;
    for (Iterator i=co.getAcadAreaReservations().iterator();i.hasNext();) {
        AcadAreaReservation ar = (AcadAreaReservation)i.next();
        rTable.add(
                lpad(ar.getAcademicArea().getAcademicAreaAbbreviation(),4)+"  "+
                lpad(ar.getRequested()==null?"":ar.getRequested().toString(),5)+" "+
                lpad(ar.getPriorEnrollment()==null?"":ar.getPriorEnrollment().toString(),5)+" "+
                lpad(ar.getProjectedEnrollment()==null?"":ar.getProjectedEnrollment().toString(),5));
        if (ar.getRequested()!=null) a+=ar.getRequested().intValue();
        if (ar.getPriorEnrollment()!=null) b+=ar.getPriorEnrollment().intValue();
        if (ar.getProjectedEnrollment()!=null) c+=ar.getProjectedEnrollment().intValue();
    }
    if (rTable.isEmpty()) {
        rTable.add(" *** No Request Data   ");
    } else {
        rTable.add(
                " Tot  "+
                lpad(String.valueOf(a),5)+" "+
                lpad(String.valueOf(b),5)+" "+
                lpad(String.valueOf(c),5));
        rTable.add("                       ");
        rTable.add(" *Please check requests");
    }
    */
    Vector cTable = new Vector();
    if (offering.isNotOffered().booleanValue()) cTable.add(" ** Course not offered");
    Vector gTable = new Vector();
    TreeSet configs = new TreeSet(new InstrOfferingConfigComparator(null));
    configs.addAll(offering.getInstrOfferingConfigs());
    for (Iterator i = configs.iterator(); i.hasNext(); ) {
      InstrOfferingConfig config = (InstrOfferingConfig) i.next();
      if (offering.getInstrOfferingConfigs().size() > 1)
        cTable.add("** Configuration " + config.getName());
      TreeSet subparts = new TreeSet(new SchedulingSubpartComparator());
      subparts.addAll(config.getSchedulingSubparts());
      for (Iterator j = subparts.iterator(); j.hasNext(); ) {
        SchedulingSubpart subpart = (SchedulingSubpart) j.next();
        TreeSet classes = new TreeSet(new ClassComparator(ClassComparator.COMPARE_BY_HIERARCHY));
        classes.addAll(subpart.getClasses());
        String subpartLabel = subpart.getItype().getAbbv();
        boolean same = false;
        for (Iterator k = classes.iterator(); k.hasNext(); ) {
          Class_ clazz = (Class_) k.next();
          String[] time = time(clazz);
          String[] rooms = room(clazz);
          String[] instr = instructor(clazz);
          for (int x = 0;
              x < Math.max(Math.max(1, time.length), Math.max(instr.length, rooms.length));
              x++) {
            cTable.add(
                rpad(same ? "" : x == 0 ? subpartLabel : "", 5)
                    + " "
                    + lpad(x == 0 ? clazz.getSectionNumberString() : "", 6)
                    + " "
                    + rpad(time != null && x < time.length ? time[x] : "", 40)
                    + " "
                    + lpad(
                        x == 0 && clazz.getClassLimit() > 0 && clazz.getNbrRooms().intValue() > 0
                            ? (clazz.getNbrRooms().intValue() > 1 ? clazz.getNbrRooms() + "x" : "")
                                + String.valueOf(clazz.getClassLimit())
                            : "",
                        5)
                    + " "
                    + rpad(rooms != null && x < rooms.length ? rooms[x] : "", 18)
                    + " "
                    + rpad(instr != null && x < instr.length ? instr[x] : "", 21)
                    + " "
                    + rpad(x == 0 ? clazz.getManagingDept().getShortLabel() : "", 6));
          }
          same = true;
          if (clazz.getParentClass() != null && clazz.getChildClasses().isEmpty()) {
            String gr =
                clazz.getSchedulingSubpart().getItype().getAbbv().trim()
                    + lpad(clazz.getSectionNumberString(), 4);
            Class_ parent = clazz.getParentClass();
            while (parent != null) {
              gr =
                  parent.getSchedulingSubpart().getItype().getAbbv().trim()
                      + lpad(parent.getSectionNumberString(), 4)
                      + ", "
                      + gr;
              parent = parent.getParentClass();
            }
            gTable.add(gr);
          }
        }
      }
    }
    for (int i = 0; i < 1 + Math.max(rTable.size(), cTable.size()); i++) {
      String res = null;
      String cl = null;
      if (i < rTable.size()) res = (String) rTable.elementAt(i);
      if (i < cTable.size()) cl = (String) cTable.elementAt(i);
      println(rpad(res, 23) + " | " + (cl == null ? "" : cl));
    }
    if (!gTable.isEmpty()) {
      println(rep('-', sNrChars));
      println("     Course groups:");
      int half = (gTable.size() + 1) / 2;
      for (int i = 0; i < half; i++) {
        String gr1 = (String) gTable.elementAt(i);
        String gr2 = (half + i < gTable.size() ? (String) gTable.elementAt(half + i) : "");
        println("     " + rpad(gr1, 60) + " | " + rpad(gr2, 60));
      }
    }
    println(rep('=', sNrChars));
    iCourseOffering = null;
  }