public void setExecutionSemester(final ExecutionSemester executionSemester) {
this.executionSemester = executionSemester;
}
public StyledExcelSpreadsheet getInconsistencySpreadsheet() {
final StyledExcelSpreadsheet spreadsheet =
new StyledExcelSpreadsheet(BundleUtil.getString(Bundle.ACADEMIC, "label.course.load.inconsistency.filename")
+ "_" + executionSemester.getExecutionYear().getYear().replace('/', '_') + "_"
+ executionSemester.getSemester());
HSSFCellStyle normalStyle = spreadsheet.getExcelStyle().getValueStyle();
normalStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
HSSFWorkbook wb = spreadsheet.getWorkbook();
HSSFFont font = wb.createFont();
font.setColor(HSSFColor.BLACK.index);
font.setFontHeightInPoints((short) 8);
HSSFCellStyle redStyle = wb.createCellStyle();
redStyle.setFont(font);
redStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
redStyle.setFillForegroundColor(HSSFColor.ORANGE.index);
redStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
HSSFCellStyle yellowStyle = wb.createCellStyle();
yellowStyle.setFont(font);
yellowStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
yellowStyle.setFillForegroundColor(HSSFColor.YELLOW.index);
yellowStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
spreadsheet.newHeaderRow();
spreadsheet.addHeader(BundleUtil.getString(Bundle.ACADEMIC, "label.department"));
spreadsheet.addHeader(BundleUtil.getString(Bundle.ACADEMIC, "label.degree"));
spreadsheet.addHeader(BundleUtil.getString(Bundle.ACADEMIC, "label.executionCourse"));
spreadsheet.addHeader(BundleUtil.getString(Bundle.ACADEMIC, "label.shift"));
spreadsheet.addHeader(BundleUtil.getString(Bundle.ACADEMIC, "label.shiftType"));
spreadsheet.addHeader(BundleUtil.getString(Bundle.ACADEMIC, "label.load.competenceCourse"));
spreadsheet.addHeader(BundleUtil.getString(Bundle.ACADEMIC, "label.load.curricularCourse"));
spreadsheet.addHeader(BundleUtil.getString(Bundle.ACADEMIC, "label.load.executionCourse"));
spreadsheet.addHeader(BundleUtil.getString(Bundle.ACADEMIC, "label.load.lessonInstances"));
spreadsheet.addHeader(BundleUtil.getString(Bundle.ACADEMIC, "label.load.lesson.count"));
spreadsheet.addHeader(BundleUtil.getString(Bundle.ACADEMIC, "label.load.lessonInstances.count"));
for (final ExecutionCourse executionCourse : executionSemester.getAssociatedExecutionCoursesSet()) {
for (final CourseLoad courseLoad : executionCourse.getCourseLoadsSet()) {
for (final Shift shift : courseLoad.getShiftsSet()) {
spreadsheet.newRow();
spreadsheet.addCell(getDepartmentString(executionCourse));
spreadsheet.addCell(executionCourse.getDegreePresentationString());
spreadsheet.addCell(executionCourse.getName());
spreadsheet.addCell(shift.getNome());
spreadsheet.addCell(courseLoad.getType().getFullNameTipoAula());
final BigDecimal competenceCourseLoad =
new BigDecimal(getCompetenceCourseLoad(courseLoad)).setScale(2, RoundingMode.HALF_EVEN);
final BigDecimal curricularCourseLoad =
new BigDecimal(getCurricularCourseLoad(courseLoad)).setScale(2, RoundingMode.HALF_EVEN);
final BigDecimal executionLoad = courseLoad.getTotalQuantity().setScale(2, RoundingMode.HALF_EVEN);
final BigDecimal shiftCourseLoad = getShiftCourseLoad(shift).setScale(2, RoundingMode.HALF_EVEN);
if (competenceCourseLoad.signum() < 0) {
spreadsheet.addCell(getCompetenceCourseLoadStrings(courseLoad), redStyle);
} else {
spreadsheet.addCell(competenceCourseLoad);
}
if (!competenceCourseLoad.equals(curricularCourseLoad) || curricularCourseLoad.signum() < 0) {
spreadsheet.addCell(getCurricularCourseLoadString(courseLoad), redStyle);
} else {
spreadsheet.addCell(curricularCourseLoad);
}
if (!executionLoad.equals(curricularCourseLoad)) {
spreadsheet.addCell(executionLoad, redStyle);
} else {
spreadsheet.addCell(executionLoad);
}
if (!shiftCourseLoad.equals(executionLoad)) {
if (isLargeDifference(shiftCourseLoad, executionLoad,
competenceCourseLoad.divide(new BigDecimal(14), 2, RoundingMode.HALF_EVEN))) {
spreadsheet.addCell(shiftCourseLoad, redStyle);
} else {
spreadsheet.addCell(shiftCourseLoad, yellowStyle);
}
} else {
spreadsheet.addCell(shiftCourseLoad);
}
spreadsheet.addCell(shift.getAssociatedLessonsSet().size());
spreadsheet.addCell(getLessonInstanceCount(shift));
}
}
}
final HSSFSheet sheet = wb.getSheetAt(0);