protected void run(String tsdId, final String courseId) throws FenixServiceException {

    TeacherServiceDistribution rootTSD =
        FenixFramework.<TeacherServiceDistribution>getDomainObject(tsdId).getRootTSD();
    CompetenceCourse course = FenixFramework.getDomainObject(courseId);

    if (!rootTSD.getCompetenceCourses().contains(course)) {
      for (ExecutionSemester period :
          rootTSD.getTSDProcessPhase().getTSDProcess().getExecutionPeriods()) {
        if (course.getCurricularCoursesWithActiveScopesInExecutionPeriod(period).size() > 0) {
          new TSDCompetenceCourse(rootTSD, course, period);
        }
      }
    }
  }
  public String getName() {
    StringBuilder sb = new StringBuilder();

    for (int i = 0; i < level; i++) {
      sb.append(" - ");
    }

    sb.append(" ");
    sb.append(tsd.getName());

    return sb.toString();
  }
  private static void buildTeacherServiceDistributionOptionEntriesRec(
      List<TeacherServiceDistributionDTOEntry> tsdOptionEntries,
      int level,
      TeacherServiceDistribution grouping,
      Person person,
      boolean testCoursesManagementGroupPermission,
      boolean testTeachersManagementGroupPermission,
      boolean testTeachersValuationManagerPermission,
      boolean testCoursesValuationManagerPermission) {

    if (person == null
        || (testCoursesValuationManagerPermission
            && grouping.isMemberOfCoursesValuationManagers(person))
        || (testTeachersValuationManagerPermission
            && grouping.isMemberOfTeachersValuationManagers(person))
        || (testCoursesManagementGroupPermission
            && grouping.isMemberOfCoursesManagementGroup(person))
        || (testTeachersManagementGroupPermission
            && grouping.isMemberOfTeachersManagementGroup(person))
        || grouping.getTSDProcessPhase().getTSDProcess().getHasSuperUserPermission(person)) {
      tsdOptionEntries.add(new TeacherServiceDistributionDTOEntry(grouping, level));
      person = null;
    }

    List<TeacherServiceDistribution> childsList =
        new ArrayList<TeacherServiceDistribution>(grouping.getChilds());
    Collections.sort(childsList, new BeanComparator("name"));

    for (TeacherServiceDistribution tsd : childsList) {
      buildTeacherServiceDistributionOptionEntriesRec(
          tsdOptionEntries,
          level + 1,
          tsd,
          person,
          testCoursesManagementGroupPermission,
          testTeachersManagementGroupPermission,
          testTeachersValuationManagerPermission,
          testCoursesValuationManagerPermission);
    }
  }
 public Integer getIdInternal() {
   return tsd.getIdInternal();
 }