Example usage for org.joda.time DateTime getYear

List of usage examples for org.joda.time DateTime getYear

Introduction

In this page you can find the example usage for org.joda.time DateTime getYear.

Prototype

public int getYear() 

Source Link

Document

Get the year field value.

Usage

From source file:org.epics.archiverappliance.common.TimeUtils.java

/**
 * Returns a partition name for the given epoch second based on the partition granularity.
 * //ww  w.j ava  2  s .  c  o  m
 * @param epochseconds
 * @return
 */
public static String getPartitionName(long epochSeconds, PartitionGranularity granularity) {
    DateTime dateTime = new DateTime(epochSeconds * 1000, DateTimeZone.UTC);
    switch (granularity) {
    case PARTITION_YEAR:
        return "" + dateTime.getYear();
    case PARTITION_MONTH:
        return "" + dateTime.getYear() + "_"
                + (dateTime.getMonthOfYear() < 10 ? TWO_DIGIT_EXPANSIONS[dateTime.getMonthOfYear()]
                        : dateTime.getMonthOfYear());
    case PARTITION_DAY:
        return "" + dateTime.getYear() + "_"
                + (dateTime.getMonthOfYear() < 10 ? TWO_DIGIT_EXPANSIONS[dateTime.getMonthOfYear()]
                        : dateTime.getMonthOfYear())
                + "_" + (dateTime.getDayOfMonth() < 10 ? TWO_DIGIT_EXPANSIONS[dateTime.getDayOfMonth()]
                        : dateTime.getDayOfMonth());
    case PARTITION_HOUR:
        return "" + dateTime.getYear() + "_"
                + (dateTime.getMonthOfYear() < 10 ? TWO_DIGIT_EXPANSIONS[dateTime.getMonthOfYear()]
                        : dateTime.getMonthOfYear())
                + "_"
                + (dateTime.getDayOfMonth() < 10 ? TWO_DIGIT_EXPANSIONS[dateTime.getDayOfMonth()]
                        : dateTime.getDayOfMonth())
                + "_" + (dateTime.getHourOfDay() < 10 ? TWO_DIGIT_EXPANSIONS[dateTime.getHourOfDay()]
                        : dateTime.getHourOfDay());
    case PARTITION_5MIN:
    case PARTITION_15MIN:
    case PARTITION_30MIN:
        int approxMinutesPerChunk = granularity.getApproxMinutesPerChunk();
        int startOfPartition_Min = (dateTime.getMinuteOfHour() / approxMinutesPerChunk) * approxMinutesPerChunk;
        return "" + dateTime.getYear() + "_"
                + (dateTime.getMonthOfYear() < 10 ? TWO_DIGIT_EXPANSIONS[dateTime.getMonthOfYear()]
                        : dateTime.getMonthOfYear())
                + "_"
                + (dateTime.getDayOfMonth() < 10 ? TWO_DIGIT_EXPANSIONS[dateTime.getDayOfMonth()]
                        : dateTime.getDayOfMonth())
                + "_"
                + (dateTime.getHourOfDay() < 10 ? TWO_DIGIT_EXPANSIONS[dateTime.getHourOfDay()]
                        : dateTime.getHourOfDay())
                + "_" + (startOfPartition_Min < 10 ? TWO_DIGIT_EXPANSIONS[startOfPartition_Min]
                        : startOfPartition_Min);
    default:
        throw new UnsupportedOperationException("Invalid Partition type " + granularity);
    }
}

From source file:org.everit.jira.core.impl.TimetrackerComponent.java

License:Apache License

private List<DateTime> getExtraDaysOfTheMonth(final DateTime dateForMonth, final Set<DateTime> extraDates) {
    List<DateTime> resultExtraDays = new ArrayList<>();
    for (DateTime extraDate : extraDates) {
        if ((extraDate.getMonthOfYear() == dateForMonth.getMonthOfYear())
                && (extraDate.getYear() == dateForMonth.getYear())
                && (extraDate.getEra() == dateForMonth.getEra())) {
            resultExtraDays.add(extraDate);
        }/*from   w ww . j  a  v a2 s  .c o m*/
    }
    return resultExtraDays;
}

From source file:org.everit.jira.core.util.TimetrackerUtil.java

License:Apache License

/**
 * Check the date is contains the dates or not.
 *
 * @param dates//www .ja  v a2  s  . c  o  m
 *          the dates set.
 * @param date
 *          the date that check contains.
 * @return true if contains, otherwise false.
 */
public static boolean containsSetTheSameDay(final Set<DateTime> dates, final DateTime date) {
    for (DateTime d : dates) {
        if ((d.getYear() == date.getYear()) && (d.getDayOfYear() == date.getDayOfYear())) {
            return true;
        }
    }
    return false;
}

From source file:org.everit.jira.timetracker.plugin.util.DateTimeConverterUtil.java

License:Apache License

/**
 * Convert joda DateTime to java Date. Convert the date and time without Time Zone correction.
 * (the joda DateTime toDate metod add the time zone).
 *
 * @param dateTime/*from  w  ww  . java2s  .c  o m*/
 *          The dateTime.
 * @return The new date.
 */
@SuppressWarnings("deprecation")
public static Date convertDateTimeToDate(final DateTime dateTime) {
    return new Date(dateTime.getYear() - YEAR_1900, dateTime.getMonthOfYear() - 1, dateTime.getDayOfMonth(),
            dateTime.getHourOfDay(), dateTime.getMinuteOfHour(), dateTime.getSecondOfMinute());
}

From source file:org.fam.jsf.bootstrap.Bootstrap.java

private void createSeasons() {
    try {/*from w w  w. j a v a  2  s .c  o  m*/
        DateTime dt = new DateTime();
        int year = dt.getYear();
        for (int i = 0; i < 5; i++) {
            FamSeason s = new FamSeason();
            String lib = String.format("%d/%d", year - i, year - i + 1);
            s.setLibSeason(lib);
            s.setCurrentSeason(i == 0);

            ejbSeason.create(s);
            listSeason.add(s);
        }
    } catch (Exception e) {
        String msg = "create seasons failed";
        logErrorMsg(msg, e);

    }
}

From source file:org.fenixedu.academic.domain.reports.RaidesCommonReportFieldsWrapper.java

License:Open Source License

