Exemple #1
0
  private static void drawDocuments(
      final Page page, final PhdProgramPublicCandidacyHashCode hashCode, final String folderName)
      throws IOException {

    page.h(3, "Documents", "mtop2");

    final PhdIndividualProgramProcess process = hashCode.getIndividualProgramProcess();
    if (!process.getCandidacyProcessDocuments().isEmpty()) {

      final String documentName = folderName + "-documents.zip";
      final String url =
          APPLICATION_PREFIX_LINK
              + "/phd/epfl/applications/candidateDocuments?candidateOid="
              + hashCode.getExternalId();
      page.pStart("mbottom0").link(url, documentName).pEnd();

      page.tableStart("tstyle2 thwhite thnowrap thlight thleft thtop ulnomargin ");
      page.rowStart().header("Document type").header("Upload time").header("Filename").rowEnd();

      for (final PhdProgramProcessDocument document : process.getCandidacyProcessDocuments()) {
        page.rowStart().column(document.getDocumentType().getLocalizedName());
        page.column(document.getUploadTime().toString("dd/MM/yyyy HH:mm"));
        page.column(document.getFilename()).rowEnd();
      }

      page.tableEnd();
    }
  }
Exemple #2
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;
  }
Exemple #3
0
  private static void drawThesisRanking(
      Page page, PhdProgramPublicCandidacyHashCode hashCode, String email) throws IOException {

    page.h(3, "Thesis Rank", "mtop2");
    final PhdIndividualProgramProcess process = hashCode.getIndividualProgramProcess();

    page.tableStart("tstyle2");

    page.rowStart();
    page.header("Rank");
    page.header("Name");
    page.header("Teacher");
    page.header("Description");
    page.rowEnd();

    Collection<ThesisSubjectOrder> thesisSubjectOrders = process.getThesisSubjectOrdersSorted();

    for (ThesisSubjectOrder thesisSubjectOrder : thesisSubjectOrders) {
      page.rowStart();
      page.column(thesisSubjectOrder.getSubjectOrder().toString());
      page.column(thesisSubjectOrder.getThesisSubject().getName().getContent());
      page.column(
          thesisSubjectOrder.getThesisSubject().getTeacher() != null
              ? thesisSubjectOrder.getThesisSubject().getTeacher().getPerson().getName()
              : "");
      page.rowEnd();
    }

    page.tableEnd();
  }
Exemple #4
0
  private static void drawPhdIndividualProgramInformation(
      final Page page, final PhdProgramPublicCandidacyHashCode hashCode) throws IOException {
    final PhdIndividualProgramProcess process = hashCode.getIndividualProgramProcess();

    page.h(3, "Application information");
    page.tableStart("tstyle2 thwhite thnowrap thlight thleft thtop ulnomargin ");
    page.rowStart()
        .headerStartWithStyle("width: 125px;")
        .write("Candidacy Date:")
        .headerEnd()
        .column(process.getCandidacyDate().toString("dd/MM/yyyy"))
        .rowEnd();
    page.rowStart()
        .header("Area:")
        .column(process.getPhdProgramFocusArea().getName().getContent())
        .rowEnd();
    page.rowStart()
        .header(Unit.getInstitutionAcronym() + " Phd Program:")
        .column(process.getPhdProgram().getName().getContent(MultiLanguageString.en))
        .rowEnd();
    if (process.getExternalPhdProgram() != null) {
      page.rowStart()
          .header("EPFL Phd Program:")
          .column(process.getExternalPhdProgram().getName().getContent(MultiLanguageString.en));
    }
    page.rowStart().header("Title:").column(string(process.getThesisTitle())).rowEnd();
    page.rowStart().header("Collaboration:").column(process.getCollaborationTypeName()).rowEnd();
    page.rowStart().header("Year:").column(process.getExecutionYear().getYear()).rowEnd();
    page.tableEnd();
  }
