public void save() {
   TutorshipIntention intention =
       TutorshipIntention.readByDcpAndTeacherAndInterval(dcp, teacher, academicInterval);
   ExecutionYear executionYear =
       (ExecutionYear) ExecutionYear.getExecutionInterval(academicInterval);
   if (intention == null && intending) {
     new TutorshipIntention(dcp, teacher, academicInterval);
     ProgramTutoredParticipationLog.createLog(
         dcp.getDegree(),
         executionYear,
         Bundle.MESSAGING,
         "log.degree.programtutoredparticipation.addteacher",
         teacher.getPerson().getPresentationName(),
         dcp.getDegree().getPresentationName());
   } else if (intention != null && !intending) {
     ProgramTutoredParticipationLog.createLog(
         dcp.getDegree(),
         executionYear,
         Bundle.MESSAGING,
         "log.degree.programtutoredparticipation.removeteacher",
         teacher.getPerson().getPresentationName(),
         dcp.getDegree().getPresentationName());
     intention.delete();
   }
 }
示例#2
0
  private String getTeachersAndTeachingHours(CurricularCourse course, boolean responsibleTeacher) {
    Map<Teacher, Double> responsiblesMap = new HashMap<Teacher, Double>();
    List<ExecutionSemester> executionSemesters = getSelectedExecutionSemesters();
    for (final ExecutionCourse executionCourse : course.getAssociatedExecutionCourses()) {
      if (executionSemesters.contains(executionCourse.getExecutionPeriod())) {
        for (Professorship professorhip : executionCourse.getProfessorshipsSet()) {
          if (professorhip.isResponsibleFor() == responsibleTeacher
              && professorhip
                  .getPerson()
                  .getTeacher()
                  .isActiveOrHasAuthorizationForSemester(executionCourse.getExecutionPeriod())) {
            Double hours = responsiblesMap.get(professorhip.getTeacher());
            if (hours == null) {
              hours = 0.0;
            }
            hours = hours + getHours(professorhip);
            responsiblesMap.put(professorhip.getTeacher(), hours);
          }
        }
      }
    }
    int counter = 1000;
    List<String> responsibles = new ArrayList<String>();
    for (Teacher teacher : responsiblesMap.keySet()) {
      String responsible =
          teacher.getPerson().getName() + " (" + responsiblesMap.get(teacher) + ")";
      counter -= JSONObject.escape(responsible + ", ").getBytes().length;
      responsibles.add(responsible);
    }

    if (!responsibleTeacher && course.isDissertation()) {
      Set<Teacher> teachers = new HashSet<Teacher>();
      for (ExecutionCourse executionCourse : course.getAssociatedExecutionCoursesSet()) {
        if (executionCourse
            .getExecutionPeriod()
            .getExecutionYear()
            .equals(executionSemester.getExecutionYear().getPreviousExecutionYear())) {
          for (Attends attends : executionCourse.getAttends()) {
            if (attends.hasEnrolment() && attends.getEnrolment().getThesis() != null) {
              for (ThesisEvaluationParticipant thesisEvaluationParticipant :
                  attends.getEnrolment().getThesis().getOrientation()) {
                if (thesisEvaluationParticipant.getPerson().getTeacher() != null
                    && thesisEvaluationParticipant
                        .getPerson()
                        .getTeacher()
                        .isActiveOrHasAuthorizationForSemester(
                            executionCourse.getExecutionPeriod())) {
                  teachers.add(thesisEvaluationParticipant.getPerson().getTeacher());
                }
              }
            }
          }
        }
      }
      for (Teacher teacher : teachers) {
        String responsible = teacher.getPerson().getName() + " (0.0)";
        if (counter - JSONObject.escape(responsible).getBytes().length < 0) {
          break;
        }
        if (!responsiblesMap.containsKey(teacher)) {
          counter -= JSONObject.escape(responsible + ", ").getBytes().length;
          responsibles.add(responsible);
        }
      }
    }

    return StringUtils.join(responsibles, ", ");
  }
 @Override
 public String toString() {
   return teacher.getPerson().getIstUsername() + "[" + (intending ? "x" : " ") + "]";
 }