@Override
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws FenixActionException, FenixFilterException {
    try {
      super.execute(mapping, form, request, response);
    } catch (Exception e1) {
      e1.printStackTrace();
    }

    String groupPropertiesCodeString = request.getParameter("groupPropertiesCode");
    Integer groupPropertiesCode = new Integer(groupPropertiesCodeString);
    ISiteComponent shiftsAndGroupsView = new InfoSiteShiftsAndGroups();
    readSiteView(request, shiftsAndGroupsView, null, groupPropertiesCode, null);

    InfoExecutionPeriod infoExecutionPeriod =
        (InfoExecutionPeriod) request.getAttribute(PresentationConstants.EXECUTION_PERIOD);

    InfoExecutionDegree infoExecutionDegree =
        RequestUtils.getExecutionDegreeFromRequest(
            request, infoExecutionPeriod.getInfoExecutionYear());

    Integer curricularYear = (Integer) request.getAttribute("curYear");

    List infoExecutionCourses =
        (List)
            SelectExportExecutionCourse.run(
                infoExecutionDegree, infoExecutionPeriod, curricularYear);
    Collections.sort(infoExecutionCourses, new BeanComparator("nome"));
    request.setAttribute("exeCourseList", infoExecutionCourses);
    return mapping.findForward("sucess");
  }
