示例#1
0
  public String getLastEnrolledExecutionYear() {
    if (getStudent() == null) {
      return "";
    }

    List<ExecutionYear> enrolmentsExecutionYears =
        new ArrayList<ExecutionYear>(getEnrolmentsExecutionYears(getStudent()));
    Collections.sort(enrolmentsExecutionYears, ExecutionYear.REVERSE_COMPARATOR_BY_YEAR);

    ExecutionYear lastEnrolledExecutionYear = null;

    if (enrolmentsExecutionYears.isEmpty()) {
      return "";
    }

    if (enrolmentsExecutionYears.size() == 1
        && ExecutionYear.readCurrentExecutionYear()
            .equals(enrolmentsExecutionYears.iterator().next())) {
      return "";
    } else if (ExecutionYear.readCurrentExecutionYear()
        .equals(enrolmentsExecutionYears.iterator().next())) {
      lastEnrolledExecutionYear = enrolmentsExecutionYears.get(1);
    } else {
      lastEnrolledExecutionYear = enrolmentsExecutionYears.iterator().next();
    }

    return ((Integer) lastEnrolledExecutionYear.getBeginCivilYear()).toString();
  }
  @Override
  public Object provide(Object source, Object currentValue) {

    final ExecutionYear currentYear = ExecutionYear.readCurrentExecutionYear();
    final ExecutionYear previousYear = currentYear.getPreviousExecutionYear();
    final List<ExecutionSemester> executionSemesters = new ArrayList<ExecutionSemester>();

    SpecialSeasonStudentEnrollmentBean bean = (SpecialSeasonStudentEnrollmentBean) source;
    if (bean.getScp()
        .getDegreeCurricularPlan()
        .hasOpenSpecialSeasonEnrolmentPeriod(currentYear.getLastExecutionPeriod())) {
      executionSemesters.add(currentYear.getLastExecutionPeriod());
    }
    if (bean.getScp()
        .getDegreeCurricularPlan()
        .hasOpenSpecialSeasonEnrolmentPeriod(currentYear.getFirstExecutionPeriod())) {
      executionSemesters.add(currentYear.getFirstExecutionPeriod());
    }
    if (bean.getScp()
        .getDegreeCurricularPlan()
        .hasOpenSpecialSeasonEnrolmentPeriod(previousYear.getLastExecutionPeriod())) {
      executionSemesters.add(previousYear.getLastExecutionPeriod());
    }
    if (bean.getScp()
        .getDegreeCurricularPlan()
        .hasOpenSpecialSeasonEnrolmentPeriod(previousYear.getFirstExecutionPeriod())) {
      executionSemesters.add(previousYear.getFirstExecutionPeriod());
    }

    Collections.sort(executionSemesters, ExecutionSemester.COMPARATOR_BY_SEMESTER_AND_YEAR);
    Collections.reverse(executionSemesters);
    return executionSemesters;
  }
