Example #1
0
  private void writeLineForExecutionCourseAndExamOfSeason(
      StringBuilder strBuffer, InfoExecutionCourse infoExecutionCourse, int season) {
    for (int j = 0; j < infoExecutionCourse.getAssociatedInfoExams().size(); j++) {
      InfoExam infoExam = infoExecutionCourse.getAssociatedInfoExams().get(j);
      if (infoExam.getSeason().getSeason().intValue() == season) {
        strBuffer.append("<td>" + season + "&ordf; </td>");
        strBuffer.append("<td>" + infoExam.getDate() + "</td>");
        strBuffer.append("<td>" + infoExam.getBeginningHour() + "</td>");
        strBuffer.append("<td>" + infoExam.getEndHour() + "</td>");
        strBuffer.append("<td>");
        ComparatorChain comparatorChain = new ComparatorChain();
        comparatorChain.addComparator(new BeanComparator("infoRoom.capacidadeExame"), true);
        comparatorChain.addComparator(new BeanComparator("infoRoom.nome"));
        Collections.sort(infoExam.getWrittenEvaluationSpaceOccupations(), comparatorChain);
        for (int k = 0; k < infoExam.getWrittenEvaluationSpaceOccupations().size(); k++) {
          if (k > 0) {
            strBuffer.append(" ");
          }

          InfoRoomOccupation infoRoomOccupation =
              infoExam.getWrittenEvaluationSpaceOccupations().get(k);
          strBuffer.append(infoRoomOccupation.getInfoRoom().getNome());
        }
        strBuffer.append("</td>");
      }
    }
  }
Example #2
0
  private void renderExamsExecutionCourseTableForYear(
      StringBuilder strBuffer, Integer year, PageContext pageContext) {
    // PRINT EXECUTION DEGREE
    strBuffer.append(
        "<strong>"
            + examsMap
                .getInfoExecutionDegree()
                .getInfoDegreeCurricularPlan()
                .getInfoDegree()
                .getNome()
            + "</strong><br />");
    strBuffer.append("<strong>" + year + "&ordm; ");
    strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.year"));
    strBuffer.append("</strong>");
    if (!examsMap.getExecutionCourses().isEmpty()) {
      strBuffer.append(
          " - <strong>"
              + ((InfoExecutionCourse) examsMap.getExecutionCourses().iterator().next())
                  .getInfoExecutionPeriod()
                  .getSemester()
              + "&ordm; ");
      strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.semester"));
      strBuffer.append("</strong>");
    }
    strBuffer.append(
        " - <strong>"
            + examsMap.getInfoExecutionDegree().getInfoExecutionYear().getYear()
            + "</strong><br />");
    strBuffer.append("<table border='1' cellspacing='0' cellpadding='3' width='95%'>");

    renderExamsTableHeader(strBuffer, pageContext);

    Collections.sort(examsMap.getExecutionCourses(), new BeanComparator("nome"));

    for (int i = 0; i < examsMap.getExecutionCourses().size(); i++) {
      InfoExecutionCourse infoExecutionCourse =
          (InfoExecutionCourse) examsMap.getExecutionCourses().get(i);
      if (infoExecutionCourse.getCurricularYear().equals(year)
          && !infoExecutionCourse.getAssociatedInfoExams().isEmpty()) {
        strBuffer.append("<tr>");
        strBuffer.append("<td rowspan='2'>");
        strBuffer.append(infoExecutionCourse.getNome());
        strBuffer.append("</td>");

        writeLineForExecutionCourseAndExamOfSeason(strBuffer, infoExecutionCourse, Season.SEASON1);
        strBuffer.append("</tr>");

        strBuffer.append("<tr>");
        writeLineForExecutionCourseAndExamOfSeason(strBuffer, infoExecutionCourse, Season.SEASON2);
        strBuffer.append("</tr>");
      }
    }

    strBuffer.append("</table>");
  }
  @Atomic
  public static List run(
      String executionDegreeId, String executionPeriodId, Integer curricularYearInt)
      throws FenixServiceException {

    if (executionPeriodId == null) {
      throw new FenixServiceException("nullExecutionPeriodId");
    }

    final ExecutionSemester executionSemester = FenixFramework.getDomainObject(executionPeriodId);

    final List<ExecutionCourse> executionCourseList;
    if (executionDegreeId == null && curricularYearInt == null) {
      executionCourseList = executionSemester.getExecutionCoursesWithNoCurricularCourses();
    } else {
      final ExecutionDegree executionDegree =
          findExecutionDegreeByID(executionSemester, executionDegreeId);
      final DegreeCurricularPlan degreeCurricularPlan = executionDegree.getDegreeCurricularPlan();
      final CurricularYear curricularYear = CurricularYear.readByYear(curricularYearInt);
      executionCourseList =
          executionSemester
              .getExecutionCoursesByDegreeCurricularPlanAndSemesterAndCurricularYearAndName(
                  degreeCurricularPlan, curricularYear, "%");
    }

    final List infoExecutionCourseList = new ArrayList(executionCourseList.size());
    for (final ExecutionCourse executionCourse : executionCourseList) {
      infoExecutionCourseList.add(InfoExecutionCourse.newInfoFromDomain(executionCourse));
    }

    return infoExecutionCourseList;
  }
  public void validateResponsibleForList(
      Teacher teacher, ExecutionCourse executionCourse, Professorship responsibleForAdded)
      throws MaxResponsibleForExceed, InvalidCategory {

    List responsibleFors = executionCourse.responsibleFors();

    if ((!responsibleFors.contains(responsibleForAdded))
        && (responsibleFors.size() >= MAX_RESPONSIBLEFOR_BY_EXECUTION_COURSE)) {
      List infoResponsibleFors =
          (List)
              CollectionUtils.collect(
                  responsibleFors,
                  new Transformer() {

                    @Override
                    public Object transform(Object input) {
                      Professorship responsibleFor = (Professorship) input;
                      InfoProfessorship infoResponsibleFor =
                          InfoProfessorship.newInfoFromDomain(responsibleFor);
                      return infoResponsibleFor;
                    }
                  });

      InfoExecutionCourse infoExecutionCourse =
          InfoExecutionCourse.newInfoFromDomain(executionCourse);
      throw new MaxResponsibleForExceed(infoExecutionCourse, infoResponsibleFors);
    }
  }
