public String addContext() {
   try {
     checkCourseGroup();
     checkCurricularCourse();
     checkCurricularSemesterAndYear();
     AddContextToCurricularCourse.run(
         getCurricularCourse(),
         getCourseGroup(),
         getBeginExecutionPeriodID(),
         getFinalEndExecutionPeriodID(),
         getCurricularYearID(),
         getCurricularSemesterID());
     addInfoMessage(BundleUtil.getString(Bundle.BOLONHA, "addedNewContextToCurricularCourse"));
   } catch (FenixActionException e) {
     this.addErrorMessage(BundleUtil.getString(Bundle.BOLONHA, e.getMessage()));
     return "";
   } catch (FenixServiceException e) {
     this.addErrorMessage(BundleUtil.getString(Bundle.BOLONHA, e.getMessage()));
     return "";
   } catch (DomainException e) {
     addErrorMessage(BundleUtil.getString(Bundle.BOLONHA, e.getMessage(), e.getArgs()));
     return "";
   } catch (Exception e) {
     this.addErrorMessage(BundleUtil.getString(Bundle.BOLONHA, "general.error"));
     return "buildCurricularPlan";
   }
   setContextID(null); // resetContextID
   return "buildCurricularPlan";
 }
  public ActionForward cancelAcademicServiceRequest(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws FenixFilterException, FenixServiceException {

    final RegistrationAcademicServiceRequest academicServiceRequest =
        getAndSetAcademicServiceRequest(request);
    final String justification =
        ((AcademicServiceRequestsManagementForm) actionForm).getJustification();

    try {
      academicServiceRequest.cancel(justification);
    } catch (DomainExceptionWithLabelFormatter ex) {
      addActionMessage(
          request, ex.getKey(), solveLabelFormatterArgs(request, ex.getLabelFormatterArgs()));
      return mapping.findForward("prepareCancelAcademicServiceRequest");
    } catch (DomainException ex) {
      addActionMessage(request, ex.getKey());
      return mapping.findForward("prepareCancelAcademicServiceRequest");
    }

    request.setAttribute("registration", academicServiceRequest.getRegistration());
    return mapping.findForward("viewRegistrationDetails");
  }
  public ActionForward uploadDocument(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws FenixFilterException, FenixServiceException, IOException {
    CandidacyProcessDocumentUploadBean uploadBean =
        (CandidacyProcessDocumentUploadBean)
            getObjectFromViewState("individualCandidacyProcessBean.document");
    try {
      IndividualCandidacyDocumentFile documentFile =
          createIndividualCandidacyDocumentFile(
              uploadBean,
              uploadBean
                  .getIndividualCandidacyProcess()
                  .getPersonalDetails()
                  .getDocumentIdNumber());
      uploadBean.setDocumentFile(documentFile);

      executeActivity(getProcess(request), "EditDocuments", uploadBean);
    } catch (DomainException e) {
      addActionMessage(request, e.getMessage(), e.getArgs());
    }

    return prepareExecuteEditDocuments(mapping, actionForm, request, response);
  }
  public ActionForward receiveAcademicServiceRequest(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws FenixFilterException, FenixServiceException {

    final RegistrationAcademicServiceRequest serviceRequest =
        getAndSetAcademicServiceRequest(request);
    final AcademicServiceRequestBean requestBean =
        (AcademicServiceRequestBean) getObjectFromViewState("serviceRequestBean");

    try {
      serviceRequest.receivedFromExternalEntity(
          requestBean.getSituationDate(), requestBean.getJustification());

    } catch (DomainExceptionWithLabelFormatter ex) {
      addActionMessage(
          request, ex.getKey(), solveLabelFormatterArgs(request, ex.getLabelFormatterArgs()));
      request.setAttribute("serviceRequestBean", requestBean);
      return mapping.findForward("prepareReceiveAcademicServiceRequest");
    } catch (DomainException ex) {
      addActionMessage(request, ex.getKey());
      request.setAttribute("serviceRequestBean", requestBean);
      return mapping.findForward("prepareReceiveAcademicServiceRequest");
    }

    request.setAttribute("registration", serviceRequest.getRegistration());
    return mapping.findForward("viewRegistrationDetails");
  }
  public ActionForward processNewAcademicServiceRequest(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws FenixFilterException, FenixServiceException {

    final RegistrationAcademicServiceRequest academicServiceRequest =
        getAndSetAcademicServiceRequest(request);

    try {
      academicServiceRequest.process();
      addActionMessage(request, "academic.service.request.processed.with.success");
    } catch (DomainException ex) {
      addActionMessage(request, ex.getKey(), ex.getArgs());
      request.setAttribute("failingCondition", ex.getKey());
      return mapping.findForward("prepareRejectAcademicServiceRequest");
    }

    if (academicServiceRequest.isDocumentRequest()
        && ((DocumentRequest) academicServiceRequest)
            .getDocumentRequestType()
            .isAllowedToQuickDeliver()) {
      return prepareConcludeAcademicServiceRequest(mapping, actionForm, request, response);
    } else if (request.getParameter("academicSituationType") != null) {
      return search(mapping, actionForm, request, response);
    } else {
      request.setAttribute("registration", academicServiceRequest.getRegistration());
      return mapping.findForward("viewRegistrationDetails");
    }
  }
  public ActionForward concludeAcademicServiceRequest(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws FenixFilterException, FenixServiceException {
    Boolean sendEmail = true;
    RegistrationAcademicServiceRequest academicServiceRequest =
        getAndSetAcademicServiceRequest(request);

    final AcademicServiceRequestsManagementForm form =
        (AcademicServiceRequestsManagementForm) actionForm;
    if (academicServiceRequest.getAcademicServiceRequestType()
        == AcademicServiceRequestType.SPECIAL_SEASON_REQUEST) {
      if (form.getDeferRequest() == null) {
        return prepareConcludeAcademicServiceRequest(mapping, actionForm, request, response);
      }
      final SpecialSeasonRequest specialSeasonRequest =
          (SpecialSeasonRequest) academicServiceRequest;
      specialSeasonRequest.setDeferment(form.getDeferRequest());
      academicServiceRequest = specialSeasonRequest;
    }

    if (RegistrationAgreement.MOBILITY_AGREEMENTS.contains(
        academicServiceRequest.getRegistration().getRegistrationAgreement())) {
      sendEmail = false;
    }

    if (academicServiceRequest.getAcademicServiceRequestType()
        == AcademicServiceRequestType.DIPLOMA_SUPPLEMENT_REQUEST) {
      sendEmail = false;
    }

    try {
      academicServiceRequest.conclude(
          getSituationDate(),
          getJustification(),
          form.getSendEmailToStudent() != null ? form.getSendEmailToStudent() : sendEmail);
      addActionMessage(request, "academic.service.request.concluded.with.success");

      if (academicServiceRequest.isDocumentRequest()
          && ((DocumentRequest) academicServiceRequest)
              .getDocumentRequestType()
              .isAllowedToQuickDeliver()) {
        return deliveredAcademicServiceRequest(mapping, actionForm, request, response);
      }
    } catch (DomainExceptionWithLabelFormatter ex) {
      addActionMessage(
          request, ex.getKey(), solveLabelFormatterArgs(request, ex.getLabelFormatterArgs()));
    } catch (DomainException ex) {
      addActionMessage(request, ex.getKey());
    }

    request.setAttribute("registration", academicServiceRequest.getRegistration());
    return mapping.findForward("viewRegistrationDetails");
  }
  private ResultParticipation readResultParticipationFromRequest(HttpServletRequest request) {
    final String oid = getRequestParameterAsString(request, "participationId");
    ResultParticipation participation = null;

    try {
      participation = ResultParticipation.readByOid(oid);
    } catch (DomainException e) {
      addActionMessage(request, e.getKey(), e.getArgs());
    }

    return participation;
  }
 public void deleteContext(ActionEvent event) {
   try {
     DeleteContextFromDegreeModule.run(getCurricularCourseID(), getContextIDToDelete());
     addInfoMessage(BundleUtil.getString(Bundle.BOLONHA, "successAction"));
   } catch (IllegalDataAccessException e) {
     this.addErrorMessage(BundleUtil.getString(Bundle.BOLONHA, "error.notAuthorized"));
   } catch (FenixServiceException e) {
     addErrorMessage(e.getMessage());
   } catch (DomainException e) {
     addErrorMessage(BundleUtil.getString(Bundle.DOMAIN_EXCEPTION, e.getKey(), e.getArgs()));
   }
   setContextID(null); // resetContextID
 }
 public ActionForward executeRejectCandidacy(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws FenixFilterException, FenixServiceException {
   try {
     executeActivity(getProcess(request), "RejectCandidacy", null);
   } catch (DomainException e) {
     addActionMessage(request, e.getMessage(), e.getArgs());
     return mapping.findForward("reject-candidacy");
   }
   return listProcessAllowedActivities(mapping, form, request, response);
 }
 public ActionForward executeSendToScientificCouncil(
     ActionMapping mapping,
     ActionForm actionForm,
     HttpServletRequest request,
     HttpServletResponse response)
     throws FenixServiceException {
   try {
     executeActivity(getProcess(request), "SendToScientificCouncil");
   } catch (final DomainException e) {
     addActionMessage(request, e.getMessage(), e.getArgs());
     return prepareExecuteSendToScientificCouncil(mapping, actionForm, request, response);
   }
   return listProcessAllowedActivities(mapping, actionForm, request, response);
 }
 public ActionForward executeCreateRegistration(
     ActionMapping mapping,
     ActionForm actionForm,
     HttpServletRequest request,
     HttpServletResponse response)
     throws FenixServiceException {
   try {
     executeActivity(getProcess(request), "CreateRegistration");
   } catch (final DomainException e) {
     addActionMessage(request, e.getMessage(), e.getArgs());
     request.setAttribute("degree", getProcess(request).getCandidacySelectedDegree());
     return mapping.findForward("create-registration");
   }
   return listProcessAllowedActivities(mapping, actionForm, request, response);
 }
  public ActionForward prepareExecuteRevertApplicationToStandBy(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws FenixFilterException, FenixServiceException {
    try {
      executeActivity(getProcess(request), "RevertApplicationToStandBy", null);
    } catch (DomainException e) {
      addActionMessage(request, e.getMessage(), e.getArgs());
      return listProcessAllowedActivities(mapping, actionForm, request, response);
    }

    return listProcessAllowedActivities(mapping, actionForm, request, response);
  }
  public ActionForward executeIntroduceCandidacyResult(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws FenixServiceException {

    try {
      executeActivity(getProcess(request), "IntroduceCandidacyResult", getCandidacyResultBean());
    } catch (final DomainException e) {
      addActionMessage(request, e.getMessage(), e.getArgs());
      request.setAttribute("individualCandidacyResultBean", getCandidacyResultBean());
      return mapping.findForward("introduce-candidacy-result");
    }

    return listProcessAllowedActivities(mapping, actionForm, request, response);
  }
  public ActionForward editPhdCandidacyPeriod(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {
    PhdCandidacyPeriod phdCandidacyPeriod = readPhdCandidacyPeriod(request);
    PhdCandidacyPeriodBean bean = readPhdCandidacyPeriodBean();

    try {
      phdCandidacyPeriod.edit(bean.getStart(), bean.getEnd());
    } catch (DomainException e) {
      addActionMessage("error", request, e.getKey(), e.getArgs());
      return editPhdCandidacyPeriodInvalid(mapping, form, request, response);
    }

    return list(mapping, form, request, response);
  }
  public ActionForward bindPerson(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws FenixFilterException, FenixServiceException {
    try {
      executeActivity(
          getProcess(request), "BindPersonToCandidacy", getIndividualCandidacyProcessBean());
    } catch (DomainException e) {
      addActionMessage(request, e.getMessage(), e.getArgs());
      request.setAttribute(
          getIndividualCandidacyProcessBeanName(), getIndividualCandidacyProcessBean());
      return mapping.findForward("edit-personal-information-for-bind");
    }

    return prepareExecuteCandidacyPayment(mapping, actionForm, request, response);
  }
  public ActionForward executeChangePaymentCheckedState(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws FenixFilterException, FenixServiceException {
    try {
      executeActivity(
          getProcess(request), "ChangePaymentCheckedState", getIndividualCandidacyProcessBean());
    } catch (DomainException e) {
      addActionMessage(request, e.getMessage(), e.getArgs());
      request.setAttribute(
          getIndividualCandidacyProcessBeanName(), getIndividualCandidacyProcessBean());
      return mapping.findForward("change-payment-checked-state");
    }

    return listProcessAllowedActivities(mapping, actionForm, request, response);
  }
 @Override
 public ActionForward createNewProcess(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws FenixFilterException, FenixServiceException {
   try {
     request.setAttribute(
         "process",
         CreateNewProcess.run(getProcessType().getName(), getIndividualCandidacyProcessBean()));
   } catch (DomainException e) {
     addActionMessage(request, e.getMessage(), e.getArgs());
     request.setAttribute(
         getIndividualCandidacyProcessBeanName(), getIndividualCandidacyProcessBean());
     return mapping.findForward("fill-candidacy-information");
   }
   return listProcessAllowedActivities(mapping, form, request, response);
 }
  public ActionForward createServiceRequest(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws FenixFilterException, FenixServiceException {

    try {
      executeFactoryMethod();
    } catch (DomainException e) {
      addActionMessage(request, e.getMessage(), e.getArgs());
      return confirmCreateServiceRequest(mapping, actionForm, request, response);
    }

    final RegistrationAcademicServiceRequestCreator bean =
        getRenderedObject("academicServiceRequestCreateBean");
    request.setAttribute("registration", bean.getRegistration());
    return mapping.findForward("viewRegistrationDetails");
  }
  @Service
  public ActionForward revertRequestToProcessingState(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {
    final AcademicServiceRequest academicServiceRequest = getAndSetAcademicServiceRequest(request);
    getAndSetUrl(form, request);
    request.setAttribute(
        "canRevertToProcessingState", canRevertToProcessingState(academicServiceRequest));

    try {
      academicServiceRequest.revertToProcessingState();
    } catch (DomainException ex) {
      addActionMessage(request, ex.getMessage(), ex.getArgs());
    }

    return mapping.findForward("viewAcademicServiceRequest");
  }
  public ActionForward executeEditCandidacyInformation(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws FenixServiceException {

    try {
      executeActivity(
          getProcess(request), "EditCandidacyInformation", getIndividualCandidacyProcessBean());
    } catch (final DomainException e) {
      addActionMessage(request, e.getMessage(), e.getArgs());
      request.setAttribute(
          getIndividualCandidacyProcessBeanName(), getIndividualCandidacyProcessBean());
      return mapping.findForward("edit-candidacy-information");
    }

    return listProcessAllowedActivities(mapping, actionForm, request, response);
  }
  public ActionForward deliveredAcademicServiceRequest(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws FenixFilterException, FenixServiceException {

    final RegistrationAcademicServiceRequest academicServiceRequest =
        getAndSetAcademicServiceRequest(request);

    try {
      academicServiceRequest.delivered();
      addActionMessage(request, "academic.service.request.delivered.with.success");
    } catch (DomainException ex) {
      addActionMessage(request, ex.getKey());
    }

    request.setAttribute("registration", academicServiceRequest.getRegistration());
    return mapping.findForward("viewRegistrationDetails");
  }
 public String editContext() {
   try {
     checkCourseGroup();
     EditContextFromCurricularCourse.run(
         getCurricularCourse(),
         getContext(getContextID()),
         getCourseGroup(),
         getCurricularYearID(),
         getCurricularSemesterID(),
         getBeginExecutionPeriodID(),
         getFinalEndExecutionPeriodID());
   } catch (IllegalDataAccessException e) {
     this.addErrorMessage(BundleUtil.getString(Bundle.BOLONHA, "error.notAuthorized"));
   } catch (DomainException e) {
     addErrorMessage(BundleUtil.getString(Bundle.DOMAIN_EXCEPTION, e.getMessage()));
   } catch (FenixActionException e) {
     addErrorMessage(BundleUtil.getString(Bundle.BOLONHA, e.getMessage()));
   }
   setContextID(null); // resetContextID
   return "";
 }
  public ActionForward createPhdCandidacyPeriod(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {
    PhdCandidacyPeriodBean bean = readPhdCandidacyPeriodBean();

    switch (bean.getType()) {
      case EPFL:
        try {
          EPFLPhdCandidacyPeriod.create(bean);
          break;
        } catch (final DomainException e) {
          addActionMessage("error", request, e.getKey(), e.getArgs());
          return createPhdCandidacyPeriodInvalid(mapping, form, request, response);
        }
      case INSTITUTION:
        try {
          InstitutionPhdCandidacyPeriod.create(bean);
          break;
        } catch (final DomainException e) {
          addActionMessage("error", request, e.getKey(), e.getArgs());
          return createPhdCandidacyPeriodInvalid(mapping, form, request, response);
        }
      default:
        throw new DomainException("error.PhdCandidacyPeriodBean.type.missing");
    }

    return list(mapping, form, request, response);
  }
  public String createCurricularCourse() {
    try {
      checkCourseGroup();
      checkCurricularSemesterAndYear();
      runCreateCurricularCourse();

    } catch (FenixActionException e) {
      this.addErrorMessage(BundleUtil.getString(Bundle.BOLONHA, e.getMessage()));
      return "";
    } catch (FenixServiceException e) {
      this.addErrorMessage(BundleUtil.getString(Bundle.BOLONHA, e.getMessage()));
      return "";
    } catch (DomainException e) {
      addErrorMessage(BundleUtil.getString(Bundle.DOMAIN_EXCEPTION, e.getMessage()));
      return "";
    } catch (Exception e) {
      this.addErrorMessage(BundleUtil.getString(Bundle.BOLONHA, "general.error"));
      return "buildCurricularPlan";
    }
    addInfoMessage(BundleUtil.getString(Bundle.BOLONHA, "curricularCourseCreated"));
    return "buildCurricularPlan";
  }
Example #25
0
  @Override
  public void editCandidacyPeriod(final YearMonthDay startDate, final YearMonthDay endDate) {
    final DelegateElectionCandidacyPeriod candidacyPeriod = getCandidacyPeriod();
    final DelegateElectionVotingPeriod votingPeriod = getVotingPeriod(startDate, endDate);

    if (candidacyPeriod.isPastPeriod()
        && votingPeriod != null
        && votingPeriod.getStartDate().isBefore(new YearMonthDay())) {
      throw new DomainException(
          "error.yearDelegateElections.edit.pastPeriod",
          new String[] {
            getDegree().getSigla(),
            getCurricularYear().getYear().toString(),
            getCandidacyPeriod().getPeriod()
          });
    } else {
      try {
        candidacyPeriod.delete();
        setCandidacyPeriod(new DelegateElectionCandidacyPeriod(startDate, endDate));
      } catch (DomainException ex) {
        throw new DomainException(ex.getMessage(), ex.getArgs());
      }
    }
  }
  public ActionForward create(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    DynaActionForm createContributorForm = (DynaActionForm) form;
    User userView = getUserView(request);

    final String contributorName = (String) createContributorForm.get("contributorName");
    try {
      Integer.valueOf((String) createContributorForm.get("contributorName"));

      ActionMessages errors = new ActionMessages();
      errors.add(
          "error.invalid.contributorName", new ActionMessage("error.invalid.contributorName"));
      saveErrors(request, errors);
      return mapping.findForward(prepareReadyForward);
    } catch (NumberFormatException e) {
      // do nothing, name is not a number, it's correct
    }

    Integer contributorNumber = null;
    try {
      contributorNumber = Integer.valueOf((String) createContributorForm.get("contributorNumber"));
      if (contributorNumber.intValue() == 0) {
        ActionMessages errors = new ActionMessages();
        errors.add(
            "error.invalid.contributorNumber",
            new ActionMessage("error.invalid.contributorNumber"));
        saveErrors(request, errors);
        return mapping.findForward(prepareReadyForward);
      }
    } catch (NumberFormatException e) {
      ActionMessages errors = new ActionMessages();
      errors.add(
          "error.invalid.contributorNumber", new ActionMessage("error.invalid.contributorNumber"));
      saveErrors(request, errors);
      return mapping.findForward(prepareReadyForward);
    }

    if (StringUtils.isEmpty(createContributorForm.getString("contributorType"))) {
      ActionMessages errors = new ActionMessages();
      errors.add(
          "error.invalid.contributorType", new ActionMessage("error.invalid.contributorType"));
      saveErrors(request, errors);
      return mapping.findForward(prepareReadyForward);
    }

    InfoContributor infoContributor = new InfoContributor();
    infoContributor.setContributorType(
        ContributorType.valueOf((String) createContributorForm.get("contributorType")));
    infoContributor.setContributorName(contributorName);
    infoContributor.setContributorNumber(contributorNumber.toString());
    infoContributor.setContributorAddress((String) createContributorForm.get("contributorAddress"));
    infoContributor.setAreaCode((String) createContributorForm.get("areaCode"));
    infoContributor.setAreaOfAreaCode((String) createContributorForm.get("areaOfAreaCode"));
    infoContributor.setArea((String) createContributorForm.get("area"));
    infoContributor.setParishOfResidence((String) createContributorForm.get("parishOfResidence"));
    infoContributor.setDistrictSubdivisionOfResidence(
        (String) createContributorForm.get("districtSubdivisionOfResidence"));
    infoContributor.setDistrictOfResidence(
        (String) createContributorForm.get("districtOfResidence"));

    Object args[] = {infoContributor};
    try {
      infoContributor.createContributor();
    } catch (DomainException e) {
      // Contributor number already exists
      ActionMessages errors = new ActionMessages();
      errors.add(e.getKey(), new ActionMessage(e.getKey()));
      saveErrors(request, errors);
      return mapping.findForward(prepareReadyForward);
    } catch (InvalidArgumentsServiceException e) {
      throw new ExistingActionException("O Contribuinte", e);
    }

    return mapping.findForward("CreateSuccess");
  }