示例#3
0
  private static Map<PhdProgramFocusArea, Set<PhdProgramPublicCandidacyHashCode>> getApplicants(
      final List<PhdProgramPublicCandidacyHashCode> unfocusAreaCandidates) {
    final Map<PhdProgramFocusArea, Set<PhdProgramPublicCandidacyHashCode>> candidates =
        new TreeMap<PhdProgramFocusArea, Set<PhdProgramPublicCandidacyHashCode>>(
            PhdProgramFocusArea.COMPARATOR_BY_NAME);

    for (final PublicCandidacyHashCode hashCode : Bennu.getInstance().getCandidacyHashCodesSet()) {
      if (hashCode.isFromPhdProgram() && hashCode.hasCandidacyProcess()) {

        final PhdProgramPublicCandidacyHashCode phdHashCode =
            (PhdProgramPublicCandidacyHashCode) hashCode;

        if (phdHashCode.getIndividualProgramProcess().getExecutionYear()
            != ExecutionYear.readCurrentExecutionYear()) {
          continue;
        }

        if (!PhdIndividualProgramCollaborationType.EPFL.equals(
            phdHashCode.getIndividualProgramProcess().getCollaborationType())) {
          continue;
        }

        if (!PhdIndividualProgramProcessState.CANDIDACY.equals(
            phdHashCode.getIndividualProgramProcess().getActiveState())) {
          continue;
        }

        //                if (phdHashCode.getPhdProgramCandidacyProcess().isValidatedByCandidate())
        // {
        addCandidate(unfocusAreaCandidates, candidates, phdHashCode);
        //                }
      }
    }
    return candidates;
  }
  public ActionForward showCandidates(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    final ExecutionYear currentExecutionYear = ExecutionYear.readCurrentExecutionYear();

    final YearDelegateElection yearDelegateElection =
        (YearDelegateElection)
            FenixFramework.getDomainObject(request.getParameter("selectedCandidacyPeriod"));
    Collection<Student> candidates = yearDelegateElection.getCandidatesSet();

    final ExecutionYear executionYear = yearDelegateElection.getExecutionYear();

    ElectionPeriodBean bean = new ElectionPeriodBean();
    bean.setCurricularYear(yearDelegateElection.getCurricularYear());
    bean.setDegree(yearDelegateElection.getDegree());
    bean.setDegreeType(yearDelegateElection.getDegree().getDegreeType());
    bean.setElection(yearDelegateElection);
    bean.setExecutionYear(executionYear);

    if (request.getParameter("showPhotos") != null) {
      request.setAttribute("candidatesWithPhotos", candidates);
    } else {
      request.setAttribute("candidatesWithoutPhotos", candidates);
    }

    request.setAttribute("currentExecutionYear", currentExecutionYear);
    request.setAttribute("electionPeriodBean", bean);
    return mapping.findForward("showCandidates");
  }
  public ActionForward showVotingResults(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    final String forwardTo = (String) getFromRequest(request, "forwardTo");

    final ExecutionYear currentExecutionYear = ExecutionYear.readCurrentExecutionYear();

    final YearDelegateElection yearDelegateElection =
        (YearDelegateElection)
            FenixFramework.getDomainObject(
                (String) getFromRequest(request, "selectedVotingPeriod"));

    final ExecutionYear executionYear = yearDelegateElection.getExecutionYear();

    List<DelegateElectionResultsByStudentDTO> electionResultsByStudentDTOList =
        yearDelegateElection.getLastVotingPeriod().getDelegateElectionResults();

    ElectionPeriodBean bean = new ElectionPeriodBean();
    bean.setCurricularYear(yearDelegateElection.getCurricularYear());
    bean.setDegree(yearDelegateElection.getDegree());
    bean.setDegreeType(yearDelegateElection.getDegree().getDegreeType());
    bean.setElection(yearDelegateElection);
    bean.setExecutionYear(executionYear);

    request.setAttribute("currentExecutionYear", currentExecutionYear);
    request.setAttribute("electionPeriodBean", bean);
    request.setAttribute("votingResultsByStudent", electionResultsByStudentDTOList);
    return mapping.findForward(forwardTo);
  }
  private ExecutionYear readExecutionYear(String year) {

    final ExecutionYear executionYear;
    if (year == null || year.equals("")) {
      executionYear = ExecutionYear.readCurrentExecutionYear();
    } else {
      executionYear = ExecutionYear.readExecutionYearByName(year);
    }
    return executionYear;
  }
  public ActionForward prepare(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    final ExecutionYear currentExecutionYear = ExecutionYear.readCurrentExecutionYear();

    ElectionPeriodBean bean = new ElectionPeriodBean();
    bean.setDegreeType(DegreeType.BOLONHA_INTEGRATED_MASTER_DEGREE); // default
    bean.setExecutionYear(currentExecutionYear); // default

    request.setAttribute("electionPeriodBean", bean);
    request.setAttribute("currentExecutionYear", currentExecutionYear);
    return selectDegreeType(mapping, actionForm, request, response);
  }
  public ActionForward prepareCreateNewImportationProcess(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {
    DgesBaseProcessBean bean = getRenderedBean();
    if (bean == null) {
      bean = new DgesBaseProcessBean(ExecutionYear.readCurrentExecutionYear());
    }

    RenderUtils.invalidateViewState("importation.bean");
    RenderUtils.invalidateViewState("importation.bean.edit");

    request.setAttribute("importationBean", bean);

    return mapping.findForward("prepare-create-new-process");
  }
  public ActionForward prepareCreateNewExportationCandidaciesForPasswordGenerationJob(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {
    DgesBaseProcessBean bean = getRenderedBean();
    if (bean == null) {
      bean = new DgesBaseProcessBean(ExecutionYear.readCurrentExecutionYear());
    }

    RenderUtils.invalidateViewState("importation.bean");
    RenderUtils.invalidateViewState("importation.bean.edit");

    request.setAttribute("importationBean", bean);

    return mapping.findForward(
        "prepare-create-new-exportation-candidacies-for-password-generation-job");
  }
  public ActionForward list(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {

    DgesBaseProcessBean bean = getRenderedBean();
    if (bean == null) {
      bean = new DgesBaseProcessBean(ExecutionYear.readCurrentExecutionYear());
    }

    RenderUtils.invalidateViewState("importation.bean");
    request.setAttribute("importationBean", bean);

    request.setAttribute(
        "importationJobsDone", DgesStudentImportationProcess.readDoneJobs(bean.getExecutionYear()));
    request.setAttribute(
        "importationJobsPending",
        DgesStudentImportationProcess.readUndoneJobs(bean.getExecutionYear()));
    request.setAttribute(
        "exportationPasswordsDone",
        ExportDegreeCandidaciesByDegreeForPasswordGeneration.readDoneJobs(bean.getExecutionYear()));
    request.setAttribute(
        "exportationPasswordsPending",
        ExportDegreeCandidaciesByDegreeForPasswordGeneration.readUndoneJobs(
            bean.getExecutionYear()));
    request.setAttribute(
        "exportationAlreadyStudentsDone",
        ExportExistingStudentsFromImportationProcess.readDoneJobs(bean.getExecutionYear()));
    request.setAttribute(
        "exportionAlreadyStudentsPending",
        ExportExistingStudentsFromImportationProcess.readUndoneJobs(bean.getExecutionYear()));

    request.setAttribute(
        "canRequestJobImportationProcess", DgesStudentImportationProcess.canRequestJob());
    request.setAttribute(
        "canRequestJobExportationPasswords",
        ExportDegreeCandidaciesByDegreeForPasswordGeneration.canRequestJob());
    request.setAttribute(
        "canRequestJobExportationAlreadyStudents",
        ExportExistingStudentsFromImportationProcess.canRequestJob());

    return mapping.findForward("list");
  }
  public ExecutionYear getExecutionYear() {
    String executionYearId = getExecutionYearID();

    ExecutionYear oldestContextExecutionYear =
        getDegreeCurricularPlan().getOldestContextExecutionYear();

    if (executionYearId != null) {
      return FenixFramework.getDomainObject(executionYearId);
    }

    ExecutionYear currentExecutionYear = ExecutionYear.readCurrentExecutionYear();

    if (oldestContextExecutionYear != null
        && oldestContextExecutionYear.isAfter(currentExecutionYear)) {
      return oldestContextExecutionYear;
    }

    return currentExecutionYear;
  }
  public ActionForward selectDegreeType(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    final String forwardTo = (String) getFromRequest(request, "forwardTo");
    final ExecutionYear currentExecutionYear = ExecutionYear.readCurrentExecutionYear();

    ElectionPeriodBean bean = (ElectionPeriodBean) getFromRequest(request, "electionPeriodBean");

    if (bean == null) {
      final Degree degree = FenixFramework.getDomainObject(request.getParameter("degreeOID"));

      bean = new ElectionPeriodBean();
      bean.setDegree(degree);
      bean.setDegreeType(degree.getDegreeType());
      bean.setExecutionYear(currentExecutionYear); // default
    } else {
      if (bean.getExecutionYear() == null) {
        bean.setExecutionYear(currentExecutionYear); // default
      }
      if (bean.getDegreeType() == null) {
        bean.setDegreeType(DegreeType.BOLONHA_INTEGRATED_MASTER_DEGREE); // default
      }
    }

    List<YearDelegateElectionsPeriodsByDegreeBean> electionsByDegree =
        new ArrayList<YearDelegateElectionsPeriodsByDegreeBean>();
    for (Degree degree : Degree.readAllByDegreeType(bean.getDegreeType())) {
      List<YearDelegateElection> elections =
          degree.getYearDelegateElectionsGivenExecutionYear(bean.getExecutionYear());
      YearDelegateElectionsPeriodsByDegreeBean electionBean =
          new YearDelegateElectionsPeriodsByDegreeBean(degree, bean.getExecutionYear(), elections);
      electionsByDegree.add(electionBean);
    }

    request.setAttribute("electionPeriodBean", bean);
    request.setAttribute("currentExecutionYear", currentExecutionYear);
    request.setAttribute("electionsByDegreeBean", electionsByDegree);
    return mapping.findForward(forwardTo);
  }
  protected List run(String teacherID, String executionYearID) throws FenixServiceException {

    final Teacher teacher = FenixFramework.getDomainObject(teacherID);
    if (teacher == null) {
      throw new DomainException("error.noTeacher");
    }

    final ExecutionYear executionYear;
    if (executionYearID == null) {
      executionYear = ExecutionYear.readCurrentExecutionYear();
    } else {
      executionYear = FenixFramework.getDomainObject(executionYearID);
    }

    final List<Professorship> responsibleFors = new ArrayList();
    for (final Professorship professorship : teacher.responsibleFors()) {
      if (professorship.getExecutionCourse().getExecutionPeriod().getExecutionYear()
          == executionYear) {
        responsibleFors.add(professorship);
      }
    }
    return getDetailedProfessorships(teacher.getProfessorships(executionYear), responsibleFors);
  }
 protected InfoExecutionYear getCurrentExecutionYear() {
   return InfoExecutionYear.newInfoFromDomain(ExecutionYear.readCurrentExecutionYear());
 }
  @SuppressWarnings("unchecked")
  private ByteArrayOutputStream createAcademicAdminProcessSheet(Person person) throws JRException {
    InputStream istream = getClass().getResourceAsStream(ACADEMIC_ADMIN_SHEET_REPORT_PATH);
    JasperReport report = (JasperReport) JRLoader.loadObject(istream);

    @SuppressWarnings("rawtypes")
    HashMap map = new HashMap();

    try {
      final Student student = person.getStudent();
      final Registration registration = findRegistration(student);

      map.put("executionYear", ExecutionYear.readCurrentExecutionYear().getYear());
      if (registration != null) {
        map.put("course", registration.getDegree().getNameI18N().toString());
      }
      map.put("studentNumber", student.getNumber().toString());
      map.put("fullName", person.getName());

      try {
        map.put(
            "photo",
            new ByteArrayInputStream(person.getPersonalPhotoEvenIfPending().getDefaultAvatar()));
      } catch (Exception e) {
        // nothing; print everything else
      }

      map.put(
          "sex",
          BundleUtil.getStringFromResourceBundle(
              "resources/EnumerationResources", person.getGender().name()));
      map.put("maritalStatus", person.getMaritalStatus().getPresentationName());
      map.put("profession", person.getProfession());
      map.put("idDocType", person.getIdDocumentType().getLocalizedName());
      map.put("idDocNumber", person.getDocumentIdNumber());

      YearMonthDay emissionDate = person.getEmissionDateOfDocumentIdYearMonthDay();
      if (emissionDate != null) {
        map.put(
            "idDocEmissionDate", emissionDate.toString(DateTimeFormat.forPattern("dd/MM/yyyy")));
      }

      map.put(
          "idDocExpirationDate",
          person
              .getExpirationDateOfDocumentIdYearMonthDay()
              .toString(DateTimeFormat.forPattern("dd/MM/yyyy")));
      map.put("idDocEmissionLocation", person.getEmissionLocationOfDocumentId());

      String nif = person.getSocialSecurityNumber();
      if (nif != null) {
        map.put("NIF", nif);
      }

      map.put(
          "birthDate",
          person.getDateOfBirthYearMonthDay().toString(DateTimeFormat.forPattern("dd/MM/yyyy")));
      map.put("nationality", person.getCountryOfBirth().getCountryNationality().toString());
      map.put("parishOfBirth", person.getParishOfBirth());
      map.put("districtSubdivisionOfBirth", person.getDistrictSubdivisionOfBirth());
      map.put("districtOfBirth", person.getDistrictOfBirth());
      map.put("countryOfBirth", person.getCountryOfBirth().getName());
      map.put("fathersName", person.getNameOfFather());
      map.put("mothersName", person.getNameOfMother());
      map.put("address", person.getAddress());
      map.put("postalCode", person.getPostalCode());
      map.put("locality", person.getAreaOfAreaCode());
      map.put("cellphoneNumber", person.getDefaultMobilePhoneNumber());
      map.put("telephoneNumber", person.getDefaultPhoneNumber());
      map.put("emailAddress", getMail(person));
      map.put(
          "currentDate",
          new java.text.SimpleDateFormat(
                  "'Lisboa, 'dd' de 'MMMM' de 'yyyy", new java.util.Locale("PT", "pt"))
              .format(new java.util.Date()));
    } catch (NullPointerException e) {
      // nothing; will cause printing of incomplete form
      // better than no form at all
    }

    JasperPrint print = JasperFillManager.fillReport(report, map);
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    JasperExportManager.exportReportToPdfStream(print, output);
    return output;
  }
示例#16
0
  @Override
  protected String getMessage(Thesis thesis) {
    Person currentPerson = AccessControl.getPerson();
    ExecutionYear executionYear = ExecutionYear.readCurrentExecutionYear();

    String title = thesis.getTitle().getContent();
    String year = executionYear.getYear();
    String degreeName = thesis.getDegree().getNameFor(executionYear).getContent();
    String studentName = thesis.getStudent().getPerson().getName();
    String studentNumber = thesis.getStudent().getNumber().toString();
    String presidentName = name(thesis.getPresident());
    String presidentAffiliation = affiliation(thesis.getPresident());
    String orientatorName = name(thesis.getOrientator());
    String orientatorAffiliation = affiliation(thesis.getOrientator());
    String coorientatorName = name(thesis.getCoorientator());
    String coorientatorAffiliation = affiliation(thesis.getCoorientator());
    String vowel1Name = name(thesis.getVowels(), 0);
    String vowel1Affiliation = affiliation(thesis.getVowels(), 0);
    String vowel2Name = name(thesis.getVowels(), 1);
    String vowel2Affiliation = affiliation(thesis.getVowels(), 1);
    String vowel3Name = name(thesis.getVowels(), 2);
    String vowel3Affiliation = affiliation(thesis.getVowels(), 2);

    String date = String.format(new Locale("pt"), "%1$td de %1$tB de %1$tY", new Date());
    String currentPersonName = currentPerson.getNickname();

    if (thesis.isCoordinator()) {
      return getMessage(
          COORDINATOR_BODY_KEY,
          year,
          degreeName,
          studentName,
          studentNumber,
          presidentName,
          presidentAffiliation,
          orientatorName,
          orientatorAffiliation,
          includeFlag(coorientatorName),
          coorientatorName,
          coorientatorAffiliation,
          includeFlag(vowel1Name),
          vowel1Name,
          vowel1Affiliation,
          includeFlag(vowel2Name),
          vowel2Name,
          vowel2Affiliation,
          includeFlag(vowel3Name),
          vowel3Name,
          vowel3Affiliation,
          date,
          currentPersonName);
    } else {
      return getMessage(
          BODY_KEY,
          year,
          degreeName,
          studentName,
          studentNumber,
          presidentName,
          presidentAffiliation,
          orientatorName,
          orientatorAffiliation,
          includeFlag(coorientatorName),
          coorientatorName,
          coorientatorAffiliation,
          includeFlag(vowel1Name),
          vowel1Name,
          vowel1Affiliation,
          includeFlag(vowel2Name),
          vowel2Name,
          vowel2Affiliation,
          includeFlag(vowel3Name),
          vowel3Name,
          vowel3Affiliation,
          date,
          currentPersonName);
    }
  }