Example #1
0
  /**
   * Executes the service. Returns the current InfoCurricularCourse.
   *
   * @throws ExcepcaoPersistencia
   */
  protected InfoCurricularCourse run(String externalId) throws FenixServiceException {
    CurricularCourse curricularCourse;
    curricularCourse = (CurricularCourse) FenixFramework.getDomainObject(externalId);

    if (curricularCourse == null) {
      throw new NonExistingServiceException();
    }

    return InfoCurricularCourse.newInfoFromDomain(curricularCourse);
  }
Example #2
0
  @Override
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws FenixActionException {
    IUserView userView = getUserView(request);
    String seminaryIDString = request.getParameter("objectCode");
    String seminaryID;
    if (seminaryIDString == null) {
      throw new FenixActionException(mapping.findForward("invalidQueryString"));
    }
    try {
      seminaryID = seminaryIDString;
    } catch (Exception ex) {
      throw new FenixActionException(mapping.findForward("invalidQueryString"));
    }
    InfoSeminaryWithEquivalencies seminary = null;
    InfoStudent student = null;
    List disciplines = null;
    ActionForward destiny = null;
    try {
      seminary = GetSeminary.runGetSeminary(seminaryID);
      student = ReadStudentByUsername.runReadStudentByUsername(userView.getUtilizador());
      disciplines =
          ReadCurricularCoursesByUsername.runReadCurricularCoursesByUsername(
              userView.getUtilizador());
      List avaliableEquivalencies = new LinkedList();
      for (Iterator iterator = disciplines.iterator(); iterator.hasNext(); ) {
        InfoCurricularCourse curricularCourse = (InfoCurricularCourse) iterator.next();
        for (Iterator equivalencyIterator = seminary.getEquivalencies().iterator();
            equivalencyIterator.hasNext(); ) {
          InfoEquivalency equivalency = (InfoEquivalency) equivalencyIterator.next();
          if (equivalency
              .getCurricularCourse()
              .getExternalId()
              .equals(curricularCourse.getExternalId())) {
            avaliableEquivalencies.add(equivalency);
            break;
          }
        }
      }
      seminary.setEquivalencies(avaliableEquivalencies);
      List candidacies =
          GetCandidaciesByStudentIDAndSeminaryID.runGetCandidaciesByStudentIDAndSeminaryID(
              student.getExternalId(), seminaryID);
      if (candidacies.size() >= seminary.getAllowedCandidaciesPerStudent().intValue()) {
        addErrorMessage(
            request,
            "error.seminaries.candidaciesLimitReached",
            "error.seminaries.candidaciesLimitReached",
            String.valueOf(seminary.getAllowedCandidaciesPerStudent()));

        destiny = mapping.findForward("candidaciesLimitReached");
      } else {
        destiny = mapping.findForward("showCandidacyOptions");
        request.setAttribute("seminary", seminary);
      }

    } catch (Exception e) {
      throw new FenixActionException(e);
    }

    return destiny;
  }