public ActionForward selectPersonForCandidacy(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response) {

    final IndividualCandidacyProcessBean bean = getIndividualCandidacyProcessBean();
    request.setAttribute(getIndividualCandidacyProcessBeanName(), bean);

    if (!bean.hasChoosenPerson()) {
      addActionMessage(request, "error.candidacy.must.select.any.person");
      return mapping.findForward("prepare-create-new-process");
    }

    if (existsIndividualCandidacyProcessForDocumentId(
        request,
        bean.getChoosePersonBean().getPerson().getIdDocumentType(),
        bean.getChoosePersonBean().getPerson().getDocumentIdNumber())) {
      addActionMessage(request, "error.candidacy.already.exists.for.this.person");
      return mapping.findForward("prepare-create-new-process");
    }

    bean.setPersonBean(new PersonBean(bean.getChoosePersonBean().getPerson()));
    bean.removeChoosePersonBean();
    return mapping.findForward("fill-personal-information");
  }
  public ActionForward fillPersonalInformation(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response) {

    final IndividualCandidacyProcessBean bean = getIndividualCandidacyProcessBean();
    final ChoosePersonBean choosePersonBean = bean.getChoosePersonBean();
    request.setAttribute(getIndividualCandidacyProcessBeanName(), bean);
    bean.setPersonBean(
        new PersonBean(
            choosePersonBean.getName(),
            choosePersonBean.getIdentificationNumber(),
            choosePersonBean.getDocumentType(),
            choosePersonBean.getDateOfBirth()));

    // bean.getPersonBean().setAddress("Some address");
    // bean.getPersonBean().setArea("Some area");
    // bean.getPersonBean().setAreaOfAreaCode("2345-2341");
    // bean.getPersonBean().setCountryOfBirth(Country.readByTwoLetterCode("AF"));
    // bean.getPersonBean().setCountryOfResidence(Country.readByTwoLetterCode("PT"));
    // bean.getPersonBean().setDistrictOfBirth("Some district of birth");
    // bean.getPersonBean().setDistrictOfResidence("Some district of residence");
    // bean.getPersonBean().setDistrictSubdivisionOfBirth("district subdivision of birth");
    // bean.getPersonBean().setDistrictSubdivisionOfResidence("district subdivision of residence");
    // bean.getPersonBean().setGender(Gender.MALE);
    // bean.getPersonBean().setPhone("12313234132");
    // bean.getPersonBean().setNationality(Country.readByTwoLetterCode("AF"));
    // bean.getPersonBean().setAreaCode("1223-123");

    bean.removeChoosePersonBean();
    return mapping.findForward("fill-personal-information");
  }
  public ActionForward searchPersonForCandidacy(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response) {

    final IndividualCandidacyProcessBean bean = getIndividualCandidacyProcessBean();
    request.setAttribute(getIndividualCandidacyProcessBeanName(), bean);

    final ChoosePersonBean choosePersonBean = bean.getChoosePersonBean();

    if (!choosePersonBean.hasPerson()) {
      if (choosePersonBean.isFirstTimeSearch()) {
        final Collection<Person> persons =
            Person.findPersonByDocumentID(choosePersonBean.getIdentificationNumber());
        choosePersonBean.setFirstTimeSearch(false);
        if (showSimilarPersons(choosePersonBean, persons)) {
          RenderUtils.invalidateViewState();
          return mapping.findForward("prepare-create-new-process");
        }
      }
      bean.setPersonBean(
          new PersonBean(
              choosePersonBean.getName(),
              choosePersonBean.getIdentificationNumber(),
              choosePersonBean.getDocumentType(),
              choosePersonBean.getDateOfBirth()));

      // bean.getPersonBean().setAddress("Some address");
      // bean.getPersonBean().setArea("Some area");
      // bean.getPersonBean().setAreaOfAreaCode("2345-2341");
      // //bean.getPersonBean().setCountryOfBirth(Country.readByTwoLetterCode("AF"));
      // bean.getPersonBean().setCountryOfResidence(Country.readByTwoLetterCode("PT"));
      // bean.getPersonBean().setDistrictOfBirth("Some district of birth");
      // bean.getPersonBean().setDistrictOfResidence("Some district of residence");
      // bean.getPersonBean().setDistrictSubdivisionOfBirth("district subdivision of birth");
      // bean.getPersonBean().setDistrictSubdivisionOfResidence("district subdivision of
      // residence");
      // bean.getPersonBean().setGender(Gender.MALE);
      // bean.getPersonBean().setPhone("12313234132");
      // bean.getPersonBean().setNationality(Country.readByTwoLetterCode("AF"));
      // bean.getPersonBean().setAreaCode("1223-123");

      return mapping.findForward("fill-personal-information");

    } else {
      bean.setPersonBean(new PersonBean(bean.getChoosePersonBean().getPerson()));

      // bean.getPersonBean().setAddress("Some address");
      // bean.getPersonBean().setArea("Some area");
      // bean.getPersonBean().setAreaOfAreaCode("2345-2341");
      // bean.getPersonBean().setCountryOfBirth(Country.readByTwoLetterCode("AF"));
      // bean.getPersonBean().setCountryOfResidence(Country.readByTwoLetterCode("PT"));
      // bean.getPersonBean().setDistrictOfBirth("Some district of birth");
      // bean.getPersonBean().setDistrictOfResidence("Some district of residence");
      // bean.getPersonBean().setDistrictSubdivisionOfBirth("district subdivision of birth");
      // bean.getPersonBean().setDistrictSubdivisionOfResidence("district subdivision of
      // residence");
      // bean.getPersonBean().setGender(Gender.MALE);
      // bean.getPersonBean().setPhone("12313234132");
      // bean.getPersonBean().setNationality(Country.readByTwoLetterCode("AF"));
      // bean.getPersonBean().setAreaCode("1223-123");

      return mapping.findForward("fill-personal-information");
    }
  }