Esempio n. 1
0
  private String renderYear(YearAnnouncementArchiveEntry year) {
    StringBuilder buffer = new StringBuilder();

    boolean first = true;
    for (int i = year.getFirstPostMonth(); i <= 12; i++) {
      MonthAnnouncementArchiveEntry month = year.getEntries().get(i);

      if (month != null && !first) {
        buffer.append(", ");
      }
      if (month != null && this.getTargetUrl() != null) {
        buffer.append("<a href=\"").append(this.getTargetUrl());
        buffer.append("selectedYear=").append(year.getYear());
        buffer.append("&amp;selectedMonth=").append(month.getMonth());
        buffer.append("\">");
      }
      if (month != null) {
        Locale locale = Language.getLocale();
        LocalDate localDate = new LocalDate();
        localDate = localDate.withMonthOfYear(month.getMonth());

        buffer.append(localDate.toString("MMM.", locale));
        buffer.append(" (");
        buffer.append(month.getAnnouncementCount());
        buffer.append(")");
        first = false;
      }
      if (month != null && this.getTargetUrl() != null) {
        buffer.append("</a>");
      }
    }
    return buffer.toString();
  }
Esempio n. 2
0
  @Override
  public String getEmailMessageBodyForRefereeForm(final PhdCandidacyReferee referee) {
    Locale locale = Language.getLocale();
    final ResourceBundle bundle = ResourceBundle.getBundle("resources.PhdResources", locale);

    return String.format(
        bundle.getString("message.phd.epfl.email.body.referee"),
        EPFLPhdCandidacyProcessProperties.getConfiguration().getPublicCandidacyRefereeFormLink(),
        referee.getValue());
  }
Esempio n. 3
0
 private String getAnnouncementBody(Thesis thesis, String key, Language language) {
   return getMessage(
       key,
       new Locale(language.toString()),
       thesis.getStudent().getPerson().getName(),
       getDate(thesis.getProposedDiscussed()),
       hasPlace(thesis),
       thesis.getProposedPlace(),
       hasTime(thesis.getProposedDiscussed()),
       getTime(thesis.getProposedDiscussed()),
       getString(thesis.getTitle(), language));
 }
  public static void executeTask() {
    final String ts = new DateTime().toString("yyyy-MM-dd HH:mm:ss");
    final VirtualHost virtualHost = VirtualHost.getVirtualHostForThread();

    List<String> toAddress = new ArrayList<String>();
    Language.setLocale(Language.getDefaultLocale());
    for (Person person : getPeopleToProcess()) {
      Authenticate.authenticate(person.getUsername(), StringUtils.EMPTY, false);
      Map<AcquisitionProcessStateType, MultiCounter<AcquisitionProcessStateType>>
          generateAcquisitionMap = ProcessMapGenerator.generateAcquisitionMap(person, true);
      Map<RefundProcessStateType, MultiCounter<RefundProcessStateType>> generateRefundMap =
          ProcessMapGenerator.generateRefundMap(person, true);

      if (!generateAcquisitionMap.isEmpty() || !generateRefundMap.isEmpty()) {
        toAddress.clear();
        try {
          final String email = person.getEmail();
          if (email != null) {
            final Sender sender = virtualHost.getSystemSender();
            final PersistentGroup group = SingleUserGroup.getOrCreateGroup(person.getUser());
            new Message(
                sender,
                Collections.EMPTY_SET,
                Collections.singleton(group),
                Collections.EMPTY_SET,
                Collections.EMPTY_SET,
                null,
                "Processos Pendentes - Aquisições",
                getBody(generateAcquisitionMap, generateRefundMap, virtualHost),
                null);
          }
        } catch (final Throwable ex) {
          System.out.println("Unable to lookup email address for: " + person.getUsername());
          // skip this person... keep going to next.
        }
      }
    }
  }
Esempio n. 5
0
  @Service
  public static void validateEmailBean(PhdProgramEmailBean bean) {
    final ResourceBundle resourceBundle =
        ResourceBundle.getBundle("resources.ApplicationResources", Language.getLocale());

    if (bean.getSelectedElements().isEmpty() && StringUtils.isEmpty(bean.getBccs())) {
      throw new DomainException(resourceBundle.getString("error.email.validation.no.recipients"));
    }

    if (StringUtils.isEmpty(bean.getSubject())) {
      throw new DomainException(resourceBundle.getString("error.email.validation.subject.empty"));
    }

    if (StringUtils.isEmpty(bean.getMessage())) {
      throw new DomainException(resourceBundle.getString("error.email.validation.message.empty"));
    }
  }
