@Override public Set<WeightedStudentId> getDemands(CourseOffering course) { Hashtable<Long, Set<WeightedStudentId>> demands = iDemands.get(course.getSubjectArea().getUniqueId()); if (demands == null) { demands = loadDemandsForSubjectArea(course.getSubjectArea()); iDemands.put(course.getSubjectArea().getUniqueId(), demands); } return demands.get(course.getUniqueId()); }
private void loadCourseOfferings(Long sessionId) { for (Iterator it = CourseOffering.findAll(sessionId).iterator(); it.hasNext(); ) { CourseOffering offer = (CourseOffering) it.next(); if (offer.getPermId() != null) { courseOfferings.put( offer.getCourseNbr() + offer.getSubjectArea().getUniqueId().toString(), offer.getPermId()); } externalIdSubjectArea.put(offer.getExternalUniqueId(), offer.getSubjectArea()); externalIdCourseNumber.put(offer.getExternalUniqueId(), offer.getCourseNbr()); externalIdCoursePermId.put(offer.getExternalUniqueId(), offer.getPermId()); } }
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; }
public void csvTableForClasses( PrintWriter out, ClassAssignmentProxy classAssignment, ExamAssignmentProxy examAssignment, ClassAssignmentsReportForm form, SessionContext context) throws Exception { setVisibleColumns(form); Collection classes = (Collection) form.getClasses(); if (isShowTimetable()) { boolean hasTimetable = false; if (context.hasPermission(Right.ClassAssignments) && classAssignment != null) { if (classAssignment instanceof CachedClassAssignmentProxy) { ((CachedClassAssignmentProxy) classAssignment).setCache(classes); } for (Iterator i = classes.iterator(); i.hasNext(); ) { Object[] o = (Object[]) i.next(); Class_ clazz = (Class_) o[0]; if (classAssignment.getAssignment(clazz) != null) { hasTimetable = true; break; } } } setDisplayTimetable(hasTimetable); } setUserSettings(context.getUser()); if (examAssignment != null || Exam.hasTimetable(context.getUser().getCurrentAcademicSessionId())) { setShowExam(true); setShowExamTimetable(true); setShowExamName(false); } setShowInstructor(true); if (StudentClassEnrollment.sessionHasEnrollments( context.getUser().getCurrentAcademicSessionId())) { setShowDemand(true); } iFile = new CSVFile(); int ct = 0; Iterator it = classes.iterator(); SubjectArea subjectArea = null; String prevLabel = null; while (it.hasNext()) { Object[] o = (Object[]) it.next(); Class_ c = (Class_) o[0]; CourseOffering co = (CourseOffering) o[1]; if (subjectArea == null || !subjectArea.getUniqueId().equals(co.getSubjectArea().getUniqueId())) { if (iFile.getLines() != null) iFile.addLine(); subjectArea = co.getSubjectArea(); ct = 0; iFile.addLine(labelForTable(subjectArea)); csvBuildTableHeader(context.getUser().getCurrentAcademicSessionId()); } csvBuildClassRow(classAssignment, examAssignment, ++ct, co, c, "", context, prevLabel); prevLabel = c.getClassLabel(co); } save(out); }