Exemple #5
0
  private static void addCandidate(
      final List<PhdProgramPublicCandidacyHashCode> unfocusAreaCandidates,
      final Map<PhdProgramFocusArea, Set<PhdProgramPublicCandidacyHashCode>> candidates,
      final PhdProgramPublicCandidacyHashCode hashCode) {

    final PhdProgramFocusArea focusArea =
        hashCode.getIndividualProgramProcess().getPhdProgramFocusArea();

    if (focusArea == null) {
      unfocusAreaCandidates.add(hashCode);
      return;
    }

    if (!candidates.containsKey(focusArea)) {
      candidates.put(
          focusArea,
          new TreeSet<PhdProgramPublicCandidacyHashCode>(
              new Comparator<PhdProgramPublicCandidacyHashCode>() {

                @Override
                public int compare(
                    PhdProgramPublicCandidacyHashCode o1, PhdProgramPublicCandidacyHashCode o2) {
                  return o1.getPerson().getName().compareTo(o2.getPerson().getName());
                }
              }));
    }

    candidates.get(focusArea).add(hashCode);
  }
Exemple #6
0
  static byte[] drawCandidatePage(final PhdProgramPublicCandidacyHashCode hashCode)
      throws IOException {
    final String email = hashCode.getEmail().substring(0, hashCode.getEmail().indexOf("@"));
    final Page page = new Page();

    page.h2(APPLICATION_NAME);
    drawPersonalInformation(page, hashCode, email);
    drawPhdIndividualProgramInformation(page, hashCode);
    drawGuidings(page, hashCode);
    drawQualifications(page, hashCode);
    drawCandidacyReferees(page, hashCode, email);
    drawDocuments(page, hashCode, email);
    drawThesisRanking(page, hashCode, email);

    page.close();
    return page.toByteArray();
  }
Exemple #7
0
  static byte[] exportPresentationPage() throws IOException {
    List<PhdProgramPublicCandidacyHashCode> unfocusAreaCandidates =
        new ArrayList<PhdProgramPublicCandidacyHashCode>();

    final Page page = new Page();
    page.h2(APPLICATION_NAME);

    for (final Entry<PhdProgramFocusArea, Set<PhdProgramPublicCandidacyHashCode>> entry :
        getApplicants(unfocusAreaCandidates).entrySet()) {
      page.h(3, getFocusAreaTitle(entry), "mtop2");

      page.ulStart();
      for (final PhdProgramPublicCandidacyHashCode code : entry.getValue()) {
        final String url =
            APPLICATION_PREFIX_LINK + "/phd/epfl/applications/show?process=" + code.getValue();
        page.liStart().link(url, code.getPerson().getName()).liEnd();
      }
      page.ulEnd();
    }

    page.close();

    return page.toByteArray();
  }
Exemple #8
0
  private static void drawGuidings(
      final Page page, final PhdProgramPublicCandidacyHashCode hashCode) throws IOException {
    final PhdIndividualProgramProcess process = hashCode.getIndividualProgramProcess();
    page.h(3, "Phd supervisors (if applicable)", "mtop2");

    if (!process.getGuidingsSet().isEmpty()) {
      int count = 1;
      for (final PhdParticipant guiding : process.getGuidingsSet()) {
        page.pStart("mbottom0").strong(String.valueOf(count) + ". ").pEnd();
        drawGuiding(page, guiding);
        count++;
      }
    } else {
      page.pStart().write("Not defined").pEnd();
    }
  }
Exemple #9
0
  private static void drawQualifications(
      final Page page, final PhdProgramPublicCandidacyHashCode hashCode) throws IOException {
    final PhdIndividualProgramProcess process = hashCode.getIndividualProgramProcess();
    page.h(3, "Academic Degrees", "mtop2");

    if (!process.getQualifications().isEmpty()) {
      int count = 1;
      for (final Qualification qualification : process.getQualifications()) {
        page.pStart("mbottom0").strong(String.valueOf(count) + ". ").pEnd();
        drawQualification(page, qualification);
        count++;
      }
    } else {
      page.pStart().write("Not defined").pEnd();
    }
  }