public static Row reportRaidesFields(final Spreadsheet sheet, final Registration registration,
        StudentCurricularPlan studentCurricularPlan, List<Registration> registrationPath,
        ExecutionYear executionYear, final CycleType cycleType, final boolean concluded,
        final YearMonthDay conclusionDate, BigDecimal average, boolean graduation) {

    final Row row = sheet.addRow();
    final Person graduate = registration.getPerson();
    //List<Registration> registrationPath = getFullRegistrationPath(registration);
    Registration sourceRegistration = registrationPath.iterator().next();
    final PersonalInformationBean personalInformationBean = registration
            .getPersonalInformationBean(executionYear);

    // Ciclo/*from w w  w .j  a v  a2 s . c om*/
    row.setCell(cycleType.getDescription());

    // Concludo
    row.setCell(String.valueOf(concluded));

    // Mdia do Ciclo
    if (graduation) {
        row.setCell(concluded ? printBigDecimal(average.setScale(0, BigDecimal.ROUND_HALF_EVEN))
                : printBigDecimal(average));
    } else {
        row.setCell(
                concluded ? studentCurricularPlan.getCycle(cycleType).getCurriculum().getRawGrade().getValue()
                        : "n/a");
    }

    // Data de Concluso
    row.setCell(conclusionDate != null ? conclusionDate.toString("dd-MM-yyyy") : "");

    // Data de Incio
    row.setCell(registration.getStartDate() != null ? registration.getStartDate().toString("dd-MM-yyyy") : "");

    // N de aluno
    row.setCell(registration.getNumber());

    // Nome de Utilizador
    row.setCell(registration.getPerson().getUsername());

    // Tipo Identificao
    row.setCell(graduate.getIdDocumentType().getLocalizedName());

    // N de Identificao
    row.setCell(graduate.getDocumentIdNumber());

    // Dgitos de Controlo
    row.setCell(graduate.getIdentificationDocumentExtraDigitValue());

    // Verso Doc. Identificao
    row.setCell(graduate.getIdentificationDocumentSeriesNumberValue());

    // Nome
    row.setCell(registration.getName());

    // Sexo
    row.setCell(graduate.getGender().toString());

    // Data de Nascimento
    row.setCell(graduate.getDateOfBirthYearMonthDay() != null
            ? graduate.getDateOfBirthYearMonthDay().toString("dd-MM-yyyy")
            : "n/a");

    // Pas de Nascimento
    row.setCell(graduate.getCountryOfBirth() != null ? graduate.getCountryOfBirth().getName() : "n/a");

    // Pas de Nacionalidade
    row.setCell(graduate.getCountry() != null ? graduate.getCountry().getName() : "n/a");

    // Tipo Curso
    row.setCell(registration.getDegreeType().getName().getContent());

    // Nome Curso
    row.setCell(registration.getDegree().getNameI18N().getContent());

    // Sigla Curso
    row.setCell(registration.getDegree().getSigla());

    // Ramos do currculo do aluno
    final StringBuilder majorBranches = new StringBuilder();
    final StringBuilder minorBranches = new StringBuilder();
    for (final BranchCurriculumGroup group : studentCurricularPlan.getBranchCurriculumGroups()) {
        if (group.isMajor()) {
            majorBranches.append(group.getName().getContent()).append(",");
        } else if (group.isMinor()) {
            minorBranches.append(group.getName().getContent()).append(",");
        }
    }

    // Ramo Principal
    if (majorBranches.length() > 0) {
        row.setCell(majorBranches.deleteCharAt(majorBranches.length() - 1).toString());
    } else {
        row.setCell("");
    }

    // Ramo Secundro
    if (minorBranches.length() > 0) {
        row.setCell(minorBranches.deleteCharAt(minorBranches.length() - 1).toString());
    } else {
        row.setCell("");
    }

    // Ano Curricular
    row.setCell(registration.getCurricularYear(executionYear));

    // Ano de Ingresso no Curso Actual
    row.setCell(sourceRegistration.getStartExecutionYear().getName());

    // N de anos lectivos de inscrio no Curso actual
    int numberOfEnrolmentYears = 0;
    for (Registration current : registrationPath) {
        numberOfEnrolmentYears += current.getNumberOfYearsEnrolledUntil(executionYear);
    }
    row.setCell(numberOfEnrolmentYears);

    // ltimo ano em que esteve inscrito
    row.setCell(registration.getLastEnrolmentExecutionYear() != null
            ? registration.getLastEnrolmentExecutionYear().getName()
            : "");

    // Regime de frequncia curso: Tempo integral/Tempo Parcial
    row.setCell(registration.getRegimeType(executionYear) != null
            ? registration.getRegimeType(executionYear).getName()
            : "");

    // Tipo de Aluno (AFA, AM, ERASMUS, etc)
    row.setCell(
            registration.getRegistrationProtocol() != null ? registration.getRegistrationProtocol().getCode()
                    : "");

    // Regime de Ingresso no Curso Actual (cdigo)
    IngressionType ingressionType = sourceRegistration.getIngressionType();
    if (ingressionType == null && sourceRegistration.getStudentCandidacy() != null) {
        ingressionType = sourceRegistration.getStudentCandidacy().getIngressionType();
    }
    row.setCell(ingressionType != null ? ingressionType.getCode() : "");

    // Regime de Ingresso no Curso Actual (designao)
    row.setCell(ingressionType != null ? ingressionType.getDescription().getContent() : "");

    // estabelecimento do grau preced.: Instituio onde esteve
    // inscrito mas no obteve grau, (e.g: transferencias, mudanas de
    // curso...)
    row.setCell(personalInformationBean.getPrecedentInstitution() != null
            ? personalInformationBean.getPrecedentInstitution().getName()
            : "");
    // curso grau preced.
    row.setCell(personalInformationBean.getPrecedentDegreeDesignation() != null
            ? personalInformationBean.getPrecedentDegreeDesignation()
            : "");

    // estabelec. curso habl anterior compl (se o aluno ingressou por uma via
    // diferente CNA, e deve ser IST caso o aluno tenha estado matriculado noutro curso do IST)
    row.setCell(personalInformationBean.getInstitution() != null
            ? personalInformationBean.getInstitution().getName()
            : "");

    // curso habl anterior compl (se o aluno ingressou por uma via diferente CNA, e
    // deve ser IST caso o aluno tenha estado matriculado noutro curso do IST)
    row.setCell(personalInformationBean.getDegreeDesignation());

    // n inscries no curso preced. (conta uma por cada ano)
    row.setCell(personalInformationBean.getNumberOfPreviousYearEnrolmentsInPrecedentDegree() != null
            ? personalInformationBean.getNumberOfPreviousYearEnrolmentsInPrecedentDegree().toString()
            : "");

    // Nota de Ingresso
    Double entryGrade = null;
    if (registration.getStudentCandidacy() != null) {
        entryGrade = registration.getStudentCandidacy().getEntryGrade();
    }

    row.setCell(printDouble(entryGrade));

    // Opo de Ingresso
    Integer placingOption = null;
    if (registration.getStudentCandidacy() != null) {
        placingOption = registration.getStudentCandidacy().getPlacingOption();
    }

    row.setCell(placingOption);

    // Estado Civil
    row.setCell(personalInformationBean.getMaritalStatus() != null
            ? personalInformationBean.getMaritalStatus().toString()
            : registration.getPerson().getMaritalStatus().toString());

    // Pas de Residncia Permanente
    if (personalInformationBean.getCountryOfResidence() != null) {
        row.setCell(personalInformationBean.getCountryOfResidence().getName());
    } else {
        row.setCell(registration.getStudent().getPerson().getCountryOfResidence() != null
                ? registration.getStudent().getPerson().getCountryOfResidence().getName()
                : "");
    }

    // Distrito de Residncia Permanente
    if (personalInformationBean.getDistrictSubdivisionOfResidence() != null) {
        row.setCell(personalInformationBean.getDistrictSubdivisionOfResidence().getDistrict().getName());
    } else {
        row.setCell(registration.getStudent().getPerson().getDistrictOfResidence());
    }

    // Concelho de Residncia Permanente
    if (personalInformationBean.getDistrictSubdivisionOfResidence() != null) {
        row.setCell(personalInformationBean.getDistrictSubdivisionOfResidence().getName());
    } else {
        row.setCell(registration.getStudent().getPerson().getDistrictSubdivisionOfResidence());
    }

    // Deslocado da Residncia Permanente
    if (personalInformationBean.getDislocatedFromPermanentResidence() != null) {
        row.setCell(personalInformationBean.getDislocatedFromPermanentResidence().toString());
    } else {
        row.setCell("");
    }

    // Nvel de Escolaridade do Pai
    if (personalInformationBean.getFatherSchoolLevel() != null) {
        row.setCell(personalInformationBean.getFatherSchoolLevel().getName());
    } else {
        row.setCell("");
    }

    // Nvel de Escolaridade da Me
    if (personalInformationBean.getMotherSchoolLevel() != null) {
        row.setCell(personalInformationBean.getMotherSchoolLevel().getName());
    } else {
        row.setCell("");
    }

    // Condio perante a situao na profisso/Ocupao do
    // Pai
    if (personalInformationBean.getFatherProfessionalCondition() != null) {
        row.setCell(personalInformationBean.getFatherProfessionalCondition().getName());
    } else {
        row.setCell("");
    }

    // Condio perante a situao na profisso/Ocupao da
    // Me
    if (personalInformationBean.getMotherProfessionalCondition() != null) {
        row.setCell(personalInformationBean.getMotherProfessionalCondition().getName());
    } else {
        row.setCell("");
    }

    // Profisso do Pai
    if (personalInformationBean.getFatherProfessionType() != null) {
        row.setCell(personalInformationBean.getFatherProfessionType().getName());
    } else {
        row.setCell("");
    }

    // Profisso da Me
    if (personalInformationBean.getMotherProfessionType() != null) {
        row.setCell(personalInformationBean.getMotherProfessionType().getName());
    } else {
        row.setCell("");
    }

    // Profisso do Aluno
    if (personalInformationBean.getProfessionType() != null) {
        row.setCell(personalInformationBean.getProfessionType().getName());
    } else {
        row.setCell("");
    }

    // Data preenchimento dados RAIDES
    if (personalInformationBean.getLastModifiedDate() != null) {
        DateTime dateTime = personalInformationBean.getLastModifiedDate();
        row.setCell(dateTime.getYear() + "-" + dateTime.getMonthOfYear() + "-" + dateTime.getDayOfMonth());
    } else {
        row.setCell("");
    }

    // Estatuto de Trabalhador Estudante introduzido pelo aluno
    if (personalInformationBean.getProfessionalCondition() != null) {
        row.setCell(personalInformationBean.getProfessionalCondition().getName());
    } else {
        row.setCell("");
    }

    // Estatuto de Trabalhador Estudante 1 semestre do ano a que se
    // referem
    // os dados
    boolean working1Found = false;
    for (StudentStatute statute : registration.getStudent().getStudentStatutesSet()) {
        if (statute.getType().isWorkingStudentStatute()
                && statute.isValidInExecutionPeriod(executionYear.getFirstExecutionPeriod())) {
            working1Found = true;
            break;
        }
    }
    row.setCell(String.valueOf(working1Found));

    // Estatuto de Trabalhador Estudante 1 semestre do ano a que se
    // referem
    // os dados
    boolean working2Found = false;
    for (StudentStatute statute : registration.getStudent().getStudentStatutesSet()) {
        if (statute.getType().isWorkingStudentStatute()
                && statute.isValidInExecutionPeriod(executionYear.getLastExecutionPeriod())) {
            working2Found = true;
            break;
        }
    }
    row.setCell(String.valueOf(working2Found));

    // Bolseiro (info. RAIDES)
    if (personalInformationBean.getGrantOwnerType() != null) {
        row.setCell(personalInformationBean.getGrantOwnerType().getName());
    } else {
        row.setCell("");
    }

    // Instituio que atribuiu a bolsa
    if (personalInformationBean.getGrantOwnerType() != null && personalInformationBean.getGrantOwnerType()
            .equals(GrantOwnerType.OTHER_INSTITUTION_GRANT_OWNER)) {
        row.setCell(personalInformationBean.getGrantOwnerProviderName());
    } else {
        row.setCell("");
    }

    // Bolseiro (info. oficial)
    boolean sasFound = false;
    for (StudentStatute statute : registration.getStudent().getStudentStatutesSet()) {
        if (statute.getType().isGrantOwnerStatute()
                && statute.isValidInExecutionPeriod(executionYear.getFirstExecutionPeriod())) {
            sasFound = true;
            break;
        }
    }
    row.setCell(String.valueOf(sasFound));

    // Grau Precedente
    row.setCell(personalInformationBean.getPrecedentSchoolLevel() != null
            ? personalInformationBean.getPrecedentSchoolLevel().getName()
            : "");

    // Outro Grau Precedente
    row.setCell(personalInformationBean.getOtherPrecedentSchoolLevel());

    // grau da habl anterior compl
    row.setCell(personalInformationBean.getSchoolLevel() != null
            ? personalInformationBean.getSchoolLevel().getName()
            : "");

    // Codigo do grau habl anterior
    DegreeDesignation designation = DegreeDesignation.readByNameAndSchoolLevel(
            personalInformationBean.getDegreeDesignation(), personalInformationBean.getPrecedentSchoolLevel());
    row.setCell(designation != null ? designation.getDegreeClassification().getCode() : "");

    // Outro grau da habl anterior compl
    row.setCell(personalInformationBean.getOtherSchoolLevel());

    // Pas de Habilitao Anterior ao Curso Actual
    row.setCell(personalInformationBean.getCountryWhereFinishedPreviousCompleteDegree() != null
            ? personalInformationBean.getCountryWhereFinishedPreviousCompleteDegree().getName()
            : "");

    // Pas de Habilitao do 12 ano ou equivalente
    row.setCell(personalInformationBean.getCountryWhereFinishedHighSchoolLevel() != null
            ? personalInformationBean.getCountryWhereFinishedHighSchoolLevel().getName()
            : "");

    // Ano de concluso da habilitao anterior
    row.setCell(personalInformationBean.getConclusionYear());

    // Nota de concluso da habilitao anterior
    row.setCell(
            personalInformationBean.getConclusionGrade() != null ? personalInformationBean.getConclusionGrade()
                    : "");

    MobilityAgreement mobilityAgreement = null;
    ExecutionInterval chosenCandidacyInterval = null;
    //getting the last mobility program done
    for (OutboundMobilityCandidacySubmission outboundCandidacySubmission : registration
            .getOutboundMobilityCandidacySubmissionSet()) {
        if (outboundCandidacySubmission.getSelectedCandidacy() != null
                && outboundCandidacySubmission.getSelectedCandidacy().getSelected()) {
            ExecutionInterval candidacyInterval = outboundCandidacySubmission
                    .getOutboundMobilityCandidacyPeriod().getExecutionInterval();
            //the candidacies are made in the previous year
            if (candidacyInterval.getAcademicInterval().isBefore(executionYear.getAcademicInterval())) {
                if (mobilityAgreement != null) {
                    if (!candidacyInterval.getAcademicInterval()
                            .isAfter(chosenCandidacyInterval.getAcademicInterval())) {
                        continue;
                    }
                }
                mobilityAgreement = outboundCandidacySubmission.getSelectedCandidacy()
                        .getOutboundMobilityCandidacyContest().getMobilityAgreement();
                chosenCandidacyInterval = candidacyInterval;
            }
        }
    }
    // Programa de mobilidade
    row.setCell(mobilityAgreement != null ? mobilityAgreement.getMobilityProgram().getName().getContent() : "");

    // Pas de mobilidade
    row.setCell(mobilityAgreement != null ? mobilityAgreement.getUniversityUnit().getCountry().getName() : "");

    // Durao do programa de mobilidade
    row.setCell(personalInformationBean.getMobilityProgramDuration() != null ? BundleUtil
            .getString(Bundle.ENUMERATION, personalInformationBean.getMobilityProgramDuration().name()) : "");

    // Tipo de Estabelecimento Frequentado no Ensino Secundrio
    if (personalInformationBean.getHighSchoolType() != null) {
        row.setCell(personalInformationBean.getHighSchoolType().getName());
    } else {
        row.setCell("");
    }

    int totalEnrolmentsInPreviousYear = 0;
    int totalEnrolmentsApprovedInPreviousYear = 0;
    //int totalEnrolmentsInFirstSemester = 0;
    double totalEctsConcludedUntilPreviousYear = 0d;
    for (final CycleCurriculumGroup cycleCurriculumGroup : studentCurricularPlan
            .getInternalCycleCurriculumGrops()) {

        totalEctsConcludedUntilPreviousYear += cycleCurriculumGroup
                .getCreditsConcluded(executionYear.getPreviousExecutionYear());

        totalEnrolmentsInPreviousYear += cycleCurriculumGroup
                .getEnrolmentsBy(executionYear.getPreviousExecutionYear()).size();

        for (final Enrolment enrolment : cycleCurriculumGroup
                .getEnrolmentsBy(executionYear.getPreviousExecutionYear())) {
            if (enrolment.isApproved()) {
                totalEnrolmentsApprovedInPreviousYear++;
            }
        }

        //       totalEnrolmentsInFirstSemester += cycleCurriculumGroup.getEnrolmentsBy(executionYear.getFirstExecutionPeriod())
        //          .size();
    }

    // Total de ECTS inscritos no total do ano
    double totalCreditsEnrolled = 0d;
    for (Enrolment enrollment : studentCurricularPlan.getEnrolmentsByExecutionYear(executionYear)) {
        totalCreditsEnrolled += enrollment.getEctsCredits();
    }
    row.setCell(printDouble(totalCreditsEnrolled));

    // Total de ECTS concludos at ao fim do ano lectivo anterior ao
    // que se
    // referem os dados (neste caso at ao fim de 2007/08) no curso actual
    double totalCreditsDismissed = 0d;
    for (Credits credits : studentCurricularPlan.getCreditsSet()) {
        if (credits.isEquivalence()) {
            totalCreditsDismissed += credits.getEnrolmentsEcts();
        }
    }
    row.setCell(printDouble(totalEctsConcludedUntilPreviousYear));

    // N de Disciplinas Inscritos no ano lectivo anterior ao que se
    // referem
    // os dados
    row.setCell(totalEnrolmentsInPreviousYear);

    // N de Disciplinas Aprovadas no ano lectivo anterior ao que se
    // referem
    // os dados
    row.setCell(totalEnrolmentsApprovedInPreviousYear);

    // N de Inscries Externas no ano a que se referem os dados
    ExtraCurriculumGroup extraCurriculumGroup = studentCurricularPlan.getExtraCurriculumGroup();
    int extraCurricularEnrolmentsCount = extraCurriculumGroup != null
            ? extraCurriculumGroup.getEnrolmentsBy(executionYear).size()
            : 0;

    for (final CycleCurriculumGroup cycleCurriculumGroup : studentCurricularPlan
            .getExternalCurriculumGroups()) {
        extraCurricularEnrolmentsCount += cycleCurriculumGroup.getEnrolmentsBy(executionYear).size();
    }

    if (studentCurricularPlan.hasPropaedeuticsCurriculumGroup()) {
        extraCurricularEnrolmentsCount += studentCurricularPlan.getPropaedeuticCurriculumGroup()
                .getEnrolmentsBy(executionYear).size();
    }

    row.setCell(extraCurricularEnrolmentsCount);

    // Estados de matrcula
    SortedSet<RegistrationState> states = new TreeSet<RegistrationState>(RegistrationState.DATE_COMPARATOR);
    for (Registration current : registrationPath) {
        states.addAll(current.getRegistrationStatesSet());
    }
    RegistrationState previousYearState = null;
    RegistrationState currentYearState = null;
    for (RegistrationState state : states) {
        if (!state.getStateDate().isAfter(
                executionYear.getPreviousExecutionYear().getEndDateYearMonthDay().toDateTimeAtMidnight())) {
            previousYearState = state;
        }
        if (!state.getStateDate().isAfter(executionYear.getEndDateYearMonthDay().toDateTimeAtMidnight())) {
            currentYearState = state;
        }
    }

    // Estado da matrcula no ano lectivo anterior ao que se referem os
    // dados
    row.setCell(previousYearState != null ? previousYearState.getStateType().getDescription() : "n/a");

    // Estado (da matrcula) no ano a que se referem os dados
    row.setCell(currentYearState != null ? currentYearState.getStateType().getDescription() : "n/a");

    // Data do estado de matrcula
    row.setCell(currentYearState != null ? currentYearState.getStateDate().toString("dd-MM-yyyy") : "n/a");

    // N ECTS do 1 Ciclo concludos at ao fim do ano lectivo
    // anterior ao que se referem os dados
    final CycleCurriculumGroup firstCycleCurriculumGroup = getStudentCurricularPlan(registration,
            CycleType.FIRST_CYCLE).getCycle(CycleType.FIRST_CYCLE);
    row.setCell(firstCycleCurriculumGroup != null
            ? printBigDecimal(firstCycleCurriculumGroup.getCurriculum(executionYear).getSumEctsCredits())
            : "");

    // N ECTS do 2 Ciclo concludos at ao fim do ano lectivo
    // anterior ao que se referem os dados
    final CycleCurriculumGroup secondCycleCurriculumGroup = getStudentCurricularPlan(registration,
            CycleType.SECOND_CYCLE).getCycle(CycleType.SECOND_CYCLE);
    row.setCell(secondCycleCurriculumGroup != null && !secondCycleCurriculumGroup.isExternal()
            ? printBigDecimal(secondCycleCurriculumGroup.getCurriculum(executionYear).getSumEctsCredits())
            : "");

    // N ECTS do 2 Ciclo Extra primeiro ciclo concludos at ao fim do ano
    // lectivo anterior ao que se referem os dados
    Double extraFirstCycleEcts = 0d;
    for (final CycleCurriculumGroup cycleCurriculumGroup : studentCurricularPlan
            .getExternalCurriculumGroups()) {
        for (final CurriculumLine curriculumLine : cycleCurriculumGroup.getAllCurriculumLines()) {
            if (!curriculumLine.getExecutionYear().isAfter(executionYear.getPreviousExecutionYear())) {
                extraFirstCycleEcts += curriculumLine
                        .getCreditsConcluded(executionYear.getPreviousExecutionYear());
            }
        }
    }
    row.setCell(printDouble(extraFirstCycleEcts));

    // N ECTS Extracurriculares concludos at ao fim do ano lectivo
    // anterior que ao se referem os dados
    Double extraCurricularEcts = 0d;
    Double allExtraCurricularEcts = 0d;
    if (extraCurriculumGroup != null) {
        for (final CurriculumLine curriculumLine : extraCurriculumGroup.getAllCurriculumLines()) {
            if (curriculumLine.isApproved() && curriculumLine.hasExecutionPeriod()
                    && !curriculumLine.getExecutionYear().isAfter(executionYear.getPreviousExecutionYear())) {
                extraCurricularEcts += curriculumLine.getEctsCreditsForCurriculum().doubleValue();
            }
            if (curriculumLine.hasExecutionPeriod() && curriculumLine.getExecutionYear() == executionYear) {
                allExtraCurricularEcts += curriculumLine.getEctsCreditsForCurriculum().doubleValue();
            }
        }
    }
    row.setCell(printDouble(extraCurricularEcts));

    // N ECTS Propedeutic concludos at ao fim do ano lectivo
    // anterior que ao se referem os dados
    Double propaedeuticEcts = 0d;
    Double allPropaedeuticEcts = 0d;
    if (studentCurricularPlan.getPropaedeuticCurriculumGroup() != null) {
        for (final CurriculumLine curriculumLine : studentCurricularPlan.getPropaedeuticCurriculumGroup()
                .getAllCurriculumLines()) {
            if (curriculumLine.isApproved() && curriculumLine.hasExecutionPeriod()
                    && !curriculumLine.getExecutionYear().isAfter(executionYear.getPreviousExecutionYear())) {
                propaedeuticEcts += curriculumLine.getEctsCreditsForCurriculum().doubleValue();
            }
            if (curriculumLine.hasExecutionPeriod() && curriculumLine.getExecutionYear() == executionYear) {
                allPropaedeuticEcts += curriculumLine.getEctsCreditsForCurriculum().doubleValue();
            }
        }
    }
    row.setCell(printDouble(propaedeuticEcts));

    // N ECTS inscritos em unidades curriculares propeduticas e em
    // extra-curriculares
    row.setCell(printDouble(allPropaedeuticEcts + allExtraCurricularEcts));

    // N ECTS equivalncia/substituio/dispensa
    row.setCell(printDouble(totalCreditsDismissed));

    // Tem situao de propinas no lectivo dos dados
    row.setCell(String.valueOf(studentCurricularPlan.hasAnyGratuityEventFor(executionYear)));

    return row;
}