Example #5
0
  public ActionForward prepare(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    ContextUtils.setCurricularYearsContext(request);

    Integer executionCourseOID =
        ((InfoExecutionCourse) request.getAttribute(PresentationConstants.EXECUTION_COURSE))
            .getIdInternal();

    InfoExecutionCourse executionCourse;
    try {
      executionCourse = ReadExecutionCourseWithAssociatedCurricularCourses.run(executionCourseOID);
    } catch (Exception ex) {
      throw new Exception(ex);
    }
    List executionCourseList = new ArrayList();

    executionCourseList.add(executionCourse);

    request.setAttribute(PresentationConstants.EXECUTION_COURSES_LIST, executionCourseList);

    String nextPage = request.getParameter("nextPage");
    request.setAttribute(PresentationConstants.NEXT_PAGE, nextPage);

    List examSeasons = Util.getExamSeasons();
    request.setAttribute(PresentationConstants.LABLELIST_SEASONS, examSeasons);

    DynaValidatorForm createExamForm = (DynaValidatorForm) form;
    String[] executionCourseIDList = {executionCourse.getIdInternal().toString()};
    createExamForm.set("executionCourses", executionCourseIDList);

    List scopeIDList = new ArrayList();
    Iterator iter1 = executionCourse.getAssociatedInfoCurricularCourses().iterator();
    while (iter1.hasNext()) {
      Iterator iter2 = ((InfoCurricularCourse) iter1.next()).getInfoScopes().iterator();
      while (iter2.hasNext()) {
        scopeIDList.add(((InfoCurricularCourseScope) iter2.next()).getIdInternal().toString());
      }
    }
    String[] scopeIDArray = CollectionUtils.toArrayOfString(scopeIDList);
    createExamForm.set("scopes", scopeIDArray);

    return mapping.findForward("showCreateForm");
  }