Exemple #10
0
  private static void drawCandidacyReferees(
      final Page page, final PhdProgramPublicCandidacyHashCode hashCode, final String folderName)
      throws IOException {
    final PhdIndividualProgramProcess process = hashCode.getIndividualProgramProcess();
    page.h(3, "Reference letters (referees)", "mtop2");

    if (!process.getPhdCandidacyReferees().isEmpty()) {
      int count = 1;
      for (final PhdCandidacyReferee referee : process.getPhdCandidacyReferees()) {
        page.pStart("mbottom0").strong(String.valueOf(count) + ". ").pEnd();
        drawReferee(page, referee, count, folderName);
        count++;
      }
    } else {
      page.pStart().write("Not defined").pEnd();
    }
  }
Exemple #11
0
  static byte[] createZip(final PhdProgramPublicCandidacyHashCode hashCode) {

    final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    ZipOutputStream zip = null;
    try {
      zip = new ZipOutputStream(outputStream);

      int count = 1;
      for (final PhdProgramProcessDocument document :
          hashCode.getIndividualProgramProcess().getCandidacyProcessDocuments()) {
        final ZipEntry zipEntry = new ZipEntry(count + "-" + document.getFilename());
        zip.putNextEntry(zipEntry);

        // TODO: use in local context copy(new ByteArrayInputStream(new
        // byte[20]), zip);
        copy(document.getStream(), zip);

        zip.closeEntry();
        count++;
      }
    } catch (FileNotFoundException e) {
      logger.error(e.getMessage(), e);
    } catch (IOException e) {
      logger.error(e.getMessage(), e);
    } finally {
      if (zip != null) {
        try {
          zip.flush();
          zip.close();
        } catch (IOException e) {
          logger.error(e.getMessage(), e);
        }
      }
    }
    return outputStream.toByteArray();
  }
Exemple #12
0
  private static void drawPersonalInformation(
      final Page page, final PhdProgramPublicCandidacyHashCode hashCode, final String folderName)
      throws IOException {

    final Person person = hashCode.getPerson();

    page.h(3, "Personal Information", "mtop2");
    page.tableStart("tstyle2 thwhite thnowrap thlight thleft thtop ulnomargin ");

    page.rowStart("tdbold")
        .headerStartWithStyle("width: 125px;")
        .write("Name:")
        .headerEnd()
        .column(person.getName())
        .rowEnd();
    page.rowStart()
        .header("Gender:")
        .column(person.getGender().toLocalizedString(Locale.ENGLISH))
        .rowEnd();
    page.rowStart()
        .header("Identity card type:")
        .column(person.getIdDocumentType().getLocalizedName())
        .rowEnd();
    page.rowStart().header("Identity card #:").column(person.getDocumentIdNumber()).rowEnd();
    page.rowStart().header("Issued by:").column(person.getEmissionLocationOfDocumentId()).rowEnd();
    page.rowStart()
        .header("Fiscal number:")
        .column(string(person.getSocialSecurityNumber()))
        .rowEnd();
    page.rowStart()
        .header("Date of birth:")
        .column(person.getDateOfBirthYearMonthDay().toString("dd/MM/yyyy"))
        .rowEnd();
    page.rowStart().header("Birthplace:").column(person.getDistrictSubdivisionOfBirth()).rowEnd();
    page.rowStart()
        .header("Nationality:")
        .column(person.getCountry().getCountryNationality().getContent())
        .rowEnd();
    page.rowStart().header("Address:").column(person.getAddress()).rowEnd();
    page.rowStart().header("City:").column(person.getArea()).rowEnd();
    page.rowStart().header("Zip code:").column(person.getAreaCode()).rowEnd();
    page.rowStart()
        .header("Country:")
        .column(
            (person.getCountryOfResidence() != null
                ? person.getCountryOfResidence().getName()
                : "-"))
        .rowEnd();
    page.rowStart().header("Phone:").column(person.getDefaultPhoneNumber()).rowEnd();
    page.rowStart().header("Mobile:").column(person.getDefaultMobilePhoneNumber()).rowEnd();
    page.rowStart().header("Email:").column(person.getDefaultEmailAddressValue()).rowEnd();

    page.tableEnd();

    page.h(3, "Photo");
    String photoUrl = APPLICATION_PREFIX_LINK + "/phd/epfl/applications/photo";
    final Photograph photo = person.getPersonalPhotoEvenIfPending();
    if (photo != null) {
      photoUrl += "?photoOid=" + photo.getExternalId();
    }
    page.photo(photoUrl);
  }