From source file:org.fenixedu.academic.domain.reports.RaidesPhdReportFile.java

License:Open Source License

private void reportRaidesGraduate(Spreadsheet spreadsheet, PhdIndividualProgramProcess process,
        ExecutionYear executionYear) {//from   w w  w  .  j a  va2  s.c  o  m
    final Row row = spreadsheet.addRow();
    final Person graduate = process.getPerson();
    final PersonalInformationBean personalInformationBean = process.getPersonalInformationBean(executionYear);
    final Registration registration = process.getRegistration();
    final boolean concluded = process.isConcluded();
    final LocalDate conclusionDate = process.getConclusionDate();

    if (registration != null && !registration.isBolonha()) {
        return;
    }

    YearMonthDay registrationConclusionDate = registration != null
            ? registration.getLastStudentCurricularPlan().getCycle(CycleType.THIRD_CYCLE).getConclusionDate()
            : null;

    if (registration != null && registrationConclusionDate == null) {
        registrationConclusionDate = registration.getLastStudentCurricularPlan()
                .calculateConclusionDate(CycleType.THIRD_CYCLE);
    }

    row.setCell(String.valueOf(registration != null && !registration.isCanceled()));

    // Ciclo
    row.setCell(CycleType.THIRD_CYCLE.getDescription());

    // Concludo
    row.setCell(String.valueOf(process.isConcluded()));

    // Mdia do Ciclo
    String grade = concluded ? process.getFinalGrade().getLocalizedName() : "n/a";
    if (concluded && registration != null && registration.isConcluded()) {
        grade += " " + registration.getLastStudentCurricularPlan().getCycle(CycleType.THIRD_CYCLE)
                .getCurriculum(registrationConclusionDate.toDateTimeAtMidnight()).getRawGrade().getValue();
    }
    row.setCell(grade);

    // Data de concluso
    row.setCell(conclusionDate != null ? conclusionDate.toString("dd-MM-yyyy") : "");

    // Data de Incio
    row.setCell(process.getCandidacyDate().toString("dd-MM-yyyy"));

    // N de aluno
    row.setCell(process.getStudent().getNumber());

    // Tipo Identificao
    row.setCell(graduate.getIdDocumentType().getLocalizedName());

    // N de Identificao
    row.setCell(graduate.getDocumentIdNumber());

    // Dgitos de Controlo
    row.setCell(graduate.getIdentificationDocumentExtraDigitValue());

    // Verso Doc. Identificao
    row.setCell(graduate.getIdentificationDocumentSeriesNumberValue());

    // Nome
    row.setCell(registration != null ? registration.getName()
            : process.getPerson() != null ? process.getPerson().getName() : "n/a");

    // Sexo
    row.setCell(graduate.getGender().toString());

    // Data de Nascimento
    row.setCell(graduate.getDateOfBirthYearMonthDay() != null
            ? graduate.getDateOfBirthYearMonthDay().toString("dd-MM-yyyy")
            : "n/a");

    // Pas de Nascimento
    row.setCell(graduate.getCountryOfBirth() != null ? graduate.getCountryOfBirth().getName() : "n/a");

    // Pas de Nacionalidade
    row.setCell(graduate.getCountry() != null ? graduate.getCountry().getName() : "n/a");

    // Sigla programa doutoral
    row.setCell(process.getPhdProgram().getAcronym());

    // Programa doutoral
    row.setCell(process.getPhdProgram().getName(process.getExecutionYear()).getContent());

    // Tipo Curso
    row.setCell(registration != null ? registration.getDegreeType().getName().getContent() : "n/a");

    // Nome Curso
    row.setCell(registration != null ? registration.getDegree().getNameI18N().getContent() : "n/a");

    // Sigla Curso
    row.setCell(registration != null ? registration.getDegree().getSigla() : "n/a");

    // Ramo (caso se aplique)
    row.setCell("no determinvel");

    if (registration != null) {
        // N de anos lectivos de inscrio no Curso actual
        row.setCell(calculateNumberOfEnrolmentYears(registration, executionYear));

        // ltimo ano em que esteve inscrito
        row.setCell(registration.getLastEnrolmentExecutionYear() != null
                ? registration.getLastEnrolmentExecutionYear().getName()
                : "");
    } else {
        row.setCell("n/a");
        row.setCell("n/a");
    }

    // estabelecimento do habl anterior compl (se o aluno ingressou por uma via
    // diferente CNA, e deve ser IST caso o aluno tenha estado matriculado noutro curso do IST)
    row.setCell(personalInformationBean.getInstitution() != null
            ? personalInformationBean.getInstitution().getName()
            : "");

    // curso habl anterior compl (se o aluno ingressou por uma via diferente CNA, e
    // deve ser IST caso o aluno tenha estado matriculado noutro curso do IST)
    row.setCell(personalInformationBean.getDegreeDesignation());

    // Estado Civil
    row.setCell(personalInformationBean.getMaritalStatus() != null
            ? personalInformationBean.getMaritalStatus().toString()
            : process.getPerson().getMaritalStatus().toString());

    // Pas de Residncia Permanente
    if (personalInformationBean.getCountryOfResidence() != null) {
        row.setCell(personalInformationBean.getCountryOfResidence().getName());
    } else {
        row.setCell(process.getStudent().getPerson().getCountryOfResidence() != null
                ? process.getStudent().getPerson().getCountryOfResidence().getName()
                : "");
    }

    // Distrito de Residncia Permanente
    if (personalInformationBean.getDistrictSubdivisionOfResidence() != null) {
        row.setCell(personalInformationBean.getDistrictSubdivisionOfResidence().getDistrict().getName());
    } else {
        row.setCell(process.getStudent().getPerson().getDistrictOfResidence());
    }

    // Concelho de Residncia Permanente
    if (personalInformationBean.getDistrictSubdivisionOfResidence() != null) {
        row.setCell(personalInformationBean.getDistrictSubdivisionOfResidence().getName());
    } else {
        row.setCell(process.getStudent().getPerson().getDistrictSubdivisionOfResidence());
    }

    // Deslocado da Residncia Permanente
    if (personalInformationBean.getDislocatedFromPermanentResidence() != null) {
        row.setCell(personalInformationBean.getDislocatedFromPermanentResidence().toString());
    } else {
        row.setCell("");
    }

    // Nvel de Escolaridade do Pai
    if (personalInformationBean.getFatherSchoolLevel() != null) {
        row.setCell(personalInformationBean.getFatherSchoolLevel().getName());
    } else {
        row.setCell("");
    }

    // Nvel de Escolaridade da Me
    if (personalInformationBean.getMotherSchoolLevel() != null) {
        row.setCell(personalInformationBean.getMotherSchoolLevel().getName());
    } else {
        row.setCell("");
    }

    // Condio perante a situao na profisso/Ocupao do Pai
    if (personalInformationBean.getFatherProfessionalCondition() != null) {
        row.setCell(personalInformationBean.getFatherProfessionalCondition().getName());
    } else {
        row.setCell("");
    }

    // Condio perante a situao na profisso/Ocupao da Me
    if (personalInformationBean.getMotherProfessionalCondition() != null) {
        row.setCell(personalInformationBean.getMotherProfessionalCondition().getName());
    } else {
        row.setCell("");
    }

    // Profisso do Pai
    if (personalInformationBean.getFatherProfessionType() != null) {
        row.setCell(personalInformationBean.getFatherProfessionType().getName());
    } else {
        row.setCell("");
    }

    // Profisso da Me
    if (personalInformationBean.getMotherProfessionType() != null) {
        row.setCell(personalInformationBean.getMotherProfessionType().getName());
    } else {
        row.setCell("");
    }

    // Profisso do Aluno
    if (personalInformationBean.getProfessionType() != null) {
        row.setCell(personalInformationBean.getProfessionType().getName());
    } else {
        row.setCell("");
    }

    // Data preenchimento dados RAIDES
    if (personalInformationBean.getLastModifiedDate() != null) {
        DateTime dateTime = personalInformationBean.getLastModifiedDate();
        row.setCell(dateTime.getYear() + "-" + dateTime.getMonthOfYear() + "-" + dateTime.getDayOfMonth());
    } else {
        row.setCell("");
    }

    // Estatuto de Trabalhador Estudante introduzido pelo aluno
    if (personalInformationBean.getProfessionalCondition() != null) {
        row.setCell(personalInformationBean.getProfessionalCondition().getName());
    } else {
        row.setCell("");
    }

    // Bolseiro (info. RAIDES)
    if (personalInformationBean.getGrantOwnerType() != null) {
        row.setCell(personalInformationBean.getGrantOwnerType().getName());
    } else {
        row.setCell("");
    }

    // Bolseiro (info. oficial)
    boolean sasFound = process.getStudent().getStudentStatutesSet().stream()
            .anyMatch(statute -> statute.getType().isGrantOwnerStatute()
                    && statute.isValidInExecutionPeriod(executionYear.getFirstExecutionPeriod()));
    row.setCell(String.valueOf(sasFound));

    // Grau Precedente
    row.setCell(personalInformationBean.getPrecedentSchoolLevel() != null
            ? personalInformationBean.getPrecedentSchoolLevel().getName()
            : "");

    // grau habl anterior compl
    row.setCell(personalInformationBean.getSchoolLevel() != null
            ? personalInformationBean.getSchoolLevel().getName()
            : "");

    // outro grau habl anterior compl
    row.setCell(personalInformationBean.getOtherSchoolLevel() != null
            ? personalInformationBean.getOtherSchoolLevel()
            : "");

    // Pas de Habilitao Anterior Completa
    row.setCell(personalInformationBean.getCountryWhereFinishedPreviousCompleteDegree() != null
            ? personalInformationBean.getCountryWhereFinishedPreviousCompleteDegree().getName()
            : "");

    // Pas de Habilitao do 12 ano ou equivalente
    row.setCell(personalInformationBean.getCountryWhereFinishedHighSchoolLevel() != null
            ? personalInformationBean.getCountryWhereFinishedHighSchoolLevel().getName()
            : "");

    // Ano de concluso da habilitao anterior completa
    row.setCell(personalInformationBean.getConclusionYear());

    // Nota de concluso da habilitao anterior completa
    row.setCell(
            personalInformationBean.getConclusionGrade() != null ? personalInformationBean.getConclusionGrade()
                    : "");

    // N inscries no curso preced. (conta uma por cada ano)
    row.setCell(personalInformationBean.getNumberOfPreviousYearEnrolmentsInPrecedentDegree() != null
            ? personalInformationBean.getNumberOfPreviousYearEnrolmentsInPrecedentDegree().toString()
            : "");

    // Durao do programa de mobilidade
    row.setCell(personalInformationBean.getMobilityProgramDuration() != null ? BundleUtil
            .getString(Bundle.ENUMERATION, personalInformationBean.getMobilityProgramDuration().name()) : "");

    // Tipo de Estabelecimento Frequentado no Ensino Secundrio
    if (personalInformationBean.getHighSchoolType() != null) {
        row.setCell(personalInformationBean.getHighSchoolType().getName());
    } else {
        row.setCell("");
    }

    double totalEctsConcludedUntilPreviousYear = 0d;
    if (registration != null) {

        // Total de ECTS inscritos no total do ano
        double totalCreditsEnrolled = registration.getLastStudentCurricularPlan()
                .getEnrolmentsByExecutionYear(executionYear).stream().mapToDouble(Enrolment::getEctsCredits)
                .sum();
        row.setCell(totalCreditsEnrolled);

        // Total de ECTS concludos at ao fim do ano lectivo anterior (1
        // Semestre do ano lectivo actual) ao que se
        // referem os dados (neste caso at ao fim de 2008) no curso actual
        // We can use current year because only the first semester has
        // occured
        totalEctsConcludedUntilPreviousYear = registration.getLastStudentCurricularPlan()
                .getInternalCycleCurriculumGrops().stream()
                .mapToDouble(cycleCurriculumGroup -> cycleCurriculumGroup.getCreditsConcluded(executionYear))
                .sum();
        row.setCell(totalEctsConcludedUntilPreviousYear);

        // N ECTS equivalncia/substituio/dispensa
        double totalCreditsDismissed = registration.getLastStudentCurricularPlan().getCreditsSet().stream()
                .filter(Credits::isEquivalence).mapToDouble(Credits::getEnrolmentsEcts).sum();
        row.setCell(totalCreditsDismissed);

    } else {
        row.setCell("n/a");
        row.setCell("n/a");
        row.setCell("n/a");
    }

    if (registration != null) {
        // Total de ECTS necessrios para a concluso
        if (concluded) {
            row.setCell(0);
        } else {
            row.setCell(registration.getLastStudentCurricularPlan().getRoot().getDefaultEcts(executionYear)
                    - totalEctsConcludedUntilPreviousYear);
        }
    } else {
        row.setCell("n/a");
    }

    // Se alunos de Doutoramento, inscrito na Parte Curricular?
    if (registration != null && registration.isDEA()) {
        row.setCell(String.valueOf(registration.getLastStudentCurricularPlan().hasEnrolments(executionYear)));
    } else {
        row.setCell("not PhD");
    }

    row.setCell(process.getPhdStudentNumber());

    // ist id dos orientadores
    int count = 0;
    StringBuilder guidings = new StringBuilder();
    for (PhdParticipant phdParticipant : process.getGuidingsSet()) {
        if (phdParticipant.isInternal()) {
            if (count > 0) {
                guidings.append(";");
            }
            guidings.append(((InternalPhdParticipant) phdParticipant).getPerson().getUsername());
            count++;
        }
    }
    row.setCell(guidings.toString());

    // ist id dos co-orientadores
    int countAssistantGuidings = 0;
    StringBuilder assistantGuidings = new StringBuilder();
    for (PhdParticipant phdParticipant : process.getAssistantGuidingsSet()) {
        if (phdParticipant.isInternal()) {
            if (countAssistantGuidings > 0) {
                assistantGuidings.append(";");
            }
            assistantGuidings.append(((InternalPhdParticipant) phdParticipant).getPerson().getUsername());
            countAssistantGuidings++;
        }
    }
    row.setCell(assistantGuidings.toString());

    // Nome do Orientador Externo
    int countExternalGuidings = 0;
    StringBuilder externalGuidingNames = new StringBuilder();
    for (PhdParticipant phdParticipant : process.getGuidingsSet()) {
        if (!phdParticipant.isInternal()) {
            if (countExternalGuidings > 0) {
                externalGuidingNames.append(";");
            }
            externalGuidingNames.append(((ExternalPhdParticipant) phdParticipant).getName());
            externalGuidingNames.append(" (");
            externalGuidingNames.append(((ExternalPhdParticipant) phdParticipant).getInstitution());
            externalGuidingNames.append(")");
            countExternalGuidings++;
        }
    }
    row.setCell(externalGuidingNames.toString());

    // Nome do Co-Orientador Externo
    int countExternalAssistantGuidings = 0;
    StringBuilder externalAssistantGuidingNames = new StringBuilder();
    for (PhdParticipant phdParticipant : process.getAssistantGuidingsSet()) {
        if (!phdParticipant.isInternal()) {
            if (countExternalAssistantGuidings > 0) {
                externalAssistantGuidingNames.append(";");
            }
            externalAssistantGuidingNames.append(((ExternalPhdParticipant) phdParticipant).getName());
            externalAssistantGuidingNames.append(" (");
            externalAssistantGuidingNames.append(((ExternalPhdParticipant) phdParticipant).getInstitution());
            externalAssistantGuidingNames.append(")");
            countExternalAssistantGuidings++;
        }
    }
    row.setCell(externalAssistantGuidingNames.toString());

    PhdProgramProcessState lastActiveState = process.getMostRecentState();
    row.setCell(lastActiveState != null ? lastActiveState.getType().getLocalizedName() : "n/a");

    if (process.getCollaborationType() != null) {
        row.setCell(process.getCollaborationType().getLocalizedName());
    } else {
        row.setCell("n/a");
    }

    if (process.getCandidacyDate() != null) {
        row.setCell(process.getCandidacyDate().toString("dd/MM/yyyy"));
    } else {
        row.setCell("n/a");
    }

    if (process.getCandidacyProcess().getWhenRatified() != null) {
        row.setCell(process.getCandidacyDate().toString("dd/MM/yyyy"));
    } else {
        row.setCell("n/a");
    }

    if (process.getWhenStartedStudies() != null) {
        row.setCell(process.getWhenStartedStudies().toString("dd/MM/yyyy"));
    } else {
        row.setCell("n/a");
    }

    if (process.getThesisProcess() != null && process.getThesisProcess().getDiscussionDate() != null) {
        row.setCell(process.getThesisProcess().getDiscussionDate().toString("dd/MM/yyyy"));
    } else {
        row.setCell("n/a");
    }

    // Tipo de Acordo (AFA, AM, ERASMUS, etc)
    row.setCell(registration != null
            ? registration.getRegistrationProtocol() != null ? registration.getRegistrationProtocol().getCode()
                    : ""
            : "");

    // Data de Apresentao Pblica da CAT
    if (process.getSeminarProcess() != null && process.getSeminarProcess().getPresentationDate() != null) {
        row.setCell(process.getSeminarProcess().getPresentationDate().toString("dd/MM/yyyy"));
    } else {
        row.setCell("n/a");
    }
}

