Пример #1
0
  @Atomic
  public static SiteView run(String user) {
    check(RolePredicates.TEACHER_PREDICATE);
    Teacher teacher = Teacher.readTeacherByUsername(user);
    InfoTeacher infoTeacher = InfoTeacher.newInfoFromDomain(teacher);

    Collection<ExternalActivity> externalActivities = teacher.getAssociatedExternalActivities();

    List result =
        (List)
            CollectionUtils.collect(
                externalActivities,
                new Transformer() {
                  @Override
                  public Object transform(Object o) {
                    ExternalActivity externalActivity = (ExternalActivity) o;
                    return InfoExternalActivity.newInfoFromDomain(externalActivity);
                  }
                });

    InfoSiteExternalActivities bodyComponent = new InfoSiteExternalActivities();
    bodyComponent.setInfoExternalActivities(result);
    bodyComponent.setInfoTeacher(infoTeacher);

    SiteView siteView = new SiteView(bodyComponent);
    return siteView;
  }
Пример #2
0
  private void fillParticipant(
      String guiderRole,
      final PhdIndividualProgramProcess process,
      PhdParticipant phdParticipant,
      HSSFRow row) {
    String processNumber = process.getProcessNumber();
    String studentNumber =
        process.getStudent() != null ? process.getStudent().getNumber().toString() : "";
    String studentName = process.getPerson().getName();

    String participantName = phdParticipant.getName();
    String institution = phdParticipant.getWorkLocation();

    addCellValue(row, onNullEmptyString(processNumber), 0);
    addCellValue(row, onNullEmptyString(studentNumber), 1);
    addCellValue(row, onNullEmptyString(studentName), 2);
    addCellValue(row, onNullEmptyString(participantName), 3);
    addCellValue(row, onNullEmptyString(guiderRole), 4);
    addCellValue(row, onNullEmptyString(institution), 5);

    if (!phdParticipant.isTeacher()) {
      addCellValue(row, onNullEmptyString(null), 6);
      addCellValue(row, onNullEmptyString(null), 7);
      addCellValue(row, onNullEmptyString(null), 8);
    } else {
      InternalPhdParticipant internalPhdParticipant = (InternalPhdParticipant) phdParticipant;
      Teacher teacher = internalPhdParticipant.getTeacher();

      addCellValue(row, onNullEmptyString(teacher.getTeacherId()), 6);
      Department department = internalPhdParticipant.getDepartment();

      addCellValue(row, onNullEmptyString(department != null ? department.getCode() : ""), 7);
      addCellValue(row, onNullEmptyString(department != null ? department.getName() : ""), 8);
    }
  }
 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();
   }
 }
Пример #4
0
 private int countPastServices(Teacher teacher) {
   int count = 0;
   for (TeacherService teacherService : teacher.getTeacherServices()) {
     if (teacherService.getPastService() != null) {
       count++;
     }
   }
   return count;
 }
  protected List run(String teacherID, String executionYearID) throws FenixServiceException {

    final Teacher teacher = FenixFramework.getDomainObject(teacherID);
    if (teacher == null) {
      throw new DomainException("error.noTeacher");
    }

    final ExecutionYear executionYear;
    if (executionYearID == null) {
      executionYear = ExecutionYear.readCurrentExecutionYear();
    } else {
      executionYear = FenixFramework.getDomainObject(executionYearID);
    }

    final List<Professorship> responsibleFors = new ArrayList();
    for (final Professorship professorship : teacher.responsibleFors()) {
      if (professorship.getExecutionCourse().getExecutionPeriod().getExecutionYear()
          == executionYear) {
        responsibleFors.add(professorship);
      }
    }
    return getDetailedProfessorships(teacher.getProfessorships(executionYear), responsibleFors);
  }