Ejemplo n.º 2
0
  public ActionForward nextPagePublic(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws FenixActionException {
    DynaActionForm escolherContextoForm = (DynaActionForm) form;

    InfoExecutionPeriod infoExecutionPeriod =
        (InfoExecutionPeriod) request.getAttribute(PresentationConstants.EXECUTION_PERIOD);

    Integer semestre = infoExecutionPeriod.getSemester();
    Integer anoCurricular = (Integer) escolherContextoForm.get("curYear");

    // Integer degreeCurricularPlanId =
    // getFromRequest("degreeCurricularPlanID", request);
    request.setAttribute("degreeCurricularPlanID", "");

    // Integer degreeId = getFromRequest("degreeID", request);
    request.setAttribute("degreeID", "");

    Integer index = Integer.valueOf((String) escolherContextoForm.get("index"));

    request.setAttribute("curYear", anoCurricular);
    request.setAttribute("semester", semestre);

    List infoExecutionDegreeList;
    infoExecutionDegreeList =
        ReadExecutionDegreesByExecutionYear.run(infoExecutionPeriod.getInfoExecutionYear());
    Collections.sort(infoExecutionDegreeList, new ComparatorByNameForInfoExecutionDegree());

    InfoExecutionDegree infoExecutionDegree =
        (InfoExecutionDegree) infoExecutionDegreeList.get(index.intValue());
    request.setAttribute(PresentationConstants.EXECUTION_DEGREE, infoExecutionDegree);

    if (infoExecutionDegree == null) {
      return mapping.findForward("Licenciatura execucao inexistente");
    }

    RequestUtils.setExecutionDegreeToRequest(request, infoExecutionDegree);

    String nextPage = request.getParameter("nextPage");

    if (nextPage != null) {
      return mapping.findForward(nextPage);
    }

    // TODO : throw a proper exception
    throw new FenixActionException("SomeOne is messing around with the links");
  }
  public List<SelectItem> getExecutionPeriodsLabels() {
    if (this.executionPeriodsLabels == null) {
      this.executionPeriodsLabels = new ArrayList();

      final List<InfoExecutionPeriod> infoExecutionPeriods = getExecutionPeriods();
      final ComparatorChain comparatorChain = new ComparatorChain();
      comparatorChain.addComparator(
          new ReverseComparator(new BeanComparator("infoExecutionYear.year")));
      comparatorChain.addComparator(new ReverseComparator(new BeanComparator("semester")));
      Collections.sort(infoExecutionPeriods, comparatorChain);
      for (final InfoExecutionPeriod infoExecutionPeriod : infoExecutionPeriods) {
        final SelectItem selectItem = new SelectItem();
        selectItem.setValue(infoExecutionPeriod.getExternalId());
        selectItem.setLabel(
            infoExecutionPeriod.getName()
                + " - "
                + infoExecutionPeriod.getInfoExecutionYear().getYear());
        this.executionPeriodsLabels.add(selectItem);
      }
    }
    return this.executionPeriodsLabels;
  }
  private List getExecutionDegrees(HttpServletRequest request) throws FenixServiceException {
    InfoExecutionPeriod infoExecutionPeriod =
        (InfoExecutionPeriod) request.getAttribute("infoExecutionPeriod");

    List<InfoExecutionDegree> executionDegrees =
        ReadExecutionDegreesByExecutionYearAndDegreeType.run(
            infoExecutionPeriod.getInfoExecutionYear().getYear(), null);

    ComparatorChain comparatorChain = new ComparatorChain();

    comparatorChain.addComparator(
        new BeanComparator("infoDegreeCurricularPlan.infoDegree.tipoCurso"));
    comparatorChain.addComparator(new BeanComparator("infoDegreeCurricularPlan.infoDegree.nome"));

    Collections.sort(executionDegrees, comparatorChain);

    MessageResources messageResources = this.getResources(request, "ENUMERATION_RESOURCES");
    executionDegrees =
        InfoExecutionDegree.buildLabelValueBeansForList(executionDegrees, messageResources);

    return executionDegrees;
  }
Ejemplo n.º 5
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.apache.struts.actions.DispatchAction#dispatchMethod(org.apache.struts
   * .action.ActionMapping, org.apache.struts.action.ActionForm,
   * javax.servlet.http.HttpServletRequest,
   * javax.servlet.http.HttpServletResponse, java.lang.String)
   */
  public ActionForward prepare(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    String inputPage = request.getParameter(PresentationConstants.INPUT_PAGE);
    String nextPage = request.getParameter(PresentationConstants.NEXT_PAGE);
    if (inputPage != null) {
      request.setAttribute(PresentationConstants.INPUT_PAGE, inputPage);
    }
    if (nextPage != null) {
      request.setAttribute(PresentationConstants.NEXT_PAGE, nextPage);
    }

    User userView = Authenticate.getUser();

    InfoExecutionPeriod infoExecutionPeriod = setExecutionContext(request);

    // TODO: this semester and curricular year list needs to be
    // refactored in order to incorporate masters
    /* Criar o bean de semestres */
    List semestres = new ArrayList();
    semestres.add(new LabelValueBean("escolher", ""));
    semestres.add(new LabelValueBean("1 º", "1"));
    semestres.add(new LabelValueBean("2 º", "2"));
    request.setAttribute("semestres", semestres);

    /* Criar o bean de anos curricutares */
    List anosCurriculares = new ArrayList();
    anosCurriculares.add(new LabelValueBean("escolher", ""));
    anosCurriculares.add(new LabelValueBean("1 º", "1"));
    anosCurriculares.add(new LabelValueBean("2 º", "2"));
    anosCurriculares.add(new LabelValueBean("3 º", "3"));
    anosCurriculares.add(new LabelValueBean("4 º", "4"));
    anosCurriculares.add(new LabelValueBean("5 º", "5"));
    request.setAttribute(PresentationConstants.CURRICULAR_YEAR_LIST_KEY, anosCurriculares);

    /* Cria o form bean com as licenciaturas em execucao. */

    List executionDegreeList =
        ReadExecutionDegreesByExecutionYear.run(infoExecutionPeriod.getInfoExecutionYear());

    List licenciaturas = new ArrayList();

    licenciaturas.add(new LabelValueBean("escolher", ""));

    Collections.sort(executionDegreeList, new ComparatorByNameForInfoExecutionDegree());

    Iterator iterator = executionDegreeList.iterator();

    int index = 0;
    while (iterator.hasNext()) {
      InfoExecutionDegree infoExecutionDegree = (InfoExecutionDegree) iterator.next();
      String name = infoExecutionDegree.getInfoDegreeCurricularPlan().getInfoDegree().getNome();

      name =
          infoExecutionDegree
                  .getInfoDegreeCurricularPlan()
                  .getInfoDegree()
                  .getDegreeType()
                  .toString()
              + " em "
              + name;

      name +=
          duplicateInfoDegree(executionDegreeList, infoExecutionDegree)
              ? "-" + infoExecutionDegree.getInfoDegreeCurricularPlan().getName()
              : "";

      licenciaturas.add(new LabelValueBean(name, String.valueOf(index++)));
    }

    request.setAttribute(PresentationConstants.INFO_EXECUTION_DEGREE_LIST_KEY, executionDegreeList);

    request.setAttribute(PresentationConstants.DEGREES, licenciaturas);

    if (inputPage != null) {
      return mapping.findForward(inputPage);
    }

    // TODO : throw a proper exception
    throw new Exception("SomeOne is messing around with the links");
  }