Example #6
0
  private void renderExecutionCourseListForYear(
      StringBuilder strBuffer, Integer curricularYear, PageContext pageContext) {
    if (!examsMap.hasExecutionCoursesForGivenCurricularYear(curricularYear)) {
      strBuffer
          .append("<i>")
          .append(getMessageResource(pageContext, "no.execution.courses.for.curricular.year"))
          .append(curricularYear)
          .append("</i>");
    } else {
      if (user.equals("public")) {
        strBuffer.append("<table class='tab_exams_details' cellspacing='0'>");
        strBuffer.append("<tr><th rowspan='2' width='250' class='ordYear'>");
        strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.year"));
        strBuffer.append(" ");
        strBuffer.append(curricularYear);
        strBuffer.append("</th>");
        strBuffer.append("<th colspan='3' width='250'>");
        strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.times"));
        strBuffer.append(" 1");
        strBuffer.append("</th>");
        strBuffer.append("<th colspan='3'>");
        strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.times"));
        strBuffer.append(" 2");
        strBuffer.append("</th></tr>");
        strBuffer.append("<tr><td class='subheader' width='70'>");
        strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.day"));
        strBuffer.append("</td><td class='subheader' width='50'>");
        strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.hour"));
        strBuffer.append("</td><td class='subheader' width='130'>");
        strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.room"));
        strBuffer.append("</td>");
        strBuffer.append("<td class='subheader' width='70'>");
        strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.day"));
        strBuffer.append("</td>" + "<td class='subheader' width='50'>");
        strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.hour"));
        strBuffer.append("</td><td class='subheader' width='130'>");
        strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.room"));
        strBuffer.append("</td></tr>");
      } else {
        strBuffer.append("<strong>");
        strBuffer.append(
            getMessageResource(pageContext, "public.degree.information.label.courseOf"));
        strBuffer.append(curricularYear + "&ordm; ano:</strong>");
      }

      Collections.sort(examsMap.getExecutionCourses(), new BeanComparator("sigla"));
      String rowClass = "notFirstRow"; // used for CSS style
      for (int i = 0; i < examsMap.getExecutionCourses().size(); i++) {
        InfoExecutionCourse infoExecutionCourse =
            (InfoExecutionCourse) examsMap.getExecutionCourses().get(i);

        if (user.equals("sop")) {
          strBuffer.append("<table border='1' cellspacing='0' cellpadding='3' width='95%'>");
          strBuffer.append("<tr>");
        }

        if (i == 0) {
          rowClass = "firstRow";
        }

        if (infoExecutionCourse.getCurricularYear().equals(curricularYear)) {
          boolean showCreateExamLink = infoExecutionCourse.getAssociatedInfoExams().size() < 2;
          if (user.equals("sop")) {
            strBuffer.append("<td colspan='6'>");
          }

          if (user.equals("public")) {
            strBuffer.append("<tr valign='top'>");
            strBuffer.append("<td class='" + rowClass + "'>");

            final Site site = infoExecutionCourse.getExecutionCourse().getSite();
            strBuffer.append(GenericChecksumRewriter.NO_CHECKSUM_PREFIX);
            strBuffer
                .append("<a href=\"")
                .append(((HttpServletRequest) pageContext.getRequest()).getContextPath());
            strBuffer.append(site.getReversePath());
            strBuffer.append("\">");

          } else if (showCreateExamLink && user.equals("sop")) {
            strBuffer.append(
                "<a href='"
                    + addPublicPrefix("showExamsManagement.do")
                    + "?method=createByCourse&amp;"
                    + PresentationConstants.EXECUTION_COURSE_OID
                    + "="
                    + infoExecutionCourse.getExternalId()
                    + "&amp;"
                    + PresentationConstants.EXECUTION_PERIOD_OID
                    + "="
                    + infoExecutionCourse.getInfoExecutionPeriod().getExternalId()
                    + "&amp;"
                    + PresentationConstants.EXECUTION_DEGREE_OID
                    + "="
                    + examsMap.getInfoExecutionDegree().getExternalId()
                    + "&amp;"
                    + PresentationConstants.CURRICULAR_YEAR_OID
                    + "="
                    + curricularYear.toString()
                    + "'>");
          }

          strBuffer.append(infoExecutionCourse.getSigla());
          strBuffer.append(" - ");
          strBuffer.append(infoExecutionCourse.getNome());

          if (user.equals("public")) {
            strBuffer.append("</a>");
            strBuffer.append("</td>");
          }

          boolean hasComment =
              infoExecutionCourse.getComment() != null
                  && infoExecutionCourse.getComment().length() > 0
                  && !infoExecutionCourse.getComment().equals(" ");

          if (hasComment) {
            if (user.equals("sop")) {
              strBuffer.append(" : ");
              strBuffer.append(
                  "<a href='" + addPublicPrefix("defineComment.do") + "?executionCourseCode=");
              strBuffer.append(infoExecutionCourse.getSigla());
              strBuffer.append(
                  "&amp;executionPeriodName="
                      + infoExecutionCourse.getInfoExecutionPeriod().getName());
              strBuffer.append(
                  "&amp;executionYear="
                      + infoExecutionCourse
                          .getInfoExecutionPeriod()
                          .getInfoExecutionYear()
                          .getYear());
              strBuffer.append("&amp;comment=" + infoExecutionCourse.getComment());
              strBuffer.append("&amp;method=prepare");
              strBuffer.append("&amp;indexExecutionCourse=" + i);
              strBuffer.append(
                  "&amp;"
                      + PresentationConstants.EXECUTION_PERIOD_OID
                      + "="
                      + infoExecutionCourse.getInfoExecutionPeriod().getExternalId()
                      + "&amp;"
                      + PresentationConstants.EXECUTION_DEGREE_OID
                      + "="
                      + examsMap.getInfoExecutionDegree().getExternalId()
                      + getCurricularYearsArgs());
              strBuffer.append("'>");
            } else if (user.equals("public")) {
              strBuffer.append("<td colspan='6' class='" + rowClass + "'><i>");
            }

            strBuffer.append(infoExecutionCourse.getComment());

            if (user.equals("sop")) {
              strBuffer.append("</a>");
            } else if (user.equals("public")) {
              strBuffer.append("</i></td>");
            }

          } else {
            if (user.equals("sop")) {
              strBuffer.append(" : ");
              strBuffer.append(
                  "<a href='" + addPublicPrefix("defineComment.do") + "?executionCourseCode=");
              strBuffer.append(infoExecutionCourse.getSigla());
              strBuffer.append(
                  "&amp;executionPeriodName="
                      + infoExecutionCourse.getInfoExecutionPeriod().getName());
              strBuffer.append(
                  "&amp;executionYear="
                      + infoExecutionCourse
                          .getInfoExecutionPeriod()
                          .getInfoExecutionYear()
                          .getYear());
              strBuffer.append("&amp;method=prepare");
              strBuffer.append("&amp;indexExecutionCourse=" + i);
              strBuffer.append(
                  "&amp;"
                      + PresentationConstants.EXECUTION_PERIOD_OID
                      + "="
                      + infoExecutionCourse.getInfoExecutionPeriod().getExternalId()
                      + "&amp;"
                      + PresentationConstants.EXECUTION_DEGREE_OID
                      + "="
                      + examsMap.getInfoExecutionDegree().getExternalId()
                      + getCurricularYearsArgs());
              strBuffer.append("'>");
              strBuffer.append("Definir coment&aacute;rio");
              strBuffer.append("</a>");
            }
          }

          if (user.equals("sop")) {
            strBuffer.append("</td>");
            strBuffer.append("</tr>");
          }

          if (infoExecutionCourse.getAssociatedInfoExams().isEmpty() && !hasComment) {
            strBuffer.append("<td colspan='6' align='center' class='" + rowClass + "'>");
            strBuffer
                .append("<i>")
                .append(getMessageResource(pageContext, "no.exams.for.curricular.year"))
                .append("</i>");
            strBuffer.append("</td>");
          } else {
            // Get 1st season exam
            InfoExam season1Exam =
                (InfoExam)
                    CollectionUtils.find(
                        infoExecutionCourse.getAssociatedInfoExams(),
                        new Predicate() {
                          @Override
                          public boolean evaluate(Object obj) {
                            InfoExam infoExam = (InfoExam) obj;
                            return infoExam.getSeason().equals(new Season(Season.SEASON1));
                          }
                        });
            // Get 2nd season exam
            InfoExam season2Exam =
                (InfoExam)
                    CollectionUtils.find(
                        infoExecutionCourse.getAssociatedInfoExams(),
                        new Predicate() {
                          @Override
                          public boolean evaluate(Object obj) {
                            InfoExam infoExam = (InfoExam) obj;
                            return infoExam.getSeason().equals(new Season(Season.SEASON2));
                          }
                        });

            if (user.equals("public")) {
              if (season1Exam == null && !hasComment) {
                strBuffer.append("<td colspan='3' class='" + rowClass + "'>&nbsp;</td>");
              }
              if (season2Exam == null && !hasComment) {
                strBuffer.append("<td colspan='3' class='" + rowClass + "'>&nbsp;</td>");
              }
            }

            if ((season1Exam != null)
                // && season1Exam.getAssociatedRooms() != null
                // && season1Exam.getAssociatedRooms().size() >
                // 0)
                || (season2Exam != null))
            // && season2Exam.getAssociatedRooms() != null
            // && season2Exam.getAssociatedRooms().size() > 0))
            {
              if (season1Exam != null) {
                if (user.equals("sop")) {
                  strBuffer.append("<tr>");
                  strBuffer.append("<td>");

                  strBuffer.append(
                      "<a href='"
                          + addPublicPrefix("showExamsManagement.do")
                          + "?method=edit&amp;"
                          + PresentationConstants.EXECUTION_COURSE_OID
                          + "="
                          + infoExecutionCourse.getExternalId()
                          + "&amp;"
                          + PresentationConstants.EXECUTION_PERIOD_OID
                          + "="
                          + infoExecutionCourse.getInfoExecutionPeriod().getExternalId()
                          + "&amp;"
                          + PresentationConstants.EXECUTION_DEGREE_OID
                          + "="
                          + examsMap.getInfoExecutionDegree().getExternalId()
                          + "&amp;"
                          + PresentationConstants.CURRICULAR_YEAR_OID
                          + "="
                          + curricularYear.toString()
                          + "&amp;"
                          + PresentationConstants.EXAM_OID
                          + "="
                          + season1Exam.getExternalId()
                          + "'>");
                }

                if (user.equals("sop")) {
                  strBuffer.append("1&ordf; &Eacute;poca");
                  strBuffer.append("</a>");
                  strBuffer.append("</td>");
                  strBuffer.append("<td>");
                  strBuffer.append(season1Exam.getDate());
                  strBuffer.append("<br/>");
                  strBuffer.append(season1Exam.getBeginningHour());
                  strBuffer.append("-");
                  strBuffer.append(season1Exam.getEndHour());
                } else if (user.equals("public")) {
                  strBuffer.append("<td class='" + rowClass + "'>");
                  strBuffer.append(season1Exam.getDate());
                  strBuffer.append("</td>");
                  strBuffer.append("<td class='" + rowClass + "'>");
                  strBuffer.append(season1Exam.getBeginningHour());
                  strBuffer.append("</td>");
                  // strBuffer.append("-");
                  // strBuffer.append(season1Exam.getEndHour())
                  // ;
                }

                if (user.equals("sop")) {
                  strBuffer.append("</td>");
                  strBuffer.append("<td>");

                  // Integer numAlunos =
                  // infoExecutionCourse.
                  // getNumberOfAttendingStudents();

                  Integer numAlunos = season1Exam.getEnrolledStudents();

                  strBuffer.append(numAlunos);
                  strBuffer.append(
                      getMessageResource(
                          pageContext, "public.degree.information.label.enrolledPupils"));
                  strBuffer.append("</td>");
                  strBuffer.append("<td>");
                  strBuffer.append(
                      getMessageResource(pageContext, "public.degree.information.label.lack"));

                  // Obter o num de lugares de exame das salas
                  List roomOccupation = season1Exam.getWrittenEvaluationSpaceOccupations();
                  int numLugaresSalas = 0;

                  for (int iterRO = 0; iterRO < roomOccupation.size(); iterRO++) {
                    InfoRoomOccupation infoRO = (InfoRoomOccupation) roomOccupation.get(iterRO);

                    numLugaresSalas += infoRO.getInfoRoom().getCapacidadeExame().intValue();
                  }

                  int numLugaresAPreencher = numAlunos.intValue() - numLugaresSalas;

                  // if (numLugaresAPreencher < 0)
                  // numLugaresAPreencher = 0;

                  strBuffer.append(numLugaresAPreencher);
                  strBuffer.append(
                      getMessageResource(pageContext, "public.degree.information.label.places"));

                  strBuffer.append("</td>");
                  strBuffer.append("<td>");
                }

                List infoRoomOccupations = season1Exam.getWrittenEvaluationSpaceOccupations();

                if (infoRoomOccupations != null && infoRoomOccupations.size() > 0) {
                  if (user.equals("sop")) {
                    strBuffer.append(
                        getMessageResource(pageContext, "public.degree.information.label.rooms"));
                    strBuffer.append("<br/>");
                  } else if (user.equals("public")) {
                    strBuffer.append("<td class='" + rowClass + "'>");
                  }

                  for (int iterIRO = 0; iterIRO < infoRoomOccupations.size(); iterIRO++) {
                    InfoRoomOccupation infoRoomOccupation =
                        (InfoRoomOccupation) infoRoomOccupations.get(iterIRO);

                    strBuffer.append(infoRoomOccupation.getInfoRoom().getNome() + "; ");
                  }
                } else {
                  if (user.equals("sop")) {
                    strBuffer.append("-");
                  } else if (user.equals("public")) {
                    strBuffer.append("<td class='" + rowClass + "'>");
                    strBuffer.append("<i>");
                    strBuffer.append(
                        getMessageResource(
                            pageContext, "public.degree.information.label.noRoomsAttributed"));
                    strBuffer.append("</i>");
                  }
                }

                if (user.equals("sop")) {
                  strBuffer.append("</td>");
                  strBuffer.append("<td>");

                  strBuffer.append(
                      "<a href='"
                          + addPublicPrefix("showExamsManagement.do")
                          + "?method=delete&amp;"
                          + PresentationConstants.EXECUTION_COURSE_OID
                          + "="
                          + infoExecutionCourse.getExternalId()
                          + "&amp;"
                          + PresentationConstants.EXECUTION_PERIOD_OID
                          + "="
                          + infoExecutionCourse.getInfoExecutionPeriod().getExternalId()
                          + "&amp;"
                          + PresentationConstants.EXECUTION_DEGREE_OID
                          + "="
                          + examsMap.getInfoExecutionDegree().getExternalId()
                          + "&amp;"
                          + PresentationConstants.CURRICULAR_YEAR_OID
                          + "="
                          + curricularYear.toString()
                          + "&amp;"
                          + PresentationConstants.EXAM_OID
                          + "="
                          + season1Exam.getExternalId()
                          + "'>");
                  strBuffer.append(
                      getMessageResource(pageContext, "public.degree.information.label.delete"));
                  strBuffer.append("</a>");
                  strBuffer.append("</td>");
                }
              }

              if (season2Exam != null) {
                if (user.equals("sop")) {
                  strBuffer.append("<tr>");

                  strBuffer.append("<td>");

                  strBuffer.append(
                      "<a href='"
                          + addPublicPrefix("showExamsManagement.do")
                          + "?method=edit&amp;"
                          + PresentationConstants.EXECUTION_COURSE_OID
                          + "="
                          + infoExecutionCourse.getExternalId()
                          + "&amp;"
                          + PresentationConstants.EXECUTION_PERIOD_OID
                          + "="
                          + infoExecutionCourse.getInfoExecutionPeriod().getExternalId()
                          + "&amp;"
                          + PresentationConstants.EXECUTION_DEGREE_OID
                          + "="
                          + examsMap.getInfoExecutionDegree().getExternalId()
                          + "&amp;"
                          + PresentationConstants.CURRICULAR_YEAR_OID
                          + "="
                          + curricularYear.toString()
                          + "&amp;"
                          + PresentationConstants.EXAM_OID
                          + "="
                          + season2Exam.getExternalId()
                          + "'>");
                }

                if (user.equals("sop")) {
                  strBuffer.append("2&ordf; ");
                  strBuffer.append(
                      getMessageResource(pageContext, "public.degree.information.label.times"));
                  strBuffer.append("</a>");
                  strBuffer.append("</td>");
                  strBuffer.append("<td>");
                  strBuffer.append(season2Exam.getDate());
                  strBuffer.append("<br/>");
                  strBuffer.append(season2Exam.getBeginningHour());
                  strBuffer.append("-");
                  strBuffer.append(season2Exam.getEndHour());
                } else if (user.equals("public")) {
                  strBuffer.append("<td class='" + rowClass + "'>");
                  strBuffer.append(season2Exam.getDate());
                  strBuffer.append("</td>");
                  strBuffer.append("<td class='" + rowClass + "'>");
                  strBuffer.append(season2Exam.getBeginningHour());
                  strBuffer.append("</td>");
                  // strBuffer.append("-");
                  // strBuffer.append(season2Exam.getEndHour())
                  // ;
                }

                if (user.equals("sop")) {
                  strBuffer.append("</td>");
                  strBuffer.append("<td>");
                  // Integer numAlunos =
                  // infoExecutionCourse.
                  // getNumberOfAttendingStudents();
                  Integer numAlunos = season2Exam.getEnrolledStudents();

                  strBuffer.append(numAlunos);
                  strBuffer.append(
                      getMessageResource(
                          pageContext, "public.degree.information.label.enrolledPupils"));

                  strBuffer.append("</td>");
                  strBuffer.append("<td>");
                  strBuffer.append(
                      getMessageResource(pageContext, "public.degree.information.label.lack"));

                  // Obter o num de lugares de exame das salas
                  List roomOccupation = season2Exam.getWrittenEvaluationSpaceOccupations();
                  int numLugaresSalas = 0;

                  for (int iterRO = 0; iterRO < roomOccupation.size(); iterRO++) {
                    InfoRoomOccupation infoRO = (InfoRoomOccupation) roomOccupation.get(iterRO);

                    numLugaresSalas += infoRO.getInfoRoom().getCapacidadeExame().intValue();
                  }

                  int numLugaresAPreencher = numAlunos.intValue() - numLugaresSalas;

                  // if (numLugaresAPreencher < 0)
                  // numLugaresAPreencher = 0;

                  strBuffer.append(numLugaresAPreencher);
                  strBuffer.append(
                      getMessageResource(pageContext, "public.degree.information.label.places"));
                  strBuffer.append("</td>");

                  strBuffer.append("<td>");
                }

                List infoRoomOccupations = season2Exam.getWrittenEvaluationSpaceOccupations();

                if (infoRoomOccupations != null && infoRoomOccupations.size() > 0) {
                  if (user.equals("sop")) {
                    strBuffer.append(
                        getMessageResource(pageContext, "public.degree.information.label.rooms")
                            + ":");
                    strBuffer.append("<br/>");
                  } else if (user.equals("public")) {
                    strBuffer.append("<td class='" + rowClass + "'>");
                  }

                  for (int iterIRO = 0; iterIRO < infoRoomOccupations.size(); iterIRO++) {
                    InfoRoomOccupation infoRoomOccupation =
                        (InfoRoomOccupation) infoRoomOccupations.get(iterIRO);

                    strBuffer.append(infoRoomOccupation.getInfoRoom().getNome() + "; ");
                  }

                  if (user.equals("public")) {
                    strBuffer.append("</td>");
                  }
                } else {
                  if (user.equals("sop")) {
                    strBuffer.append("-");
                  } else if (user.equals("public")) {
                    strBuffer.append("<td class='" + rowClass + "'>");
                    strBuffer.append("<i>");
                    strBuffer.append(
                        getMessageResource(
                            pageContext, "public.degree.information.label.noRoomsAttributed"));
                    strBuffer.append("</i>");
                    strBuffer.append("</td>");
                  }
                }

                if (user.equals("sop")) {
                  strBuffer.append("</td>");
                  strBuffer.append("<td>");
                  strBuffer.append(
                      "<a href='"
                          + addPublicPrefix("showExamsManagement.do")
                          + "?method=delete&amp;"
                          + PresentationConstants.EXECUTION_COURSE_OID
                          + "="
                          + infoExecutionCourse.getExternalId()
                          + "&amp;"
                          + PresentationConstants.EXECUTION_PERIOD_OID
                          + "="
                          + infoExecutionCourse.getInfoExecutionPeriod().getExternalId()
                          + "&amp;"
                          + PresentationConstants.EXECUTION_DEGREE_OID
                          + "="
                          + examsMap.getInfoExecutionDegree().getExternalId()
                          + "&amp;"
                          + PresentationConstants.CURRICULAR_YEAR_OID
                          + "="
                          + curricularYear.toString()
                          + "&amp;"
                          + PresentationConstants.EXAM_OID
                          + "="
                          + season2Exam.getExternalId()
                          + "'>");
                  strBuffer.append(
                      getMessageResource(pageContext, "public.degree.information.label.delete"));
                  strBuffer.append("</a>");
                  strBuffer.append("</td>");
                }
              }
            }
          }

          if (user.equals("public")) {
            strBuffer.append("</tr>");
            if (rowClass == "firstRow") {
              rowClass = "notFirstRow";
            }
          }
        }

        if (user.equals("sop")) {
          strBuffer.append("</tr>");
          strBuffer.append("</table>");
          strBuffer.append("<br />");
        }
      }

      if (user.equals("public")) {
        strBuffer.append("</table>");
      }
    }
  }
