final List<SelectItem> result = new ArrayList<SelectItem>();
final List<List<DegreeModule>> degreeModulesSet =
getDegreeCurricularPlan().getDcpDegreeModulesIncludingFullPath(CourseGroup.class, null);
final Set<CourseGroup> allParents = getCourseGroup(getParentCourseGroupID()).getAllParentCourseGroups();
for (final List<DegreeModule> degreeModules : degreeModulesSet) {
final DegreeModule lastDegreeModule = (degreeModules.size() > 0) ? degreeModules.get(degreeModules.size() - 1) : null;
if (!allParents.contains(lastDegreeModule) && lastDegreeModule != getCourseGroup(getParentCourseGroupID())) {
final StringBuilder pathName = new StringBuilder();
for (final DegreeModule degreeModule : degreeModules) {
pathName.append((pathName.length() == 0) ? "" : " > ").append(degreeModule.getName());
}
result.add(new SelectItem(lastDegreeModule.getExternalId(), pathName.toString()));
}
}
Collections.sort(result, new BeanComparator("label"));
result.add(0, new SelectItem(this.NO_SELECTION_STRING, BundleUtil.getString(Bundle.BOLONHA, "choose")));
return result;