Java tutorial
/** * Copyright 2002 Instituto Superior Tcnico * * This file is part of FenixEdu Core. * * FenixEdu Core is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * FenixEdu Core is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with FenixEdu Core. If not, see <http://www.gnu.org/licenses/>. */ package net.sourceforge.fenixedu.domain.reports; import java.math.BigDecimal; import java.util.List; import java.util.SortedSet; import java.util.TreeSet; import net.sourceforge.fenixedu.domain.Enrolment; import net.sourceforge.fenixedu.domain.ExecutionInterval; import net.sourceforge.fenixedu.domain.ExecutionYear; import net.sourceforge.fenixedu.domain.GrantOwnerType; import net.sourceforge.fenixedu.domain.Person; import net.sourceforge.fenixedu.domain.StudentCurricularPlan; import net.sourceforge.fenixedu.domain.candidacy.Ingression; import net.sourceforge.fenixedu.domain.candidacy.PersonalInformationBean; import net.sourceforge.fenixedu.domain.candidacyProcess.mobility.MobilityAgreement; import net.sourceforge.fenixedu.domain.degreeStructure.CycleType; import net.sourceforge.fenixedu.domain.mobility.outbound.OutboundMobilityCandidacySubmission; import net.sourceforge.fenixedu.domain.raides.DegreeDesignation; import net.sourceforge.fenixedu.domain.student.Registration; import net.sourceforge.fenixedu.domain.student.StudentStatute; import net.sourceforge.fenixedu.domain.student.StudentStatuteType; import net.sourceforge.fenixedu.domain.student.registrationStates.RegistrationState; import net.sourceforge.fenixedu.domain.studentCurriculum.BranchCurriculumGroup; import net.sourceforge.fenixedu.domain.studentCurriculum.Credits; import net.sourceforge.fenixedu.domain.studentCurriculum.CurriculumLine; import net.sourceforge.fenixedu.domain.studentCurriculum.CycleCurriculumGroup; import net.sourceforge.fenixedu.domain.studentCurriculum.ExtraCurriculumGroup; import net.sourceforge.fenixedu.util.Bundle; import org.fenixedu.bennu.core.i18n.BundleUtil; import org.joda.time.DateTime; import org.joda.time.YearMonthDay; import pt.utl.ist.fenix.tools.util.excel.Spreadsheet; import pt.utl.ist.fenix.tools.util.excel.Spreadsheet.Row; public class RaidesCommonReportFieldsWrapper { public static void createHeaders(final Spreadsheet spreadsheet) { spreadsheet.setHeader("ciclo"); spreadsheet.setHeader("concludo (ano anterior)?"); spreadsheet.setHeader("mdia do ciclo"); spreadsheet.setHeader("Data de concluso"); spreadsheet.setHeader("Data de incio"); spreadsheet.setHeader("nmero aluno"); spreadsheet.setHeader("tipo identificao"); spreadsheet.setHeader("nmero identificao"); spreadsheet.setHeader("digitos controlo"); spreadsheet.setHeader("verso doc identificao"); spreadsheet.setHeader("nome"); spreadsheet.setHeader("gnero"); spreadsheet.setHeader("data nascimento"); spreadsheet.setHeader("pas nascimento"); spreadsheet.setHeader("pas nacionalidade"); spreadsheet.setHeader("tipo curso"); spreadsheet.setHeader("nome curso"); spreadsheet.setHeader("sigla curso"); spreadsheet.setHeader("Ramo Principal"); spreadsheet.setHeader("Ramo Secundro"); spreadsheet.setHeader("ano curricular"); spreadsheet.setHeader("ano ingresso curso actual"); spreadsheet.setHeader("n. anos lectivos inscrio curso actual"); spreadsheet.setHeader("ltimo ano inscrito neste curso"); spreadsheet.setHeader("regime frequncia curso"); spreadsheet.setHeader("tipo aluno"); spreadsheet.setHeader("regime ingresso (cdigo)"); spreadsheet.setHeader("regime ingresso (designao)"); spreadsheet.setHeader("estabelecimento do grau preced. (qd aplicvel)"); spreadsheet.setHeader("curso grau preced. (qd aplicvel)"); spreadsheet.setHeader("estabelec. curso habl anterior compl"); spreadsheet.setHeader("curso habl anterior compl"); spreadsheet.setHeader("n inscries no curso preced."); spreadsheet.setHeader("nota ingresso"); spreadsheet.setHeader("opo ingresso"); spreadsheet.setHeader("estado civil"); spreadsheet.setHeader("pas residncia permanente"); spreadsheet.setHeader("distrito residncia permanente"); spreadsheet.setHeader("concelho residncia permanente"); spreadsheet.setHeader("deslocado residncia permanente"); spreadsheet.setHeader("nvel escolaridade pai"); spreadsheet.setHeader("nvel escolaridade me"); spreadsheet.setHeader("condio perante profisso pai"); spreadsheet.setHeader("condio perante profisso me"); spreadsheet.setHeader("profisso pai"); spreadsheet.setHeader("profisso me"); spreadsheet.setHeader("profisso aluno"); spreadsheet.setHeader("Data preenchimento dados RAIDES"); spreadsheet.setHeader("estatuto trabalhador estudante introduzido (info. RAIDES)"); spreadsheet.setHeader("estatuto trabalhador 1 semestre ano (info. oficial)"); spreadsheet.setHeader("estatuto trabalhador 2 semestre ano (info. oficial)"); spreadsheet.setHeader("bolseiro (info. RAIDES)"); spreadsheet.setHeader("instituio que atribuiu a bolsa (qd aplicvel)"); spreadsheet.setHeader("bolseiro (info. oficial)"); spreadsheet.setHeader("Grau Precedente"); spreadsheet.setHeader("Outro Grau Precedente"); spreadsheet.setHeader("grau habl anterior compl"); spreadsheet.setHeader("Codigo do grau habl anterior"); spreadsheet.setHeader("Outro grau habl anterior compl"); spreadsheet.setHeader("pas habilitao anterior"); spreadsheet.setHeader("pas habilitao 12 ano ou equivalente"); spreadsheet.setHeader("ano de concluso da habilitao anterior"); spreadsheet.setHeader("nota da habilitao anterior"); spreadsheet.setHeader("Programa mobilidade"); spreadsheet.setHeader("Pas mobilidade"); spreadsheet.setHeader("Durao programa mobilidade"); spreadsheet.setHeader("tipo estabelecimento ensino secundrio"); spreadsheet.setHeader("total ECTS inscritos no ano"); spreadsheet.setHeader("total ECTS concludos fim ano lectivo anterior"); spreadsheet.setHeader("n. disciplinas inscritas ano lectivo anterior dados"); spreadsheet.setHeader("n. disciplinas aprovadas ano lectivo anterior dados"); spreadsheet.setHeader("n. inscries externas ano dados"); spreadsheet.setHeader("estado matrcula ano anterior dados"); spreadsheet.setHeader("estado matrcula ano dados"); spreadsheet.setHeader("data do estado de matrcula"); spreadsheet.setHeader("n. ECTS 1 ciclo concludos fim ano lectivo anterior"); spreadsheet.setHeader("n. ECTS 2 ciclo concludos fim ano lectivo anterior"); spreadsheet.setHeader("n. ECTS extra 1 ciclo concludos fim ano lectivo anterior"); spreadsheet.setHeader("n. ECTS extracurriculares concludos fim ano lectivo anterior"); spreadsheet.setHeader("n. ECTS Propedeuticas concludos fim ano lectivo anterior"); spreadsheet.setHeader("n. ECTS inscritos em Propedeut e extra-curriculares"); spreadsheet.setHeader("n. ECTS equivalncia/substituio/dispensa"); spreadsheet.setHeader("Tem situao de propinas no lectivo dos dados?"); } public static Row reportRaidesFields(final Spreadsheet sheet, final Registration registration, 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); StudentCurricularPlan lastStudentCurricularPlan = registration.getLastStudentCurricularPlan(); // Ciclo 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 ? lastStudentCurricularPlan.getCycle(cycleType).getCurriculum().getAverage().toPlainString() : "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()); // 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().getLocalizedName()); // 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 : lastStudentCurricularPlan.getBranchCurriculumGroups()) { if (group.isMajor()) { majorBranches.append(group.getName().toString()).append(","); } else if (group.isMinor()) { minorBranches.append(group.getName().toString()).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) Ingression ingression = sourceRegistration.getIngression(); if (ingression == null && sourceRegistration.getStudentCandidacy() != null) { ingression = sourceRegistration.getStudentCandidacy().getIngression(); } row.setCell(ingression != null ? ingression.getName() : ""); // Regime de Ingresso no Curso Actual (designao) row.setCell(ingression != null ? ingression.getFullDescription() : ""); // 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.getStatuteType() == StudentStatuteType.WORKING_STUDENT && 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.getStatuteType() == StudentStatuteType.WORKING_STUDENT && 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.getStatuteType() == StudentStatuteType.SAS_GRANT_OWNER && 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 : lastStudentCurricularPlan .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 : lastStudentCurricularPlan.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 : lastStudentCurricularPlan.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 = lastStudentCurricularPlan.getExtraCurriculumGroup(); int extraCurricularEnrolmentsCount = extraCurriculumGroup != null ? extraCurriculumGroup.getEnrolmentsBy(executionYear).size() : 0; for (final CycleCurriculumGroup cycleCurriculumGroup : lastStudentCurricularPlan .getExternalCurriculumGroups()) { extraCurricularEnrolmentsCount += cycleCurriculumGroup.getEnrolmentsBy(executionYear).size(); } if (lastStudentCurricularPlan.hasPropaedeuticsCurriculumGroup()) { extraCurricularEnrolmentsCount += lastStudentCurricularPlan.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 = lastStudentCurricularPlan.getRoot() .getCycleCurriculumGroup(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 = lastStudentCurricularPlan.getRoot() .getCycleCurriculumGroup(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 : lastStudentCurricularPlan .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 (lastStudentCurricularPlan.getPropaedeuticCurriculumGroup() != null) { for (final CurriculumLine curriculumLine : lastStudentCurricularPlan.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(lastStudentCurricularPlan.hasAnyGratuityEventFor(executionYear))); return row; } private static String printDouble(Double value) { return value == null ? "" : value.toString().replace('.', ','); } private static String printBigDecimal(BigDecimal value) { return value == null ? "" : value.toPlainString().replace('.', ','); } }