예제 #1
0
 public String getNameHtml() {
   return "<span onmouseover=\"showGwtTimeHint(this, '"
       + iClassId
       + ","
       + iDayCode
       + ","
       + iStartSlot
       + "');\" onmouseout=\"hideGwtTimeHint();\""
       + " style='color:"
       + PreferenceLevel.int2color(getPreference())
       + ";'>"
       + getName()
       + "</span>";
 }
예제 #2
0
 private String[] room(Class_ clazz) {
   Assignment assgn = (iUseCommitedAssignments ? clazz.getCommittedAssignment() : null);
   if (assgn == null || assgn.getRoomLocations().isEmpty()) {
     List<RoomLocation> roomLocations = TimetableDatabaseLoader.computeRoomLocations(clazz);
     if (roomLocations.size() == clazz.getNbrRooms().intValue()) {
       String[] rooms = new String[roomLocations.size()];
       for (int x = 0; x < roomLocations.size(); x++) {
         RoomLocation r = (RoomLocation) roomLocations.get(x);
         rooms[x] = r.getName();
       }
       return rooms;
     }
     Vector roomPrefs = new Vector();
     boolean allRoomReq = true;
     for (Iterator i = clazz.effectivePreferences(BuildingPref.class).iterator(); i.hasNext(); ) {
       Preference pref = (Preference) i.next();
       roomPrefs.add(
           PreferenceLevel.prolog2abbv(pref.getPrefLevel().getPrefProlog())
               + " "
               + pref.preferenceText());
       allRoomReq = false;
     }
     for (Iterator i = clazz.effectivePreferences(RoomPref.class).iterator(); i.hasNext(); ) {
       Preference pref = (Preference) i.next();
       roomPrefs.add(
           PreferenceLevel.prolog2abbv(pref.getPrefLevel().getPrefProlog())
               + " "
               + pref.preferenceText());
       if (!PreferenceLevel.sRequired.equals(pref.getPrefLevel().getPrefProlog()))
         allRoomReq = false;
     }
     for (Iterator i = clazz.effectivePreferences(RoomFeaturePref.class).iterator();
         i.hasNext(); ) {
       Preference pref = (Preference) i.next();
       roomPrefs.add(
           PreferenceLevel.prolog2abbv(pref.getPrefLevel().getPrefProlog())
               + " "
               + pref.preferenceText());
       allRoomReq = false;
     }
     for (Iterator i = clazz.effectivePreferences(RoomGroupPref.class).iterator(); i.hasNext(); ) {
       Preference pref = (Preference) i.next();
       roomPrefs.add(
           PreferenceLevel.prolog2abbv(pref.getPrefLevel().getPrefProlog())
               + " "
               + pref.preferenceText());
       allRoomReq = false;
     }
     if (allRoomReq) {
       roomPrefs.clear();
       for (Iterator i = clazz.effectivePreferences(RoomPref.class).iterator(); i.hasNext(); ) {
         Preference pref = (Preference) i.next();
         roomPrefs.add(pref.preferenceText());
       }
     }
     String[] rooms = new String[roomPrefs.size()];
     for (int x = 0; x < roomPrefs.size(); x++) {
       rooms[x] = roomPrefs.elementAt(x).toString();
     }
     return rooms;
   }
   String[] rooms = new String[assgn.getRoomLocations().size()];
   for (int x = 0; x < assgn.getRoomLocations().size(); x++) {
     RoomLocation r = (RoomLocation) assgn.getRoomLocations().elementAt(x);
     rooms[x] = r.getName();
   }
   return rooms;
 }
