コード例 #1
0
  public ActionForward chooseStudent(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    final StudentContextSelectionBean studentContextSelectionBean = getRenderedObject();

    final String number = studentContextSelectionBean.getNumber();
    if (number != null && !number.isEmpty()) {
      final AcademicInterval academicInterval = studentContextSelectionBean.getAcademicInterval();
      final ExecutionInterval executionInterval =
          ExecutionInterval.getExecutionInterval(academicInterval);

      final SearchParameters searchParameters = new SearchParameters();
      if (StringUtils.isNumeric(number)) {
        searchParameters.setStudentNumber(Integer.valueOf(number));
      } else {
        searchParameters.setUsername(number);
      }
      final CollectionPager<Person> people =
          new SearchPerson()
              .run(searchParameters, new SearchPerson.SearchPersonPredicate(searchParameters));
      final Collection<Registration> registrations = new ArrayList<Registration>();
      for (final Person person : people.getCollection()) {
        if (person.getStudent() != null) {
          for (final Registration registration : person.getStudent().getRegistrationsSet()) {
            if (registration.hasAnyActiveState((ExecutionSemester) executionInterval)) {
              registrations.add(registration);
            }
          }
        }
      }

      if (studentContextSelectionBean.getToEdit()) {
        request.setAttribute("toEditScheduleRegistrations", registrations);
      } else {
        request.setAttribute("registrations", registrations);
        request.setAttribute("timeTableExecutionSemester", executionInterval);
      }
    }

    return prepare(mapping, form, request, response);
  }
コード例 #2
0
  @EntryPoint
  public ActionForward prepare(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    ContextSelectionBean contextSelectionBean =
        (ContextSelectionBean) request.getAttribute(PresentationConstants.CONTEXT_SELECTION_BEAN);

    final StudentContextSelectionBean studentContextSelectionBean =
        new StudentContextSelectionBean(contextSelectionBean.getAcademicInterval());
    request.setAttribute("studentContextSelectionBean", studentContextSelectionBean);

    final List<ExecutionDegree> executionDegrees =
        new ArrayList<ExecutionDegree>(
            ExecutionDegree.filterByAcademicInterval(contextSelectionBean.getAcademicInterval()));
    Collections.sort(executionDegrees, executionDegreeComparator);
    request.setAttribute("executionDegrees", executionDegrees);
    ExecutionSemester executionSemester =
        (ExecutionSemester)
            ExecutionInterval.getExecutionInterval(contextSelectionBean.getAcademicInterval());
    request.setAttribute("executionSemester", executionSemester);

    AcademicCalendarEntry academicCalendarEntry =
        contextSelectionBean.getAcademicInterval().getAcademicCalendarEntry();
    while (!(academicCalendarEntry instanceof AcademicCalendarRootEntry)) {
      if (academicCalendarEntry instanceof AcademicYearCE) {
        ExecutionYear year = ExecutionYear.getExecutionYear((AcademicYearCE) academicCalendarEntry);
        request.setAttribute("executionYear", year);
        break;
      } else {
        academicCalendarEntry = academicCalendarEntry.getParentEntry();
      }
    }

    if (!executionSemester.isCurrent()) {
      request.setAttribute("noEditionAllowed", true);
    }

    return mapping.findForward("showForm");
  }