private String findDepartment(final CurricularCourse curricularCourse) {
final StringBuilder stringBuilder = new StringBuilder();
final CompetenceCourse competenceCourse = curricularCourse.getCompetenceCourse();
if (competenceCourse != null) {
final DepartmentUnit departmentUnit = competenceCourse.getDepartmentUnit();
if (departmentUnit == null) {
for (final Department department : competenceCourse.getDepartmentsSet()) {
if (stringBuilder.length() > 0) {
stringBuilder.append(", ");
}
stringBuilder.append(department.getName());
}
} else {
stringBuilder.append(departmentUnit.getName());
}
}
return stringBuilder.length() == 0 ? " " : stringBuilder.toString();
}