예제 #3
0
  public PdfWebTable getTable(
      boolean html, boolean color, ExamReportForm form, Collection<ExamInfo> exams) {
    if (exams == null || exams.isEmpty()) return null;
    boolean timeVertical = RequiredTimeTable.getTimeGridVertical(sessionContext.getUser());
    boolean timeText = RequiredTimeTable.getTimeGridAsText(sessionContext.getUser());

    String nl = (html ? "<br>" : "\n");
    PdfWebTable table =
        new PdfWebTable(
            9,
            "Not-assigned Examinations",
            "unassignedExams.do?ord=%%",
            new String[] {
              (form.getShowSections() ? "Classes / Courses" : "Examination"),
              "Length",
              "Seating" + nl + "Type",
              "Size",
              "Max" + nl + "Rooms",
              "Instructor",
              "Period" + nl + "Preferences",
              "Room" + nl + "Preferences",
              "Distribution" + nl + "Preferences"
            },
            new String[] {
              "left", "right", "center", "right", "right", "left", "left", "left", "left"
            },
            new boolean[] {true, true, true, false, false, true, true, true, true});
    table.setRowStyle("white-space:nowrap");
    try {
      for (ExamInfo exam : exams) {
        String perPref = "", roomPref = "", distPref = "";

        if (html) {
          roomPref += exam.getExam().getEffectivePrefHtmlForPrefType(RoomPref.class);
          if (roomPref.length() > 0) roomPref += nl;
          roomPref += exam.getExam().getEffectivePrefHtmlForPrefType(BuildingPref.class);
          if (roomPref.length() > 0) roomPref += nl;
          roomPref += exam.getExam().getEffectivePrefHtmlForPrefType(RoomFeaturePref.class);
          if (roomPref.length() > 0) roomPref += nl;
          roomPref += exam.getExam().getEffectivePrefHtmlForPrefType(RoomGroupPref.class);
          if (roomPref.endsWith(nl))
            roomPref = roomPref.substring(0, roomPref.length() - nl.length());
          if (timeText) {
            perPref += exam.getExam().getEffectivePrefHtmlForPrefType(ExamPeriodPref.class);
          } else {
            if (exam.getExam().getExamType().getType() == ExamType.sExamTypeMidterm) {
              MidtermPeriodPreferenceModel epx =
                  new MidtermPeriodPreferenceModel(
                      exam.getExam().getSession(), exam.getExam().getExamType());
              epx.load(exam.getExam());
              perPref += epx.toString(true);
            } else {
              PeriodPreferenceModel px =
                  new PeriodPreferenceModel(exam.getExam().getSession(), exam.getExamTypeId());
              px.load(exam.getExam());
              perPref =
                  "<img border='0' src='pattern?v="
                      + (timeVertical ? 1 : 0)
                      + "&x="
                      + exam.getExamId()
                      + "' title='"
                      + px.toString()
                      + "'>";
            }
          }
          distPref += exam.getExam().getEffectivePrefHtmlForPrefType(DistributionPref.class);
        } else {
          for (Iterator j = exam.getExam().effectivePreferences(RoomPref.class).iterator();
              j.hasNext(); ) {
            Preference pref = (Preference) j.next();
            if (roomPref.length() > 0) roomPref += nl;
            roomPref +=
                (color
                        ? "@@COLOR "
                            + PreferenceLevel.prolog2color(pref.getPrefLevel().getPrefProlog())
                            + " "
                        : "")
                    + PreferenceLevel.prolog2abbv(pref.getPrefLevel().getPrefProlog())
                    + " "
                    + pref.preferenceText();
          }
          for (Iterator j = exam.getExam().effectivePreferences(BuildingPref.class).iterator();
              j.hasNext(); ) {
            Preference pref = (Preference) j.next();
            if (roomPref.length() > 0) roomPref += nl;
            roomPref +=
                (color
                        ? "@@COLOR "
                            + PreferenceLevel.prolog2color(pref.getPrefLevel().getPrefProlog())
                            + " "
                        : "")
                    + PreferenceLevel.prolog2abbv(pref.getPrefLevel().getPrefProlog())
                    + " "
                    + pref.preferenceText();
          }
          for (Iterator j = exam.getExam().effectivePreferences(RoomFeaturePref.class).iterator();
              j.hasNext(); ) {
            Preference pref = (Preference) j.next();
            if (roomPref.length() > 0) roomPref += nl;
            roomPref +=
                (color
                        ? "@@COLOR "
                            + PreferenceLevel.prolog2color(pref.getPrefLevel().getPrefProlog())
                            + " "
                        : "")
                    + PreferenceLevel.prolog2abbv(pref.getPrefLevel().getPrefProlog())
                    + " "
                    + pref.preferenceText();
          }
          for (Iterator j = exam.getExam().effectivePreferences(RoomGroupPref.class).iterator();
              j.hasNext(); ) {
            Preference pref = (Preference) j.next();
            if (roomPref.length() > 0) roomPref += nl;
            roomPref +=
                (color
                        ? "@@COLOR "
                            + PreferenceLevel.prolog2color(pref.getPrefLevel().getPrefProlog())
                            + " "
                        : "")
                    + PreferenceLevel.prolog2abbv(pref.getPrefLevel().getPrefProlog())
                    + " "
                    + pref.preferenceText();
          }
          if (ExamType.sExamTypeMidterm == exam.getExamType().getType()) {
            MidtermPeriodPreferenceModel epx =
                new MidtermPeriodPreferenceModel(exam.getExam().getSession(), exam.getExamType());
            epx.load(exam.getExam());
            perPref += epx.toString(false, true);
          } else {
            if (timeText || !color) {
              for (Iterator j =
                      exam.getExam().effectivePreferences(ExamPeriodPref.class).iterator();
                  j.hasNext(); ) {
                Preference pref = (Preference) j.next();
                if (perPref.length() > 0) perPref += nl;
                perPref +=
                    (color
                            ? "@@COLOR "
                                + PreferenceLevel.prolog2color(pref.getPrefLevel().getPrefProlog())
                                + " "
                            : "")
                        + PreferenceLevel.prolog2abbv(pref.getPrefLevel().getPrefProlog())
                        + " "
                        + pref.preferenceText();
              }
            } else {
              PeriodPreferenceModel px =
                  new PeriodPreferenceModel(
                      exam.getExam().getSession(), exam.getExamType().getUniqueId());
              px.load(exam.getExam());
              RequiredTimeTable rtt = new RequiredTimeTable(px);
              Image image = rtt.createBufferedImage(timeVertical);
              if (image != null) {
                table.addImage(exam.getExamId().toString(), image);
                perPref += "@@IMAGE " + exam.getExamId().toString() + " ";
              } else {
                for (Iterator j =
                        exam.getExam().effectivePreferences(ExamPeriodPref.class).iterator();
                    j.hasNext(); ) {
                  Preference pref = (Preference) j.next();
                  if (perPref.length() > 0) perPref += nl;
                  perPref +=
                      (color
                              ? "@@COLOR "
                                  + PreferenceLevel.prolog2color(
                                      pref.getPrefLevel().getPrefProlog())
                                  + " "
                              : "")
                          + PreferenceLevel.prolog2abbv(pref.getPrefLevel().getPrefProlog())
                          + " "
                          + pref.preferenceText();
                }
              }
            }
          }
          for (Iterator j = exam.getExam().effectivePreferences(DistributionPref.class).iterator();
              j.hasNext(); ) {
            DistributionPref pref = (DistributionPref) j.next();
            if (distPref.length() > 0) distPref += nl;
            distPref +=
                (color
                        ? "@@COLOR "
                            + PreferenceLevel.prolog2color(pref.getPrefLevel().getPrefProlog())
                            + " "
                        : "")
                    + PreferenceLevel.prolog2abbv(pref.getPrefLevel().getPrefProlog())
                    + " "
                    + pref.preferenceText(true, true, " (", ", ", ")")
                        .replaceAll("&lt;", "<")
                        .replaceAll("&gt;", ">");
          }
        }

        String instructors = exam.getInstructorName(", ");

        table.addLine(
            "onClick=\"showGwtDialog('Examination Assignment', 'examInfo.do?examId="
                + exam.getExamId()
                + "','900','90%');\"",
            new String[] {
              (html ? "<a name='" + exam.getExamId() + "'>" : "")
                  + (form.getShowSections() ? exam.getSectionName(nl) : exam.getExamName())
                  + (html ? "</a>" : ""),
              String.valueOf(exam.getLength()),
              (Exam.sSeatingTypeNormal == exam.getSeatingType() ? "Normal" : "Exam"),
              String.valueOf(exam.getNrStudents()),
              String.valueOf(exam.getMaxRooms()),
              instructors,
              perPref,
              roomPref,
              distPref
            },
            new Comparable[] {
              exam,
              exam.getLength(),
              exam.getSeatingType(),
              exam.getNrStudents(),
              exam.getMaxRooms(),
              instructors,
              perPref,
              roomPref,
              distPref
            },
            exam.getExamId().toString());
      }
    } catch (Exception e) {
      Debug.error(e);
      table.addLine(new String[] {"<font color='red'>ERROR:" + e.getMessage() + "</font>"}, null);
    }
    return table;
  }