Example #7
0
  public ActionForward prepareForEdit(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    Integer infoExamId = (Integer) request.getAttribute(PresentationConstants.EXAM_OID);
    request.setAttribute(PresentationConstants.EXAM_OID, infoExamId);

    ContextUtils.setCurricularYearsContext(request);

    InfoExam infoExam = (InfoExam) request.getAttribute(PresentationConstants.EXAM);
    List executionCourseList = infoExam.getAssociatedExecutionCourse();
    Iterator iter = executionCourseList.iterator();
    List newExecutionCourseList = new ArrayList();
    while (iter.hasNext()) {
      InfoExecutionCourse element = (InfoExecutionCourse) iter.next();

      InfoExecutionCourse executionCourse;
      try {
        executionCourse =
            ReadExecutionCourseWithAssociatedCurricularCourses.run(element.getIdInternal());
      } catch (Exception ex) {
        throw new Exception(ex);
      }
      newExecutionCourseList.add(executionCourse);
    }

    request.setAttribute(PresentationConstants.EXECUTION_COURSES_LIST, newExecutionCourseList);

    String nextPage = request.getParameter("nextPage");
    request.setAttribute(PresentationConstants.NEXT_PAGE, nextPage);

    List<LabelValueBean> examSeasons = Util.getExamSeasons();
    request.setAttribute(PresentationConstants.LABLELIST_SEASONS, examSeasons);

    DynaValidatorForm createExamForm = (DynaValidatorForm) form;

    String[] executionCourseIDList = new String[executionCourseList.size()];
    for (int i = 0; i < executionCourseList.size(); i++) {
      executionCourseIDList[i] =
          ((InfoExecutionCourse) executionCourseList.get(i)).getIdInternal().toString();
    }
    createExamForm.set("executionCourses", executionCourseIDList);

    List<InfoRoomOccupation> roomsList = infoExam.getWrittenEvaluationSpaceOccupations();
    String[] roomsIDArray = new String[roomsList.size()];
    Object[] infoRoomsArray = new Object[roomsList.size()];
    for (int i = 0; i < roomsList.size(); i++) {
      infoRoomsArray[i] = roomsList.get(i).getInfoRoom();
      roomsIDArray[i] = ((InfoRoom) infoRoomsArray[i]).getIdInternal().toString();
    }
    createExamForm.set("rooms", roomsIDArray);
    request.setAttribute("rooms", infoRoomsArray);

    List scopeList = infoExam.getAssociatedCurricularCourseScope();
    String[] scopeIDArray = new String[scopeList.size()];
    for (int i = 0; i < scopeList.size(); i++) {
      scopeIDArray[i] = ((InfoCurricularCourseScope) scopeList.get(i)).getIdInternal().toString();
    }
    createExamForm.set("scopes", scopeIDArray);

    createExamForm.set("day", DateFormatUtils.format(infoExam.getDay().getTime(), "dd"));
    createExamForm.set("month", DateFormatUtils.format(infoExam.getDay().getTime(), "MM"));
    createExamForm.set("year", DateFormatUtils.format(infoExam.getDay().getTime(), "yyyy"));
    createExamForm.set(
        "beginningHour", DateFormatUtils.format(infoExam.getBeginning().getTime(), "HH"));
    createExamForm.set(
        "beginningMinute", DateFormatUtils.format(infoExam.getBeginning().getTime(), "mm"));
    createExamForm.set("endHour", DateFormatUtils.format(infoExam.getEnd().getTime(), "HH"));
    createExamForm.set("endMinute", DateFormatUtils.format(infoExam.getEnd().getTime(), "mm"));
    createExamForm.set("season", infoExam.getSeason().getSeason().toString());

    return mapping.findForward("showCreateForm");
  }
