コード例 #1
0
 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());
   }
 }
コード例 #2
0
  public int compare(Object o1, Object o2) {
    // Check if objects are of class Instructional Offering
    if (!(o1 instanceof CourseOffering)) {
      throw new ClassCastException("o1 Class must be of type CourseOffering");
    }
    if (!(o2 instanceof CourseOffering)) {
      throw new ClassCastException("o2 Class must be of type CourseOffering");
    }

    CourseOffering co1 = (CourseOffering) o1;
    CourseOffering co2 = (CourseOffering) o2;

    // Same Course Offering
    if (co1.getUniqueId().equals(co2.getUniqueId())) {
      return 0;
    }

    // One of the offerings is a Controlling Course
    if (compareBy == COMPARE_BY_CTRL_CRS) {
      if (co1.isIsControl().booleanValue()) return -1;
      if (co2.isIsControl().booleanValue()) return 1;
    }

    // Compare by course name (also used if neither is controlling)
    if (co1.getSubjectAreaAbbv().equals(co2.getSubjectAreaAbbv())) {
      if (co1.getCourseNbr().equals(co2.getCourseNbr())) {
        if (co1.getTitle() == null && co2.getTitle() == null) {
          return (0);
        } else if (co1.getTitle() == null) {
          return (-1);
        } else if (co2.getTitle() == null) {
          return (1);
        }
        return (co1.getTitle().compareTo(co2.getTitle()));
      } else {
        return (co1.getCourseNbr().compareTo(co2.getCourseNbr()));
      }
    } else {
      return (co1.getSubjectAreaAbbv().compareTo(co2.getSubjectAreaAbbv()));
    }
  }