Exemplo n.º 1
0
 private Map<ShiftType, Double> getAllDegreeTeachingServices(ExecutionCourse executionCourse) {
   Map<ShiftType, Double> shiftTypesPercentageMap = new HashMap<ShiftType, Double>();
   for (Professorship professorship : executionCourse.getProfessorshipsSet()) {
     for (DegreeTeachingService degreeTeachingService :
         professorship.getDegreeTeachingServicesSet()) {
       for (ShiftType shiftType : degreeTeachingService.getShift().getTypes()) {
         Double percentage = shiftTypesPercentageMap.get(shiftType);
         if (percentage == null) {
           percentage = degreeTeachingService.getPercentage();
         } else {
           percentage += degreeTeachingService.getPercentage();
         }
         shiftTypesPercentageMap.put(shiftType, percentage);
       }
     }
     for (NonRegularTeachingService nonRegularTeachingService :
         professorship.getNonRegularTeachingServicesSet()) {
       for (ShiftType shiftType : nonRegularTeachingService.getShift().getTypes()) {
         Double percentage = shiftTypesPercentageMap.get(shiftType);
         if (percentage == null) {
           percentage = nonRegularTeachingService.getPercentage();
         } else {
           percentage += nonRegularTeachingService.getPercentage();
         }
         shiftTypesPercentageMap.put(shiftType, percentage);
       }
     }
   }
   return shiftTypesPercentageMap;
 }
Exemplo n.º 2
0
  private void fillTeachersInquiriesWithTeachers(
      final ExecutionCourse executionCourse,
      final Set<ShiftType> shiftTypes,
      StudentInquiryTemplate studentTeacherInquiryTemplate) {
    Map<Person, Map<ShiftType, StudentTeacherInquiryBean>> teachersShifts =
        new HashMap<Person, Map<ShiftType, StudentTeacherInquiryBean>>();
    Map<ShiftType, Double> allTeachingServicesShiftType = null;
    Set<ShiftType> nonAssociatedTeachersShiftTypes = null;
    for (final Professorship professorship : executionCourse.getProfessorshipsSet()) {

      final Person person = professorship.getPerson();
      if (!teachersShifts.containsKey(person)) {
        teachersShifts.put(person, new HashMap<ShiftType, StudentTeacherInquiryBean>());
      }

      final Map<ShiftType, StudentTeacherInquiryBean> teacherShift = teachersShifts.get(person);
      final AffiliatedTeacherDTO teacherDTO = new AffiliatedTeacherDTO(person);

      //	    Teacher teacher = person.getTeacher();
      //	    boolean mandatoryTeachingService = false;
      //	    if (teacher != null &&
      // teacher.isTeacherProfessorCategory(executionCourse.getExecutionPeriod())) {
      //		mandatoryTeachingService = true;
      //	    }

      Map<ShiftType, Double> shiftTypesPercentageMap = new HashMap<ShiftType, Double>();
      for (DegreeTeachingService degreeTeachingService :
          professorship.getDegreeTeachingServicesSet()) {
        for (ShiftType shiftType : degreeTeachingService.getShift().getTypes()) {
          Double percentage = shiftTypesPercentageMap.get(shiftType);
          if (percentage == null) {
            percentage = degreeTeachingService.getPercentage();
          } else {
            percentage += degreeTeachingService.getPercentage();
          }
          shiftTypesPercentageMap.put(shiftType, percentage);
        }
      }
      for (NonRegularTeachingService nonRegularTeachingService :
          professorship.getNonRegularTeachingServicesSet()) {
        for (ShiftType shiftType : nonRegularTeachingService.getShift().getTypes()) {
          Double percentage = shiftTypesPercentageMap.get(shiftType);
          if (percentage == null) {
            percentage = nonRegularTeachingService.getPercentage();
          } else {
            percentage += nonRegularTeachingService.getPercentage();
          }
          shiftTypesPercentageMap.put(shiftType, percentage);
        }
      }

      for (ShiftType shiftType : shiftTypesPercentageMap.keySet()) {
        Double percentage = shiftTypesPercentageMap.get(shiftType);
        if (percentage >= 20) {
          if (!teacherShift.containsKey(shiftType)) {
            teacherShift.put(
                shiftType,
                new StudentTeacherInquiryBean(
                    teacherDTO, executionCourse, shiftType, studentTeacherInquiryTemplate));
          }
        }
      }

      if (shiftTypesPercentageMap.isEmpty() /* && !mandatoryTeachingService */) {
        if (allTeachingServicesShiftType == null) {
          allTeachingServicesShiftType = getAllDegreeTeachingServices(executionCourse);
        }
        if (nonAssociatedTeachersShiftTypes == null) {
          nonAssociatedTeachersShiftTypes = getNonAssociatedTeachersShiftTypes(executionCourse);
        }
        for (final ShiftType shiftType : shiftTypes) {
          Double shiftTypePercentage = allTeachingServicesShiftType.get(shiftType);
          if (shiftTypePercentage == null
              || shiftTypePercentage < 100.0
              || nonAssociatedTeachersShiftTypes.contains(shiftType)) {
            teacherShift.put(
                shiftType,
                new StudentTeacherInquiryBean(
                    teacherDTO, executionCourse, shiftType, studentTeacherInquiryTemplate));
          }
        }
      }
    }
    for (Entry<Person, Map<ShiftType, StudentTeacherInquiryBean>> entry :
        teachersShifts.entrySet()) {
      ArrayList<StudentTeacherInquiryBean> studentTeachers =
          new ArrayList<StudentTeacherInquiryBean>(entry.getValue().values());
      Collections.sort(studentTeachers, new BeanComparator("shiftType"));
      if (!studentTeachers.isEmpty()) {
        getTeachersInquiries().put(new AffiliatedTeacherDTO(entry.getKey()), studentTeachers);
      }
    }
  }