rowSpan = 1;
} else {
rowSpan = 2;
}
HtmlTableRow row1 = tableHeader.createRow();
if (bean.getViewPhoto()) {
HtmlTableCell photoCell = row1.createCell(BundleUtil.getString(Bundle.APPLICATION, "label.photo"));
photoCell.setRowspan(rowSpan);
}
HtmlTableCell usernameCell = row1.createCell(BundleUtil.getString(Bundle.APPLICATION, "label.username"));
usernameCell.setRowspan(rowSpan);
HtmlTableCell numberCell = row1.createCell(BundleUtil.getString(Bundle.APPLICATION, "label.number"));
numberCell.setRowspan(rowSpan);
HtmlTableCell numberOfEnrolmentsCell =
row1.createCell(BundleUtil.getString(Bundle.APPLICATION, "label.numberOfEnrollments"));
numberOfEnrolmentsCell.setRowspan(rowSpan);
HtmlTableCell enrolmentStateCell1 =
row1.createCell(BundleUtil.getString(Bundle.APPLICATION, "label.attends.enrollmentState"));
enrolmentStateCell1.setRowspan(rowSpan);
HtmlTableCell degreeCell = row1.createCell(BundleUtil.getString(Bundle.APPLICATION, "label.Degree"));
degreeCell.setRowspan(rowSpan);
HtmlTableCell registrationStateCell =
row1.createCell(BundleUtil.getString(Bundle.APPLICATION, "label.registration.state"));
registrationStateCell.setRowspan(rowSpan);
HtmlTableCell nameCell = row1.createCell(BundleUtil.getString(Bundle.APPLICATION, "label.name"));
nameCell.setRowspan(rowSpan);
if (!groupings.isEmpty()) {
HtmlTableCell groupingCell = row1.createCell(BundleUtil.getString(Bundle.APPLICATION, "label.projectGroup"));
groupingCell.setColspan(groupings.size());
}
HtmlTableCell emailCell = row1.createCell(BundleUtil.getString(Bundle.APPLICATION, "label.mail"));
emailCell.setRowspan(rowSpan);
if (!shiftTypes.isEmpty()) {
HtmlTableCell shiftCell = row1.createCell(BundleUtil.getString(Bundle.APPLICATION, "label.attends.shifts"));
shiftCell.setColspan(shiftTypes.size());
}
HtmlTableRow row2 = tableHeader.createRow();
for (Grouping grouping : groupings) {
row2.createCell(grouping.getName());
}
for (ShiftType shiftType : shiftTypes) {
row2.createCell(BundleUtil.getString(Bundle.ENUMERATION, shiftType.getName()));
}
List<Attends> attendsResult = new ArrayList<Attends>(bean.getAttendsResult());
Collections.sort(attendsResult, Attends.COMPARATOR_BY_STUDENT_NUMBER);
for (Attends attends : attendsResult) {
HtmlTableRow row = htmlTable.createRow();
if (bean.getViewPhoto()) {
HtmlImage htmlImage = new HtmlImage();
htmlImage.setSource(RenderUtils.getContextRelativePath("") + "/user/photo/"
+ attends.getRegistration().getStudent().getPerson().getUsername());
row.createCell().setBody(htmlImage);
}
row.createCell(attends.getRegistration().getStudent().getPerson().getUsername());
row.createCell(attends.getRegistration().getNumber().toString());
if (attends.getEnrolment() == null) {
row.createCell("--");
} else {
row.createCell(String.valueOf(attends.getEnrolment().getNumberOfTotalEnrolmentsInThisCourse(
attends.getEnrolment().getExecutionPeriod())));
}
final StudentAttendsStateType stateType = attends.getAttendsStateType();
row.createCell(stateType != null ? BundleUtil.getString(Bundle.ENUMERATION, stateType.getQualifiedName()) : "--");
row.createCell(attends.getStudentCurricularPlanFromAttends().getDegreeCurricularPlan().getName());
final RegistrationState registrationState =
attends.getRegistration().getLastRegistrationState(attends.getExecutionYear());
row.createCell(registrationState == null ? "" : registrationState.getStateType().getDescription());
row.createCell(attends.getRegistration().getStudent().getPerson().getFirstAndLastName());
for (Grouping grouping : groupings) {
StudentGroup studentGroup = attends.getStudentGroupByGrouping(grouping);
if (studentGroup == null) {
row.createCell("N/A");
} else {
HtmlLink groupLink = new HtmlLink();
groupLink.setText(studentGroup.getGroupNumber().toString());
groupLink.setUrl(getGroupURL(studentGroup));
row.createCell().setBody(groupLink);
}
}
String email = attends.getRegistration().getStudent().getPerson().getEmail();
row.createCell().setBody(email != null ? new HtmlEMailLink(email) : new HtmlLabel(""));
for (ShiftType shiftType : shiftTypes) {
Shift shift = attends.getRegistration().getShiftFor(bean.getExecutionCourse(), shiftType);
if (shift == null) {
row.createCell("N/A");
} else {
row.createCell(shift.getNome());
}
}
}
return htmlTable;