コード例 #1
0
  public ActionForward exportResultsToFile(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    String degreeTypeString = (String) getFromRequest(request, "degreeType");
    DegreeType degreeType = DegreeType.valueOf(degreeTypeString);
    ExecutionYear executionYear = getDomainObject(request, "executionYearOID");
    StyledExcelSpreadsheet spreadsheet =
        YearDelegateElection.exportElectionsResultsToFile(
            Degree.readAllByDegreeType(degreeType), executionYear);

    final ServletOutputStream writer = response.getOutputStream();
    spreadsheet.getWorkbook().write(writer);
    response.setContentType("application/txt");
    final String filename =
        String.format(
            "electionsResults_%s_%s.xls",
            degreeType.getLocalizedName(), executionYear.getYear().replace("/", "-"));
    response.addHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
    writer.flush();
    response.flushBuffer();
    return null;
  }
コード例 #2
0
  public ActionForward insert(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws FenixActionException {

    IUserView userView = UserView.getUser();

    DynaActionForm dynaForm = (DynaValidatorForm) form;
    String code = (String) dynaForm.get("code");
    String name = (String) dynaForm.get("name");
    String nameEn = (String) dynaForm.get("nameEn");
    String degreeTypeInt = (String) dynaForm.get("degreeType");
    String gradeTypeString = (String) dynaForm.get("gradeType");

    DegreeType degreeType = DegreeType.valueOf(degreeTypeInt);
    GradeScale gradeScale = null;
    if (gradeTypeString != null && gradeTypeString.length() > 0) {
      gradeScale = GradeScale.valueOf(gradeTypeString);
    }

    try {
      InsertDegree.run(code, name, nameEn, degreeType, gradeScale);

    } catch (ExistingServiceException ex) {
      throw new ExistingActionException(
          "message.already.existing.degree", mapping.findForward("readDegrees"));
    } catch (FenixServiceException e) {
      throw new FenixActionException(e.getMessage());
    }

    return mapping.findForward("readDegrees");
  }
コード例 #3
0
  public ActionForward deleteEnrollment(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    final String enrollmentIdString = request.getParameter("enrollmentId");
    final String studentNumberString = request.getParameter("studentNumber");
    final String degreeTypeString = request.getParameter("degreeType");
    final Integer studentNumber = Integer.valueOf(studentNumberString);
    final DegreeType degreeType = DegreeType.valueOf(degreeTypeString);

    final User userView = Authenticate.getUser();

    DeleteEnrollment.run(studentNumber, degreeType, enrollmentIdString);

    return show(mapping, form, request, response);
  }
コード例 #4
0
  @EntryPoint
  public ActionForward show(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    final DynaActionForm dynaActionForm = (DynaActionForm) form;
    final String studentNumberString = (String) dynaActionForm.get("number");
    final String degreeTypeString = (String) dynaActionForm.get("degreeType");

    if (isPresent(studentNumberString) && isPresent(degreeTypeString)) {
      final DegreeType degreeType = DegreeType.valueOf(degreeTypeString);
      putStudentCurricularInformationInRequest(
          request, Integer.valueOf(studentNumberString), degreeType);
    }

    return mapping.findForward("show");
  }
コード例 #5
0
  public ActionForward createStudentCurricularPlan(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    final DynaActionForm dynaActionForm = (DynaActionForm) form;
    final String studentNumberString = (String) dynaActionForm.get("number");
    final String degreeTypeString = (String) dynaActionForm.get("degreeType");
    final String studentCurricularPlanStateString =
        (String) dynaActionForm.get("studentCurricularPlanState");
    final String degreeCurricularPlanIdString =
        (String) dynaActionForm.get("degreeCurricularPlanId");
    final String startDateString = (String) dynaActionForm.get("startDate");

    if (isPresent(studentNumberString)
        && isPresent(degreeTypeString)
        && isPresent(studentCurricularPlanStateString)
        && isPresent(degreeCurricularPlanIdString)
        && isPresent(startDateString)) {

      final Integer studentNumber = new Integer(studentNumberString);
      final DegreeType degreeType = DegreeType.valueOf(degreeTypeString);
      final StudentCurricularPlanState studentCurricularPlanState =
          StudentCurricularPlanState.valueOf(studentCurricularPlanStateString);
      final Date startDate = simpleDateFormat.parse(startDateString);

      final User userView = Authenticate.getUser();

      CreateStudentCurricularPlan.run(
          studentNumber,
          degreeType,
          studentCurricularPlanState,
          degreeCurricularPlanIdString,
          startDate);
    }

    return show(mapping, form, request, response);
  }
コード例 #6
0
  public ActionForward prepareCreateStudentCurricularPlan(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    final DynaActionForm dynaActionForm = (DynaActionForm) form;
    final String degreeTypeString = (String) dynaActionForm.get("degreeType");

    if (isPresent(degreeTypeString)) {
      // putStudentCurricularPlanStateLabelListInRequest(request);

      final DegreeType degreeType = DegreeType.valueOf(degreeTypeString);

      final List infoDegreeCurricularPlans = ReadDegreeCurricularPlansByDegreeType.run(degreeType);

      putDegreeCurricularPlansInRequest(request, infoDegreeCurricularPlans);
    }

    return mapping.findForward("createStudentCurricularPlan");
  }
コード例 #7
0
 private DegreeType getDegreeType(final HttpServletRequest httpServletRequest) {
   final String degreeTypeString = httpServletRequest.getParameter("degreeType");
   return StringUtils.isEmpty(degreeTypeString) ? null : DegreeType.valueOf(degreeTypeString);
 }
コード例 #8
0
ファイル: FindPersonAction.java プロジェクト: joaollq/fenix
  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");
  }