From source file:org.fenixedu.academic.service.ChangeConvokeActive.java

License:Open Source License

private static void sendEmailNotification(Boolean bool, Person person, Vigilancy convoke) {

    String replyTo = person.getEmail();

    VigilantGroup group = convoke.getAssociatedVigilantGroup();
    String groupEmail = group.getContactEmail();

    if (groupEmail != null) {
        final ExamCoordinator coordinator = ExamCoordinator.getExamCoordinatorForGivenExecutionYear(person,
                group.getExecutionYear());
        if (coordinator == null ? Boolean.FALSE : group.getExamCoordinatorsSet().contains(coordinator)) {
            replyTo = groupEmail;//from ww w  .ja v a  2s.co  m
        }
    }

    WrittenEvaluation writtenEvaluation = convoke.getWrittenEvaluation();

    String emailMessage = generateMessage(bool, convoke);
    DateTime date = writtenEvaluation.getBeginningDateTime();
    String time = writtenEvaluation.getBeginningDateHourMinuteSecond().toString();
    String beginDateString = date.getDayOfMonth() + "-" + date.getMonthOfYear() + "-" + date.getYear();

    String subject = BundleUtil.getString("resources.VigilancyResources", "email.convoke.subject",
            new String[] { writtenEvaluation.getName(), group.getName(), beginDateString, time });

    new Message(PersonSender.newInstance(person), new ConcreteReplyTo(replyTo).asCollection(),
            new Recipient(VigilancyGroup.get(convoke)).asCollection(), Collections.EMPTY_LIST,
            Collections.EMPTY_LIST, subject, emailMessage, convoke.getSitesAndGroupEmails());

}

