Ejemplo n.º 1
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;
  }
Ejemplo n.º 2
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();
  }
Ejemplo n.º 3
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();
    }
  }
Ejemplo n.º 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();
  }
Ejemplo n.º 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);
  }
Ejemplo n.º 6
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();
    }
  }
Ejemplo n.º 7
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();
    }
  }
Ejemplo n.º 8
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();
    }
  }
Ejemplo n.º 9
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();
  }