コード例 #1
0
ファイル: PdfWorksheet.java プロジェクト: so0orena/unitime
 public static boolean print(
     OutputStream out, Collection<SubjectArea> subjectAreas, String courseNumber)
     throws IOException, DocumentException {
   TreeSet courses =
       new TreeSet(
           new Comparator() {
             public int compare(Object o1, Object o2) {
               CourseOffering co1 = (CourseOffering) o1;
               CourseOffering co2 = (CourseOffering) o2;
               int cmp = co1.getCourseName().compareTo(co2.getCourseName());
               if (cmp != 0) return cmp;
               return co1.getUniqueId().compareTo(co2.getUniqueId());
             }
           });
   String subjectIds = "";
   for (SubjectArea sa : subjectAreas)
     subjectIds += (subjectIds.isEmpty() ? "" : ",") + sa.getUniqueId();
   String query =
       "select co from CourseOffering co where  co.subjectArea.uniqueId in (" + subjectIds + ")";
   if (courseNumber != null && !courseNumber.trim().isEmpty()) {
     query += " and co.courseNbr ";
     if (courseNumber.indexOf('*') >= 0)
       query += " like '" + courseNumber.trim().replace('*', '%').toUpperCase() + "'";
     else query += " = '" + courseNumber.trim().toUpperCase() + "'";
   }
   courses.addAll(new SessionDAO().getSession().createQuery(query).list());
   if (courses.isEmpty()) return false;
   PdfWorksheet w = new PdfWorksheet(out, subjectAreas, courseNumber);
   for (Iterator i = courses.iterator(); i.hasNext(); ) {
     w.print((CourseOffering) i.next());
   }
   w.lastPage();
   w.close();
   return true;
 }
コード例 #2
0
ファイル: PdfWorksheet.java プロジェクト: so0orena/unitime
 public static boolean print(OutputStream out, Collection<SubjectArea> subjectAreas)
     throws IOException, DocumentException {
   TreeSet courses =
       new TreeSet(
           new Comparator() {
             public int compare(Object o1, Object o2) {
               CourseOffering co1 = (CourseOffering) o1;
               CourseOffering co2 = (CourseOffering) o2;
               int cmp = co1.getCourseName().compareTo(co2.getCourseName());
               if (cmp != 0) return cmp;
               return co1.getUniqueId().compareTo(co2.getUniqueId());
             }
           });
   String subjectIds = "";
   for (SubjectArea sa : subjectAreas)
     subjectIds += (subjectIds.isEmpty() ? "" : ",") + sa.getUniqueId();
   courses.addAll(
       SessionDAO.getInstance()
           .getSession()
           .createQuery(
               "select co from CourseOffering co where  co.subjectArea.uniqueId in ("
                   + subjectIds
                   + ")")
           .list());
   if (courses.isEmpty()) return false;
   PdfWorksheet w = new PdfWorksheet(out, subjectAreas, null);
   for (Iterator i = courses.iterator(); i.hasNext(); ) {
     w.print((CourseOffering) i.next());
   }
   w.lastPage();
   w.close();
   return true;
 }