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());
// Concluído
row.setCell(String.valueOf(concluded));
// Média 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 Conclusão
row.setCell(conclusionDate != null ? conclusionDate.toString("dd-MM-yyyy") : "");
// Data de Início
row.setCell(registration.getStartDate() != null ? registration.getStartDate().toString("dd-MM-yyyy") : "");
// Nº de aluno
row.setCell(registration.getNumber());
// Tipo Identificação
row.setCell(graduate.getIdDocumentType().getLocalizedName());
// Nº de Identificação
row.setCell(graduate.getDocumentIdNumber());
// Dígitos de Controlo
row.setCell(graduate.getIdentificationDocumentExtraDigitValue());
// Versão Doc. Identificação
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");
// País de Nascimento
row.setCell(graduate.getCountryOfBirth() != null ? graduate.getCountryOfBirth().getName() : "n/a");
// País 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 currículo 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 Secundáro
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 inscrição 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 frequência 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 (código)
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 (designação)
row.setCell(ingression != null ? ingression.getFullDescription() : "");