public TimePattern getTimePattern() {
   if (iTimePattern == null) iTimePattern = TimePatternDAO.getInstance().get(iTimePatternId);
   return iTimePattern;
 }
 public TimePattern getTimePattern(org.hibernate.Session hibSession) {
   return TimePatternDAO.getInstance().get(iTimePatternId, hibSession);
 }
Exemple #3
0
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    boolean vertical = "1".equals(request.getParameter("v"));
    RequiredTimeTable rtt = null;
    if (request.getParameter("tp") != null) {
      TimePattern p = TimePatternDAO.getInstance().get(Long.valueOf(request.getParameter("tp")));
      if (p != null) {
        TimeLocation t = null;
        if (request.getParameter("as") != null && request.getParameter("ad") != null) {
          t =
              new TimeLocation(
                  Integer.parseInt(request.getParameter("ad")),
                  Integer.parseInt(request.getParameter("as")),
                  1,
                  0,
                  0,
                  null,
                  null,
                  null,
                  0);
        }
        rtt = new RequiredTimeTable(p.getTimePatternModel(t, true));
      }
    } else if (request.getParameter("loc") != null) {
      Location location = LocationDAO.getInstance().get(Long.valueOf(request.getParameter("loc")));
      if (location != null) {
        if (request.getParameter("xt") != null) {
          PeriodPreferenceModel px =
              new PeriodPreferenceModel(
                  location.getSession(), Long.valueOf(request.getParameter("xt")));
          px.load(location);
          rtt = new RequiredTimeTable(px);
        } else {
          if ("1".equals(request.getParameter("e"))) rtt = location.getEventAvailabilityTable();
          else rtt = location.getRoomSharingTable();
        }
      }
    } else if (request.getParameter("x") != null) {
      Exam exam = ExamDAO.getInstance().get(Long.valueOf(request.getParameter("x")));
      if (exam != null) {
        ExamPeriod p = null;
        if (request.getParameter("ap") != null)
          p = ExamPeriodDAO.getInstance().get(Long.valueOf(request.getParameter("ap")));
        PeriodPreferenceModel px =
            new PeriodPreferenceModel(exam.getSession(), p, exam.getExamType().getUniqueId());
        px.load(exam);
        rtt = new RequiredTimeTable(px);
      }
    } else {
      rtt = new RequiredTimeTable(new TimePattern().getTimePatternModel());
    }
    if (rtt != null) {
      if (request.getParameter("s") != null) {
        try {
          rtt.getModel().setDefaultSelection(Integer.parseInt(request.getParameter("s")));
        } catch (NumberFormatException e) {
          rtt.getModel().setDefaultSelection(request.getParameter("s"));
        }
      }
      if (request.getParameter("p") != null)
        rtt.getModel().setPreferences(request.getParameter("p"));
      boolean hc = ("1".equals(request.getParameter("hc")));

      response.setContentType("image/png");
      response.setHeader("Content-Disposition", "attachment; filename=\"pattern.png\"");
      BufferedImage image = rtt.createBufferedImage(vertical, hc);
      if (image != null) ImageIO.write(image, "PNG", response.getOutputStream());
    }
  }