for (final ExecutionSemester executionSemester : getExecutionYear().getExecutionPeriodsSet()) {
for (final ExecutionCourse executionCourse : executionSemester.getAssociatedExecutionCoursesSet()) {
for (final Evaluation evaluation : executionCourse.getAssociatedEvaluationsSet()) {
if (evaluation instanceof WrittenEvaluation) {
final WrittenEvaluation writtenEvaluation = (WrittenEvaluation) evaluation;
final Row row = spreadsheet.addRow();
row.setCell(getExecutionYear().getYear());
row.setCell(executionSemester.getSemester());
row.setCell(executionCourse.getExternalId());
row.setCell(executionCourse.getName());
row.setCell(writtenEvaluation.getExternalId());
row.setCell(writtenEvaluation instanceof Exam ? "Exame" : "Teste");
row.setCell(writtenEvaluation.getDayDateYearMonthDay().toString("yyyy-MM-dd"));
row.setCell(writtenEvaluation.getBeginningDateTime().toString("HH:mm"));
row.setCell(writtenEvaluation.getEndDateTime().toString("HH:mm"));
final StringBuilder rooms = new StringBuilder();
int examVacancy = 0;
int normalVacancy = 0;
for (final WrittenEvaluationSpaceOccupation roomOccupation : writtenEvaluation
.getWrittenEvaluationSpaceOccupationsSet()) {
final Space room = roomOccupation.getRoom();
if (rooms.length() > 0) {
rooms.append(", ");
}
rooms.append(room.getName());
examVacancy += room.<Integer> getMetadata("examCapacity").orElse(0).intValue();
normalVacancy += room.getAllocatableCapacity().intValue();
}
row.setCell(rooms.toString());
row.setCell(examVacancy);
row.setCell(normalVacancy);
if (writtenEvaluation.getEnrollmentBeginDayDateYearMonthDay() == null) {
row.setCell(" ");
} else {
final int enrolmentCount = writtenEvaluation.getWrittenEvaluationEnrolmentsSet().size();
row.setCell(enrolmentCount);
}
}
}
}