response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition", "attachment; filename=list.xls");
final ServletOutputStream outputStream = response.getOutputStream();
final Spreadsheet spreadsheet = new Spreadsheet("list");
spreadsheet.setHeader(BundleUtil.getString(Bundle.BOLONHA, "competenceCourse"));
spreadsheet.setHeader(BundleUtil.getString(Bundle.BOLONHA, "curricularPlan"));
spreadsheet.setHeader(BundleUtil.getString(Bundle.BOLONHA, "curricularYear"));
spreadsheet.setHeader(BundleUtil.getString(Bundle.BOLONHA, "label.semester"));
for (final CompetenceCourse competenceCourse : competenceCourses) {
if (competenceCourse.getCurricularStage() == CurricularStage.APPROVED) {
for (final CurricularCourse curricularCourse : competenceCourse.getAssociatedCurricularCoursesSet()) {
for (final ExecutionCourse executionCourse : curricularCourse.getAssociatedExecutionCoursesSet()) {
final ExecutionSemester executionSemester = executionCourse.getExecutionPeriod();
for (final DegreeModuleScope degreeModuleScope : curricularCourse.getDegreeModuleScopes()) {
if (degreeModuleScope.isActiveForExecutionPeriod(executionSemester)) {
final DegreeCurricularPlan degreeCurricularPlan = curricularCourse.getDegreeCurricularPlan();
final Row row = spreadsheet.addRow();
row.setCell(competenceCourse.getName(executionSemester));
row.setCell(degreeCurricularPlan.getName());
row.setCell(degreeModuleScope.getCurricularYear());
row.setCell(degreeModuleScope.getCurricularSemester());
}
}
}
}
}
}
spreadsheet.exportToXLSSheet(outputStream);
outputStream.flush();
response.flushBuffer();
} catch (final IOException e) {
throw new FenixServiceException(e);
}