From source file:org.fenixedu.academic.service.ChangeConvokeActive.java

License:Open Source License

private static String generateMessage(Boolean bool, Vigilancy convoke) {

    WrittenEvaluation writtenEvaluation = convoke.getWrittenEvaluation();
    DateTime beginDate = writtenEvaluation.getBeginningDateTime();
    String date = beginDate.getDayOfMonth() + "-" + beginDate.getMonthOfYear() + "-" + beginDate.getYear();

    return BundleUtil.getString("resources.VigilancyResources", "email.convoke.active.body",
            new String[] { convoke.getVigilantWrapper().getPerson().getName(),
                    (bool) ? BundleUtil.getString("resources.VigilancyResources", "email.convoke.convokedAgain")
                            : BundleUtil.getString("resources.VigilancyResources", "email.convoke.uncovoked"),
                    writtenEvaluation.getFullName(), date,
                    writtenEvaluation.getBeginningDateHourMinuteSecond().toString() });
}

From source file:org.fenixedu.academic.service.CreateConvokes.java

License:Open Source License

@Atomic
public static void run(List<VigilantWrapper> vigilants, WrittenEvaluation writtenEvaluation,
        VigilantGroup group, ExamCoordinator coordinator, String emailMessage) {
    group.convokeVigilants(vigilants, writtenEvaluation);

    Set<Person> recievers = new HashSet<Person>();
    Set<String> bccs = new HashSet<String>();

    if (emailMessage.length() != 0) {
        Person person = coordinator.getPerson();
        for (VigilantWrapper vigilant : vigilants) {
            recievers.add(vigilant.getPerson());
        }/*from   w  w  w.j  ava2 s.c o  m*/

        String groupEmail = group.getContactEmail();
        String replyTo;

        recievers.addAll(writtenEvaluation.getTeachers());

        if (groupEmail != null) {
            bccs.add(groupEmail);
            replyTo = groupEmail;
        } else {
            replyTo = person.getEmail();
        }

        DateTime date = writtenEvaluation.getBeginningDateTime();
        String beginDateString = date.getDayOfMonth() + "/" + date.getMonthOfYear() + "/" + date.getYear();

        String subject = BundleUtil.getString("resources.VigilancyResources", "email.convoke.subject",
                new String[] { group.getEmailSubjectPrefix(), writtenEvaluation.getName(), group.getName(),
                        beginDateString });

        new Message(PersonSender.newInstance(person), new ConcreteReplyTo(replyTo).asCollection(),
                new Recipient(UserGroup.of(Person.convertToUsers(recievers))).asCollection(),
                Collections.EMPTY_LIST, Collections.EMPTY_LIST, subject, emailMessage, bccs);
    }
}