Example #8
0
  public ActionForward prepareAfterAssociateExecutionCourse(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    String infoExamId = (String) request.getAttribute(PresentationConstants.EXAM_OID);
    if (infoExamId == null) {
      infoExamId = request.getParameter(PresentationConstants.EXAM_OID);
    }
    request.setAttribute(PresentationConstants.EXAM_OID, infoExamId);

    ContextUtils.setCurricularYearContext(request);
    ContextUtils.setExecutionDegreeContext(request);
    ContextUtils.setExecutionPeriodContext(request);
    ContextUtils.setCurricularYearsContext(request);

    DynaValidatorForm createExamForm = (DynaValidatorForm) form;
    String[] executionCourseArray = (String[]) createExamForm.get("executionCourses");

    List executionCourseList = new ArrayList();
    for (String element : executionCourseArray) {

      InfoExecutionCourse executionCourse;
      try {
        executionCourse =
            ReadExecutionCourseWithAssociatedCurricularCourses.run(new Integer(element));
      } catch (Exception ex) {
        throw new Exception(ex);
      }

      executionCourseList.add(executionCourse);
    }
    request.setAttribute(PresentationConstants.EXECUTION_COURSES_LIST, executionCourseList);

    String nextPage = request.getParameter("nextPage");
    request.setAttribute(PresentationConstants.NEXT_PAGE, nextPage);

    List examSeasons = Util.getExamSeasons();
    request.setAttribute(PresentationConstants.LABLELIST_SEASONS, examSeasons);

    String[] scopeIDArray = (String[]) createExamForm.get("scopes");
    List scopeIDList = CollectionUtils.toList(scopeIDArray);
    InfoExecutionCourse executionCourse =
        (InfoExecutionCourse) executionCourseList.get(executionCourseList.size() - 1);
    Iterator iter2 = executionCourse.getAssociatedInfoCurricularCourses().iterator();
    while (iter2.hasNext()) {
      Iterator iter3 = ((InfoCurricularCourse) iter2.next()).getInfoScopes().iterator();
      while (iter3.hasNext()) {
        scopeIDList.add(((InfoCurricularCourseScope) iter3.next()).getIdInternal().toString());
      }
    }
    scopeIDArray = CollectionUtils.toArrayOfString(scopeIDList);
    createExamForm.set("scopes", scopeIDArray);

    String[] rooms = (String[]) createExamForm.get("rooms");
    List roomNames = new ArrayList();

    if (rooms != null && rooms.length > 0) {

      for (String room : rooms) {

        InfoRoom infoRoom = ReadRoomByOID.run(new Integer(room));

        roomNames.add(infoRoom);
      }
    }

    request.setAttribute("rooms", roomNames);

    return mapping.findForward("showCreateForm");
  }
Example #9
0
 public void copyFromDomain(TestScope testScope) {
   super.copyFromDomain(testScope);
   if (testScope != null) {
     setInfoExecutionCourse(InfoExecutionCourse.newInfoFromDomain(testScope.getExecutionCourse()));
   }
 }