Пример #6
0
 private Double getHours(Professorship professorhip) {
   Teacher teacher = professorhip.getPerson().getTeacher();
   TeacherService teacherService =
       teacher.getTeacherServiceByExecutionPeriod(
           professorhip.getExecutionCourse().getExecutionPeriod());
   Double result = 0.0;
   if (teacherService != null) {
     for (DegreeTeachingService degreeTeachingService :
         teacherService.getDegreeTeachingServices()) {
       if (degreeTeachingService
           .getProfessorship()
           .getExecutionCourse()
           .equals(professorhip.getExecutionCourse())) {
         for (CourseLoad courseLoad : degreeTeachingService.getShift().getCourseLoads()) {
           result =
               result
                   + courseLoad.getTotalQuantity().doubleValue()
                       * (degreeTeachingService.getPercentage().doubleValue() / 100);
         }
       }
     }
   }
   return result;
 }
 public TutorshipIntentionSelector(
     Teacher teacher,
     Department department,
     DegreeCurricularPlan dcp,
     AcademicInterval academicInterval) {
   this.teacher = teacher;
   this.department = department;
   this.dcp = dcp;
   this.academicInterval = academicInterval;
   TutorshipIntention intention =
       TutorshipIntention.readByDcpAndTeacherAndInterval(dcp, teacher, academicInterval);
   if (intention == null) {
     intending = false;
     deletable = true;
   } else {
     intending = true;
     deletable = intention.isDeletable();
   }
   previousParticipations =
       teacher.getActiveTutorships(academicInterval.getPreviousAcademicInterval()).size();
 }
  @Service
  public static List run(Integer departmentId, Integer executionYearId)
      throws FenixServiceException {

    // Execution Year
    ExecutionYear executionYear = null;
    if (executionYearId != null) {
      executionYear = rootDomainObject.readExecutionYearByOID(executionYearId);
    }
    // Departement
    Department department = rootDomainObject.readDepartmentByOID(departmentId);
    List teachers = department.getAllCurrentTeachers();
    Iterator iter = teachers.iterator();

    List<Professorship> professorships = new ArrayList<Professorship>();
    List<Professorship> responsibleFors = new ArrayList<Professorship>();
    while (iter.hasNext()) {
      Teacher teacher = (Teacher) iter.next();
      List<Professorship> teacherProfessorships = null;
      if (executionYear == null) {
        teacherProfessorships = teacher.getProfessorships();
      } else {
        teacherProfessorships = teacher.getProfessorships(executionYear);
      }
      if (teacherProfessorships != null) {
        professorships.addAll(teacherProfessorships);
      }

      List<Professorship> teacherResponsibleFors = null;
      if (executionYear == null) {
        teacherResponsibleFors = teacher.responsibleFors();
      } else {
        teacherResponsibleFors = new ArrayList<Professorship>();
        for (final Professorship professorship : teacher.responsibleFors()) {
          if (professorship.getExecutionCourse().isLecturedIn(executionYear)) {
            teacherResponsibleFors.add(professorship);
          }
        }
      }
      if (teacherResponsibleFors != null) {
        responsibleFors.addAll(teacherResponsibleFors);
      }
    }

    List detailedProfessorships = getDetailedProfessorships(professorships, responsibleFors);

    Collections.sort(
        detailedProfessorships,
        new Comparator() {

          @Override
          public int compare(Object o1, Object o2) {

            DetailedProfessorship detailedProfessorship1 = (DetailedProfessorship) o1;
            DetailedProfessorship detailedProfessorship2 = (DetailedProfessorship) o2;
            int result =
                detailedProfessorship1
                        .getInfoProfessorship()
                        .getInfoExecutionCourse()
                        .getIdInternal()
                        .intValue()
                    - detailedProfessorship2
                        .getInfoProfessorship()
                        .getInfoExecutionCourse()
                        .getIdInternal()
                        .intValue();
            if (result == 0
                && (detailedProfessorship1.getResponsibleFor().booleanValue()
                    || detailedProfessorship2.getResponsibleFor().booleanValue())) {
              if (detailedProfessorship1.getResponsibleFor().booleanValue()) {
                return -1;
              }
              if (detailedProfessorship2.getResponsibleFor().booleanValue()) {
                return 1;
              }
            }

            return result;
          }
        });

    List result = new ArrayList();
    iter = detailedProfessorships.iterator();
    List<DetailedProfessorship> temp = new ArrayList<DetailedProfessorship>();
    while (iter.hasNext()) {
      DetailedProfessorship detailedProfessorship = (DetailedProfessorship) iter.next();
      if (temp.isEmpty()
          || temp.get(temp.size() - 1)
              .getInfoProfessorship()
              .getInfoExecutionCourse()
              .equals(detailedProfessorship.getInfoProfessorship().getInfoExecutionCourse())) {
        temp.add(detailedProfessorship);
      } else {
        result.add(temp);
        temp = new ArrayList<DetailedProfessorship>();
        temp.add(detailedProfessorship);
      }
    }
    if (!temp.isEmpty()) {
      result.add(temp);
    }
    return result;
  }
Пример #9
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" : " ") + "]";
 }