public ActionForward search(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {
    final AcademicServiceRequestBean bean = getOrCreateAcademicServiceRequestBean(request);
    request.setAttribute("bean", bean);

    final Collection<AcademicServiceRequest> remainingRequests =
        bean.searchAcademicServiceRequests();
    final Collection<AcademicServiceRequest> specificRequests =
        getAndRemoveSpecificRequests(bean, remainingRequests);

    final SortedSet<AcademicServiceRequest> sorted =
        new TreeSet<AcademicServiceRequest>(getComparator(request));
    sorted.addAll(remainingRequests);
    request.setAttribute("remainingRequests", remainingRequests);
    request.setAttribute("specificRequests", specificRequests);

    final CollectionPager<AcademicServiceRequest> pager =
        new CollectionPager<AcademicServiceRequest>(sorted, REQUESTS_PER_PAGE);
    request.setAttribute("collectionPager", pager);
    request.setAttribute("numberOfPages", Integer.valueOf(pager.getNumberOfPages()));

    final String pageParameter = request.getParameter("pageNumber");
    final Integer page =
        StringUtils.isEmpty(pageParameter) ? Integer.valueOf(1) : Integer.valueOf(pageParameter);
    request.setAttribute("pageNumber", page);
    request.setAttribute("resultPage", pager.getPage(page));

    return mapping.findForward("searchResults");
  }
Ejemplo n.º 2
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);
  }
Ejemplo n.º 3
0
  public ActionForward findPerson(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    IUserView userView = UserView.getUser();

    FindPersonBean bean = getRenderedObject();

    boolean fromRequest = true;
    String name = request.getParameter("name");
    String roleType = null;
    String departmentId = null;
    String degreeId = null;
    String degreeType = null;

    if (bean != null && name == null) {
      fromRequest = false;
      name = bean.getName();
      roleType = bean.getRoleType() == null ? null : bean.getRoleType().toString();
      departmentId = bean.getDepartmentExternalId();
      degreeId = bean.getDegreeExternalId();
      degreeType = bean.getDegreeType() == null ? null : bean.getDegreeType().toString();
    } else {
      roleType = request.getParameter("roleType");

      departmentId = request.getParameter("departmentId");

      degreeId = request.getParameter("degreeId");
      degreeType = request.getParameter("degreeType");
    }

    if (name == null) {
      // error
    }

    SearchParameters searchParameters =
        new SearchPerson.SearchParameters(
            name,
            null,
            null,
            null,
            null,
            roleType,
            degreeType,
            degreeId,
            departmentId,
            Boolean.TRUE,
            null,
            Boolean.FALSE,
            (String) null);

    SearchPersonPredicate predicate = new SearchPerson.SearchPersonPredicate(searchParameters);

    CollectionPager result = SearchPerson.runSearchPerson(searchParameters, predicate);

    if (result == null) {
      addErrorMessage(request, "impossibleFindPerson", "error.manager.implossible.findPerson");
      return preparePerson(mapping, actionForm, request, response);
    }

    if (result.getCollection().isEmpty()) {
      addErrorMessage(request, "impossibleFindPerson", "error.manager.implossible.findPerson");
      return preparePerson(mapping, actionForm, request, response);
    }

    final String pageNumberString = request.getParameter("pageNumber");
    final Integer pageNumber =
        !StringUtils.isEmpty(pageNumberString)
            ? Integer.valueOf(pageNumberString)
            : Integer.valueOf(1);

    request.setAttribute("pageNumber", pageNumber);
    request.setAttribute("numberOfPages", Integer.valueOf(result.getNumberOfPages()));

    request.setAttribute("personListFinded", result.getPage(pageNumber.intValue()));
    request.setAttribute("totalFindedPersons", result.getCollection().size());

    request.setAttribute("name", name);
    request.setAttribute("roleType", roleType == null ? "" : roleType);
    request.setAttribute("degreeId", degreeId == null ? "" : degreeId.toString());
    request.setAttribute("degreeType", degreeType == null ? "" : degreeType.toString());
    request.setAttribute("departmentId", departmentId == null ? "" : departmentId.toString());

    if (isEmployeeOrTeacher(userView)) {
      request.setAttribute("show", Boolean.TRUE);
    } else {
      request.setAttribute("show", Boolean.FALSE);
    }

    Boolean viewPhoto = null;
    if (request.getParameter("viewPhoto") != null
        && request.getParameter("viewPhoto").length() > 0) {
      viewPhoto = getCheckBoxValue(request.getParameter("viewPhoto"));
    } else if (bean.getViewPhoto() != null) {
      viewPhoto = bean.getViewPhoto();
    }

    request.setAttribute("viewPhoto", viewPhoto);

    if (fromRequest) {
      bean = new FindPersonBean();
      bean.setName(name);
      bean.setViewPhoto(viewPhoto);
      if (!StringUtils.isEmpty(roleType)) {
        bean.setRoleType(RoleType.valueOf(roleType));
      }
      if (!StringUtils.isEmpty(degreeId)) {
        bean.setDegree(FenixFramework.<Degree>getDomainObject(degreeId));
      }
      if (!StringUtils.isEmpty(degreeType)) {
        bean.setDegreeType(DegreeType.valueOf(degreeType));
      }
      if (!StringUtils.isEmpty(departmentId)) {
        bean.setDepartment(FenixFramework.<Department>getDomainObject(departmentId));
      }
    }
    RenderUtils.invalidateViewState();
    request.setAttribute("bean", bean);
    return mapping.findForward("findPerson");
  }