Esempio n. 6
0
 private void checkDates(JobOfferBean bean) {
   LocalDate beginDate = bean.getBeginDate();
   LocalDate endDate = bean.getEndDate();
   if (beginDate.isAfter(endDate)) {
     throw new DomainException(
         "message.jobOffer.beginDate.isAfter.endDate",
         ResourceBundle.getBundle(JobBankSystem.JOB_BANK_RESOURCES, Language.getLocale()));
   }
   int days = Days.daysBetween(bean.getBeginDate(), bean.getEndDate()).getDays();
   if (days < getMinNumberActiveDaysOffer()) {
     throw new DomainException(
         "message.error.jobOffer.min.active.days.offer",
         DomainException.getResourceFor(JobBankSystem.JOB_BANK_RESOURCES),
         getMinNumberActiveDaysOffer().toString());
   }
   if (days > getMaxNumberActiveDaysOffer()) {
     throw new DomainException(
         "message.error.jobOffer.max.active.days.offer",
         DomainException.getResourceFor(JobBankSystem.JOB_BANK_RESOURCES),
         getMaxNumberActiveDaysOffer().toString());
   }
 }
Esempio n. 7
0
  public static StyledExcelSpreadsheet exportElectionsResultsToFile(
      List<Degree> degrees, ExecutionYear executionYear) throws IOException {
    StyledExcelSpreadsheet spreadsheet = new StyledExcelSpreadsheet();
    final ResourceBundle BUNDLE =
        ResourceBundle.getBundle(
            "resources.PedagogicalCouncilResources", Language.getDefaultLocale());

    for (Degree degree : degrees) {
      spreadsheet.getSheet(degree.getSigla());
      List<YearDelegateElection> elections =
          sortByYear(degree.getYearDelegateElectionsGivenExecutionYear(executionYear));
      for (YearDelegateElection election : elections) {
        if (election.hasLastVotingPeriod()) {
          DelegateElectionVotingPeriod votingPeriod = election.getLastVotingPeriod();
          spreadsheet.newHeaderRow();
          int fistHeaderRow = spreadsheet.getRow().getRowNum();
          spreadsheet.addHeader(
              String.format(
                  "%s - %s (%s)",
                  BUNDLE.getString("label.elections.excel.curricularYear"),
                  election.getCurricularYear().getYear(),
                  votingPeriod.getPeriod()),
              10000);
          spreadsheet
              .getSheet()
              .addMergedRegion(new Region(fistHeaderRow, (short) 0, fistHeaderRow, (short) 5));
          spreadsheet.newRow();
          if (votingPeriod.getVotesCount() == 0) {
            spreadsheet.addCell(BUNDLE.getString("label.elections.excel.not.have.votes"));
          } else {
            spreadsheet.addHeader(BUNDLE.getString("label.elections.excel.studentNumber"), 6000);
            spreadsheet.addHeader(BUNDLE.getString("label.elections.excel.studentName"), 10000);
            spreadsheet.addHeader(BUNDLE.getString("label.phone"), 4000);
            spreadsheet.addHeader(BUNDLE.getString("label.email"), 6000);
            spreadsheet.addHeader(BUNDLE.getString("label.address"), 12000);
            spreadsheet.addHeader(BUNDLE.getString("label.elections.excel.nrTotalVotes"), 5000);
            List<DelegateElectionResultsByStudentDTO> resultsByStudent =
                sortByResults(votingPeriod.getDelegateElectionResults());
            for (DelegateElectionResultsByStudentDTO resultByStudent : resultsByStudent) {
              Student student = resultByStudent.getStudent();
              Person person = student.getPerson();
              String phone =
                  (StringUtils.isEmpty(person.getDefaultPhoneNumber()))
                      ? "-"
                      : person.getDefaultPhoneNumber();
              String email =
                  (StringUtils.isEmpty(person.getDefaultEmailAddressValue()))
                      ? "-"
                      : person.getDefaultEmailAddressValue();
              String address =
                  (StringUtils.isEmpty(person.getAddress())) ? "-" : person.getAddress();

              spreadsheet.newRow();
              spreadsheet.addCell(student.getNumber());
              spreadsheet.addCell(student.getName());
              spreadsheet.addCell(phone);
              spreadsheet.addCell(email);
              spreadsheet.addCell(address);
              spreadsheet.addCell(resultByStudent.getVotesNumber());
            }
            spreadsheet.setRegionBorder(fistHeaderRow, spreadsheet.getRow().getRowNum() + 1, 0, 2);
            spreadsheet.newRow();
            spreadsheet.newRow();
            spreadsheet.addCell(BUNDLE.getString("label.elections.excel.nrBlankTotalVotes"));
            spreadsheet.addCell(
                votingPeriod.getBlankVotesElection(), spreadsheet.getExcelStyle().getValueStyle());
          }
        }
        spreadsheet.newRow();
        spreadsheet.newRow();
      }
    }
    return spreadsheet;
  }
Esempio n. 8
0
 private String getAnnouncementSubject(Thesis thesis, String key, Language language) {
   return getMessage(
       key, new Locale(language.toString()), thesis.getStudent().getPerson().getName());
 }
 public String getEnumerationResourcesString(String name) {
   return ResourceBundle.getBundle("resources/EnumerationResources", Language.getLocale())
       .getString(name);
 }
Esempio n. 10
0
 @Override
 public final String getFilteredName(final ExecutionYear executionYear, final Locale locale) {
   return getNameFor(executionYear).getContent(Language.valueOf(locale.getLanguage()));
 }