예제 #4
0
 private String[] time(Class_ clazz) {
   String dpat = "";
   DatePattern dp = clazz.effectiveDatePattern();
   if (dp != null && !dp.isDefault()) {
     if (dp.getType().intValue() == DatePattern.sTypeAlternate) dpat = " " + dp.getName();
     else {
       SimpleDateFormat dpf = new SimpleDateFormat("MM/dd");
       dpat = ", " + dpf.format(dp.getStartDate()) + " - " + dpf.format(dp.getEndDate());
     }
   }
   Assignment assgn = (iUseCommitedAssignments ? clazz.getCommittedAssignment() : null);
   if (assgn == null) {
     Set timePrefs = clazz.getEffectiveTimePreferences();
     if (timePrefs.isEmpty()) {
       if (clazz.getSchedulingSubpart().getMinutesPerWk().intValue() > 0)
         return new String[] {
           "Arr "
               + ((clazz.getSchedulingSubpart().getMinutesPerWk().intValue() + 59) / 60)
               + " Hrs"
               + dpat
         };
       else return new String[] {"Arr Hrs" + dpat};
     }
     boolean onlyOneReq = true;
     TimeLocation req = null;
     for (Iterator x = timePrefs.iterator(); onlyOneReq && x.hasNext(); ) {
       TimePref tp = (TimePref) x.next();
       TimePatternModel model = tp.getTimePatternModel();
       if (model.isExactTime()) {
         if (req != null) onlyOneReq = false;
         else {
           int length =
               ExactTimeMins.getNrSlotsPerMtg(
                   model.getExactDays(),
                   clazz.getSchedulingSubpart().getMinutesPerWk().intValue());
           int breakTime =
               ExactTimeMins.getBreakTime(
                   model.getExactDays(),
                   clazz.getSchedulingSubpart().getMinutesPerWk().intValue());
           req =
               new TimeLocation(
                   model.getExactDays(),
                   model.getExactStartSlot(),
                   length,
                   PreferenceLevel.sIntLevelNeutral,
                   0,
                   dp.getUniqueId(),
                   dp.getName(),
                   dp.getPatternBitSet(),
                   breakTime);
         }
       } else {
         for (int d = 0; d < model.getNrDays(); d++)
           for (int t = 0; onlyOneReq && t < model.getNrTimes(); t++) {
             if (PreferenceLevel.sRequired.equals(model.getPreference(d, t))) {
               if (req != null) onlyOneReq = false;
               else {
                 req =
                     new TimeLocation(
                         model.getDayCode(d),
                         model.getStartSlot(t),
                         model.getSlotsPerMtg(),
                         PreferenceLevel.prolog2int(model.getPreference(d, t)),
                         0,
                         dp.getUniqueId(),
                         dp.getName(),
                         dp.getPatternBitSet(),
                         model.getBreakTime());
               }
             }
           }
       }
     }
     if (onlyOneReq && req != null)
       return new String[] {
         req.getDayHeader()
             + " "
             + req.getStartTimeHeader(CONSTANTS.useAmPm())
             + " - "
             + req.getEndTimeHeader(CONSTANTS.useAmPm())
             + dpat
       };
     Vector t = new Vector();
     for (Iterator x = timePrefs.iterator(); x.hasNext(); ) {
       TimePref tp = (TimePref) x.next();
       String tx = tp.getTimePatternModel().toString();
       for (StringTokenizer s = new StringTokenizer(tx, ","); s.hasMoreTokens(); )
         t.add(s.nextToken().trim());
     }
     String[] time = new String[t.size()];
     for (int x = 0; x < time.length; x++) time[x] = t.elementAt(x) + dpat;
     return time;
   }
   TimeLocation t = assgn.getTimeLocation();
   return new String[] {
     t.getDayHeader()
         + " "
         + t.getStartTimeHeader(CONSTANTS.useAmPm())
         + " - "
         + t.getEndTimeHeader(CONSTANTS.useAmPm())
         + dpat
   };
 }