public List<SelectItem> getExecutionCoursesLabels() {
   final List<SelectItem> result = new ArrayList();
   for (final ExecutionCourse executionCourse : getExecutionCourses()) {
     result.add(new SelectItem(executionCourse.getExternalId(), executionCourse.getNome()));
   }
   Collections.sort(result, new BeanComparator("label"));
   return result;
 }
Example #2
0
  public StudentInquiryBean(
      StudentTeacherInquiryTemplate studentTeacherInquiryTemplate,
      StudentInquiryRegistry inquiryRegistry) {
    setInquiryRegistry(inquiryRegistry);
    setStartedWhen(new DateTime());
    final ExecutionCourse executionCourse = getInquiryRegistry().getExecutionCourse();
    final Set<ShiftType> shiftTypes = executionCourse.getShiftTypes();

    fillTeachersInquiriesWithTeachers(executionCourse, shiftTypes, studentTeacherInquiryTemplate);
  }
  protected Boolean run(
      String executionCourseID,
      String studentGroupID,
      String groupPropertiesID,
      List studentUsernames)
      throws FenixServiceException {

    final StudentGroup studentGroup = FenixFramework.getDomainObject(studentGroupID);
    if (studentGroup == null) {
      throw new InvalidArgumentsServiceException();
    }

    final Grouping grouping = studentGroup.getGrouping();
    final IGroupEnrolmentStrategyFactory enrolmentGroupPolicyStrategyFactory =
        GroupEnrolmentStrategyFactory.getInstance();
    final IGroupEnrolmentStrategy strategy =
        enrolmentGroupPolicyStrategyFactory.getGroupEnrolmentStrategyInstance(grouping);

    if (!strategy.checkStudentsUserNamesInGrouping(studentUsernames, grouping)) {
      throw new InvalidArgumentsServiceException();
    }

    StringBuilder sbStudentNumbers = new StringBuilder("");
    sbStudentNumbers.setLength(0);
    for (final String studentUsername : (List<String>) studentUsernames) {
      Attends attend = grouping.getStudentAttend(studentUsername);
      if (attend != null) {
        if (sbStudentNumbers.length() != 0) {
          sbStudentNumbers.append(", " + attend.getRegistration().getNumber().toString());
        } else {
          sbStudentNumbers.append(attend.getRegistration().getNumber().toString());
        }
        attend.removeStudentGroups(studentGroup);
      }
    }

    // no students means no log entry -- list may contain invalid values, so
    // its size cannot be used to test
    if (sbStudentNumbers.length() != 0) {
      List<ExecutionCourse> ecs = grouping.getExecutionCourses();
      for (ExecutionCourse ec : ecs) {
        GroupsAndShiftsManagementLog.createLog(
            ec,
            "resources.MessagingResources",
            "log.executionCourse.groupAndShifts.grouping.group.element.removed",
            Integer.toString(studentUsernames.size()),
            sbStudentNumbers.toString(),
            studentGroup.getGroupNumber().toString(),
            grouping.getName(),
            ec.getNome(),
            ec.getDegreePresentationString());
      }
    }
    return true;
  }
  protected Boolean run(
      final String executionCourseCode, final String groupPropertiesCode, final String[] selected)
      throws FenixServiceException {

    if (selected == null) {
      return Boolean.TRUE;
    }

    final Grouping groupProperties = FenixFramework.getDomainObject(groupPropertiesCode);
    if (groupProperties == null) {
      throw new ExistingServiceException();
    }

    final List<ExecutionCourse> executionCourses = groupProperties.getExecutionCourses();
    StringBuilder sbStudentNumbers = new StringBuilder("");
    sbStudentNumbers.setLength(0);
    // studentCodes list has +1 entry if "select all" was selected
    int totalStudentsProcessed = 0;

    for (final String number : selected) {
      if (number.equals("Todos os Alunos")) {
      } else {
        Registration registration = FenixFramework.getDomainObject(number);
        if (!studentHasSomeAttendsInGrouping(registration, groupProperties)) {
          final Attends attends = findAttends(registration, executionCourses);
          if (attends != null) {
            if (sbStudentNumbers.length() != 0) {
              sbStudentNumbers.append(", " + registration.getNumber().toString());
            } else {
              sbStudentNumbers.append(registration.getNumber().toString());
            }
            totalStudentsProcessed++;
            groupProperties.addAttends(attends);
          }
        }
      }
    }

    if (totalStudentsProcessed > 0) {
      List<ExecutionCourse> ecs = groupProperties.getExecutionCourses();
      for (ExecutionCourse ec : ecs) {
        GroupsAndShiftsManagementLog.createLog(
            ec,
            Bundle.MESSAGING,
            "log.executionCourse.groupAndShifts.grouping.attends.added",
            Integer.toString(totalStudentsProcessed),
            sbStudentNumbers.toString(),
            groupProperties.getName(),
            ec.getNome(),
            ec.getDegreePresentationString());
      }
    }

    return Boolean.TRUE;
  }
  protected Boolean run(String objectCode, String groupingCode) throws FenixServiceException {
    Grouping grouping = FenixFramework.getDomainObject(groupingCode);

    if (grouping == null) {
      throw new ExistingServiceException();
    }

    List attendsElements = new ArrayList();
    attendsElements.addAll(grouping.getAttends());
    Iterator iterator = attendsElements.iterator();
    StringBuilder sbStudentNumbers = new StringBuilder("");
    sbStudentNumbers.setLength(0);

    while (iterator.hasNext()) {
      Attends attend = (Attends) iterator.next();
      if (sbStudentNumbers.length() != 0) {
        sbStudentNumbers.append(", " + attend.getRegistration().getNumber().toString());
      } else {
        sbStudentNumbers.append(attend.getRegistration().getNumber().toString());
      }

      boolean found = false;
      Iterator iterStudentsGroups = grouping.getStudentGroupsSet().iterator();
      while (iterStudentsGroups.hasNext() && !found) {

        StudentGroup studentGroup = (StudentGroup) iterStudentsGroups.next();

        if (studentGroup != null) {
          studentGroup.removeAttends(attend);
          found = true;
        }
      }
      grouping.removeAttends(attend);
    }

    // no students means no log entry -- list may contain invalid values, so
    // its size cannot be used to test
    if (sbStudentNumbers.length() != 0) {
      List<ExecutionCourse> ecs = grouping.getExecutionCourses();
      for (ExecutionCourse ec : ecs) {
        GroupsAndShiftsManagementLog.createLog(
            ec,
            "resources.MessagingResources",
            "log.executionCourse.groupAndShifts.grouping.memberSet.removed",
            Integer.toString(attendsElements.size()),
            sbStudentNumbers.toString(),
            grouping.getName(),
            ec.getNome(),
            ec.getDegreePresentationString());
      }
    }

    return true;
  }
  private static void informStudents(
      final StudentGroup studentGroup, final Registration registration, final Grouping grouping) {

    final StringBuilder executionCourseNames = new StringBuilder();
    for (final ExecutionCourse executionCourse : grouping.getExecutionCourses()) {
      if (executionCourseNames.length() > 0) {
        executionCourseNames.append(", ");
      }
      executionCourseNames.append(executionCourse.getNome());
    }
  }
Example #7
0
 public void run(
     Integer executionCourseID,
     ExecutionCourse executionCourseTo,
     ExecutionCourse executionCourseFrom,
     Shift shift) {
   if (executionCourseTo != null && executionCourseFrom != null) {
     if (shift == null) {
       executionCourseTo.copyLessonPlanningsFrom(executionCourseFrom);
     } else {
       executionCourseTo.createLessonPlanningsUsingSummariesFrom(shift);
     }
   }
 }
Example #8
0
  private static void writeMarks(
      final List<AttendsMark> marks,
      final ExecutionCourse executionCourse,
      final Evaluation evaluation)
      throws FenixServiceMultipleException {

    final List<DomainException> exceptionList = new ArrayList<DomainException>();

    for (final AttendsMark entry : marks) {

      final Attends attend = findAttend(executionCourse, entry.attendId);
      final String markValue = entry.mark;

      if (attend.hasEnrolment() && attend.getEnrolment().isImpossible()) {
        exceptionList.add(
            new DomainException(
                "errors.student.with.impossible.enrolment",
                attend.getRegistration().getStudent().getNumber().toString()));
      } else {
        final Mark mark = attend.getMarkByEvaluation(evaluation);

        if (isToDeleteMark(markValue)) {
          if (mark != null) {
            mark.delete();
          }
        } else {
          try {
            if (mark == null) {
              evaluation.addNewMark(attend, markValue);
            } else {
              mark.setMark(markValue);
            }
          } catch (InvalidMarkDomainException e) {
            exceptionList.add(e);
          }
        }
      }
    }

    if (!exceptionList.isEmpty()) {
      throw new FenixServiceMultipleException(exceptionList);
    }

    EvaluationManagementLog.createLog(
        executionCourse,
        "resources.MessagingResources",
        "log.executionCourse.evaluation.generic.edited.marks",
        evaluation.getPresentationName(),
        executionCourse.getName(),
        executionCourse.getDegreePresentationString());
  }
 public boolean deleteAllTeachersResults() {
   ExecutionCourse executionCourse = null;
   try {
     executionCourse = FenixFramework.getDomainObject(getExecutionCourseOID().toString());
   } catch (ClassCastException cce) {
     throw new DomainException("error.executionCourse.dontExist", cce.getCause());
   } catch (MissingObjectException moe) {
     throw new DomainException("error.executionCourse.dontExist", moe.getCause());
   }
   setProfessorshipOID(null);
   setShiftType(null);
   setInquiryQuestionOID(null);
   return executionCourse.deleteAllTeachersResults();
 }
Example #10
0
    @Override
    public List<ExecutionCourse> getExecutionCourses() {
      SortedSet<ExecutionCourse> result =
          new TreeSet<ExecutionCourse>(
              ExecutionCourse.EXECUTION_COURSE_COMPARATOR_BY_EXECUTION_PERIOD_AND_NAME);

      Integer semester = getSemesterNumber();
      for (ExecutionCourse executionCourse : getParentExecutionCourses()) {
        if (executionCourse.getExecutionPeriod().getSemester().equals(semester)) {
          result.add(executionCourse);
        }
      }

      return new ArrayList<ExecutionCourse>(result);
    }
  public void validateResponsibleForList(
      Teacher teacher, ExecutionCourse executionCourse, Professorship responsibleForAdded)
      throws MaxResponsibleForExceed, InvalidCategory {

    List responsibleFors = executionCourse.responsibleFors();

    if ((!responsibleFors.contains(responsibleForAdded))
        && (responsibleFors.size() >= MAX_RESPONSIBLEFOR_BY_EXECUTION_COURSE)) {
      List infoResponsibleFors =
          (List)
              CollectionUtils.collect(
                  responsibleFors,
                  new Transformer() {

                    @Override
                    public Object transform(Object input) {
                      Professorship responsibleFor = (Professorship) input;
                      InfoProfessorship infoResponsibleFor =
                          InfoProfessorship.newInfoFromDomain(responsibleFor);
                      return infoResponsibleFor;
                    }
                  });

      InfoExecutionCourse infoExecutionCourse =
          InfoExecutionCourse.newInfoFromDomain(executionCourse);
      throw new MaxResponsibleForExceed(infoExecutionCourse, infoResponsibleFors);
    }
  }
Example #12
0
  private static Attends findAttend(
      final ExecutionCourse executionCourse,
      final Integer studentNumber,
      final List<DomainException> exceptionList) {

    final List<Attends> activeAttends = new ArrayList<Attends>(2);
    for (final Attends attend : executionCourse.getAttends()) {
      if (attend.getRegistration().getNumber().equals(studentNumber)
          && (isActive(attend) || belongsToActiveExternalCycle(attend))) {
        activeAttends.add(attend);
      }
    }

    if (activeAttends.size() == 1) {
      return activeAttends.iterator().next();
    }

    if (activeAttends.isEmpty()) {
      exceptionList.add(
          new DomainException("errors.student.without.active.attends", studentNumber.toString()));
    } else {
      exceptionList.add(
          new DomainException(
              "errors.student.with.several.active.attends", studentNumber.toString()));
    }

    return null;
  }
Example #13
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;
 }
  public static InfoExternalExecutionCourseInfo newFromExecutionCourse(
      ExecutionCourse executionCourse) {
    InfoExternalExecutionCourseInfo info = new InfoExternalExecutionCourseInfo();
    info.setName(executionCourse.getNome());

    return info;
  }
 public List<InfoExecutionCourse> run(
     AcademicInterval academicInterval, ExecutionDegree executionDegree, String courseName) {
   List<ExecutionCourse> executionCourses =
       ExecutionCourse.searchByAcademicIntervalAndExecutionDegreeYearAndName(
           academicInterval, executionDegree, null, courseName);
   return fillInfoExecutionCourses(academicInterval, executionCourses);
 }
Example #16
0
 private static Attends findAttend(final ExecutionCourse executionCourse, final String attendId) {
   for (final Attends attend : executionCourse.getAttends()) {
     if (attend.getExternalId().equals(attendId)) {
       return attend;
     }
   }
   return null;
 }
Example #17
0
 private Set<ShiftType> getNonAssociatedTeachersShiftTypes(ExecutionCourse executionCourse) {
   Set<ShiftType> nonAssociatedTeachersShiftTypes = new HashSet<ShiftType>();
   for (Shift shift : executionCourse.getAssociatedShifts()) {
     if (shift.getDegreeTeachingServicesSet().isEmpty()
         && shift.getNonRegularTeachingServicesSet().isEmpty()) {
       nonAssociatedTeachersShiftTypes.addAll(shift.getTypes());
     }
   }
   return nonAssociatedTeachersShiftTypes;
 }
Example #18
0
  @Override
  protected boolean forward(ProcessingContext context, PathElementsProvider provider)
      throws IOException, ServletException {
    if (provider.hasNext()) {
      return false;
    } else {
      SemesterContext ownContext = (SemesterContext) context;
      ExecutionCourse executionCourse = ownContext.getExecutionCourse();

      if (executionCourse == null) {
        return false;
      } else {

        /*
         * This is an ugly hack so this process still works until the
         * semester ends where we can easily notify everyone that the
         * link format has changed.
         *
         * 04-02-2007 pcma
         */
        HttpServletRequest request = context.getRequest();
        ExecutionCourseSite portalInstance = executionCourse.getSite();
        MetaDomainObjectPortal portal = MetaDomainObjectPortal.getPortal(portalInstance.getClass());

        List<Content> contents = new ArrayList<Content>();
        contents.add(portal);
        contents.add(portalInstance);

        FilterFunctionalityContext filterContext =
            (FilterFunctionalityContext) request.getAttribute(FunctionalityContext.CONTEXT_KEY);
        if (filterContext != null) {
          request.removeAttribute(FunctionalityContext.CONTEXT_KEY);
        }
        filterContext = new FilterFunctionalityContext(request, contents);
        filterContext.setHasBeenForwarded();
        request.setAttribute(FunctionalityContext.CONTEXT_KEY, filterContext);

        String url = portalInstance.getReversePath();
        context.getResponse().sendRedirect(context.getRequest().getContextPath() + url);
        return true;
      }
    }
  }
Example #19
0
 protected void run(
     String executionCourseID,
     LessonPlanning lessonPlanning,
     ExecutionCourse executionCourse,
     ShiftType shiftType) {
   if (lessonPlanning != null) {
     lessonPlanning.delete();
   } else if (executionCourse != null && shiftType != null) {
     executionCourse.deleteLessonPlanningsByLessonType(shiftType);
   }
 }
 @Override
 public ActionForward execute(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   final String executionCourseIdString = request.getParameter("id");
   final DomainObject obj = FenixFramework.getDomainObject(executionCourseIdString);
   if (!(obj instanceof ExecutionCourse)) {
     return forward("/notFound.jsp");
   }
   ExecutionCourse executionCourse = (ExecutionCourse) obj;
   final ExecutionCourseAnnouncementBoard announcementBoard = executionCourse.getBoard();
   if (announcementBoard == null) {
     return forward(
         "/publico/executionCourse.do?method=notFound&executionCourseID="
             + executionCourse.getExternalId());
   }
   return forward(
       "/external/announcementsRSS.do?announcementBoardId=" + announcementBoard.getExternalId());
 }
Example #21
0
  public ActionForward generate(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    ExecutionCourse executionCourse = getExecutionCourse(request);
    if (executionCourse == null) {
      return mapping.findForward("fallback");
    }

    ArchiveOptions options = getOptions(request);
    if (options == null) {
      return prepare(mapping, actionForm, request, response);
    }

    String name = getArchiveName(executionCourse);
    // NOTE: Using a DiskZipArchive instead of a ZipArchive because a
    // ZipArchive
    // writes directly to the response during the entire process and
    // prevents
    // the server from showing an error page when something goes wrong. This
    // leaves the user with a corrupt Zip file and no other information.
    Archive archive = new DiskZipArchive(response, name);
    Fetcher fetcher = new Fetcher(archive, request, response);

    queueResources(request, executionCourse, options, fetcher);

    List<Content> contents = new ArrayList<Content>();
    contents.add(MetaDomainObject.getMeta(ExecutionCourseSite.class).getAssociatedPortal());
    contents.add(executionCourse.getSite());
    FilterFunctionalityContext context = new FilterFunctionalityContext(request, contents);

    fetcher.process(context);
    archive.finish();

    return null;
  }
Example #22
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);
      }
    }
  }
Example #23
0
 private String getArchiveName(ExecutionCourse executionCourse) {
   String year = executionCourse.getExecutionYear().getYear().replaceAll("/", "-");
   return String.format("%s (%s)", executionCourse.getNome(), year);
 }
Example #24
0
  private void queueResources(
      HttpServletRequest request,
      ExecutionCourse executionCourse,
      ArchiveOptions options,
      Fetcher fetcher) {
    fetcher.queue(new Resource("CSS/main.css", "/CSS/main.css"));
    fetcher.queue(new Resource("images/icon_email.gif", "/images/icon_email.gif"));

    String announcementsName = options.isAnnouncements() ? "announcements.html" : "#";
    String planningName = options.isPlanning() ? "planning.html" : "#";
    String scheduleName = options.isSchedule() ? "schedule.html" : "#";
    String shiftsName = options.isShifts() ? "shifts.html" : "#";
    String groupingsName = options.isGroupings() ? "groupings.html" : "#";
    String evaluationName = options.isEvaluations() ? "evaluation.html" : "#";

    String contextPath = request.getContextPath();

    List<Rule> globalRules = new ArrayList<Rule>();
    globalRules.add(new ResourceRule(contextPath + "/CSS/(.*)", "CSS/$1"));
    globalRules.add(new ResourceRule(contextPath + "/images/(.*)", "images/$1"));
    globalRules.add(
        new SimpleTransformRule(
            contextPath + "/publico/showCourseSite.do\\?.*?method=showCurricularCourseSite.*",
            "#"));
    globalRules.add(
        new SimpleTransformRule(
            contextPath
                + "/publico/executionCourse.do\\?(executionCourseID=[0-9]+|&amp;|method=firstPage)+",
            "index.html"));
    globalRules.add(
        new SimpleTransformRule(
            contextPath
                + "/publico/announcementManagement.do\\?(executionCourseID=[0-9]+|&amp;|method=start)+",
            announcementsName));
    globalRules.add(
        new SimpleTransformRule(
            contextPath
                + "/publico/executionCourse.do\\?(executionCourseID=[0-9]+|&amp;|method=lessonPlannings)+",
            planningName));
    globalRules.add(
        new SimpleTransformRule(
            contextPath
                + "/publico/executionCourse.do\\?(executionCourseID=[0-9]+|&amp;|method=summaries)+",
            "summaries.html"));
    globalRules.add(
        new SimpleTransformRule(
            contextPath
                + "/publico/executionCourse.do\\?(executionCourseID=[0-9]+|&amp;|method=objectives)+",
            "objectives.html"));
    globalRules.add(
        new SimpleTransformRule(
            contextPath
                + "/publico/executionCourse.do\\?(executionCourseID=[0-9]+|&amp;|method=program)+",
            "program.html"));
    globalRules.add(
        new SimpleTransformRule(
            contextPath
                + "/publico/executionCourse.do\\?(executionCourseID=[0-9]+|&amp;|method=evaluationMethod)+",
            "evaluation-method.html"));
    globalRules.add(
        new SimpleTransformRule(
            contextPath
                + "/publico/executionCourse.do\\?(executionCourseID=[0-9]+|&amp;|method=bibliographicReference)+",
            "bibliography.html"));
    globalRules.add(
        new SimpleTransformRule(
            contextPath
                + "/publico/executionCourse.do\\?(executionCourseID=[0-9]+|&amp;|method=schedule)+",
            scheduleName));
    globalRules.add(
        new SimpleTransformRule(
            contextPath
                + "/publico/executionCourse.do\\?(executionCourseID=[0-9]+|&amp;|method=shifts)+",
            shiftsName));
    globalRules.add(
        new SimpleTransformRule(
            contextPath
                + "/publico/executionCourse.do\\?(executionCourseID=[0-9]+|&amp;|method=groupings)+",
            groupingsName));
    globalRules.add(
        new SimpleTransformRule(
            contextPath
                + "/publico/executionCourse.do\\?(executionCourseID=[0-9]+|&amp;|method=evaluations)+",
            evaluationName));
    globalRules.add(
        new SimpleTransformRule(
            contextPath
                + "/publico/searchScormContent.do\\?(executionCourseID=[0-9]+|&amp;|method=prepareSearchForExecutionCourse)+",
            "#"));
    globalRules.add(
        new SimpleTransformRule(
            contextPath + "/publico/executionCourse.do\\?.*?sectionID=([0-9]+).*",
            "section-$1.html"));
    globalRules.add(
        new SimpleTransformRule(
            contextPath + "/publico/executionCourse.do\\?.*?method=rss.*", "#"));

    Resource resource =
        new Resource(
            "index.html",
            "/publico/executionCourse.do?method=firstPage&executionCourseID="
                + executionCourse.getExternalId());
    resource.addAllRules(globalRules);
    resource.addRule(
        new SimpleTransformRule(
            contextPath + "/publico/announcementManagement.do\\?.*?announcementId=([0-9]+).*",
            announcementsName.equals("#") ? "#" : announcementsName + "#ID_$1"));
    fetcher.queue(resource);

    if (options.isAnnouncements()) {
      resource =
          new Resource(
              "announcements.html",
              "/publico/announcementManagement.do?method=start&ommitArchive=true&executionCourseID="
                  + executionCourse.getExternalId());
      resource.addAllRules(globalRules);
      resource.addRule(
          new SimpleTransformRule(
              contextPath + "/publico/announcementManagement.do.*?announcementId=([0-9]+).*",
              "announcements.html#ID_$1"));
      resource.addRule(
          new SimpleTransformRule(
              contextPath + "/publico/announcementManagement.do.*?announcementBoardId=([0-9]+).*",
              "#"));
      fetcher.queue(resource);
    }

    if (options.isPlanning()) {
      resource =
          new Resource(
              "planning.html",
              "/publico/executionCourse.do?method=lessonPlannings&executionCourseID="
                  + executionCourse.getExternalId());
      resource.addAllRules(globalRules);
      fetcher.queue(resource);
    }

    resource =
        new Resource(
            "summaries.html",
            "/publico/executionCourse.do?method=summaries&ommitFilter=true&executionCourseID="
                + executionCourse.getExternalId());
    resource.addAllRules(globalRules);
    fetcher.queue(resource);

    resource =
        new Resource(
            "objectives.html",
            "/publico/executionCourse.do?method=objectives&executionCourseID="
                + executionCourse.getExternalId());
    resource.addAllRules(globalRules);
    fetcher.queue(resource);

    resource =
        new Resource(
            "program.html",
            "/publico/executionCourse.do?method=program&executionCourseID="
                + executionCourse.getExternalId());
    resource.addAllRules(globalRules);
    fetcher.queue(resource);

    resource =
        new Resource(
            "evaluation-method.html",
            "/publico/executionCourse.do?method=evaluationMethod&executionCourseID="
                + executionCourse.getExternalId());
    resource.addAllRules(globalRules);
    fetcher.queue(resource);

    resource =
        new Resource(
            "bibliography.html",
            "/publico/executionCourse.do?method=bibliographicReference&executionCourseID="
                + executionCourse.getExternalId());
    resource.addAllRules(globalRules);
    fetcher.queue(resource);

    if (options.isSchedule()) {
      resource =
          new Resource(
              "schedule.html",
              "/publico/executionCourse.do?method=schedule&executionCourseID="
                  + executionCourse.getExternalId());
      resource.addAllRules(globalRules);
      resource.addRule(
          new SimpleTransformRule("(" + contextPath + "/publico/)?siteViewer.do.*", "#"));
      fetcher.queue(resource);
    }

    if (options.isShifts()) {
      resource =
          new Resource(
              "shifts.html",
              "/publico/executionCourse.do?method=shifts&executionCourseID="
                  + executionCourse.getExternalId());
      resource.addAllRules(globalRules);
      resource.addRule(
          new SimpleTransformRule("(" + contextPath + "/publico/)?siteViewer.do.*", "#"));
      resource.addRule(
          new SimpleTransformRule(
              "("
                  + contextPath
                  + "/publico/)?viewClassTimeTableWithClassNameAndDegreeInitialsAction.do.*",
              "#"));
      fetcher.queue(resource);
    }

    if (options.isGroupings()) {
      resource =
          new Resource(
              "groupings.html",
              "/publico/executionCourse.do?method=groupings&executionCourseID="
                  + executionCourse.getExternalId());
      resource.addAllRules(globalRules);
      ResourceRule groupRule =
          new ResourceRule(
              contextPath + "/publico/executionCourse.do\\?method=grouping.*?groupingID=([0-9]+).*",
              "group-$1.html");
      groupRule.addAllRules(globalRules);
      resource.addRule(groupRule);
      fetcher.queue(resource);
    }

    if (options.isEvaluations()) {
      resource =
          new Resource(
              "evaluation.html",
              "/publico/executionCourse.do?method=evaluations&executionCourseID="
                  + executionCourse.getExternalId());
      resource.addAllRules(globalRules);
      ResourceRule marksRule =
          new ResourceRule(
              contextPath + "/publico/executionCourse.do\\?.*method=marks.*", "marks.html");
      marksRule.addAllRules(globalRules);
      resource.addRule(marksRule);
      fetcher.queue(resource);
    }

    for (Section section : executionCourse.getSite().getAssociatedSections()) {
      String name = String.format("section-%s.html", section.getExternalId());
      String url =
          String.format(
              "/publico/executionCourse.do?method=section&executionCourseID=%s&sectionID=%s",
              executionCourse.getExternalId(), section.getExternalId());
      resource = new Resource(name, url);
      resource.addAllRules(globalRules);

      if (options.isFiles()) {
        ResourceRule fileRule =
            new ResourceRule(".*?/bitstream/([0-9]+/[0-9]+/[0-9]+)/(.*)", "files/$2");
        resource.addRule(fileRule);
      }

      fetcher.queue(resource);
    }
  }
Example #25
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, ", ");
  }
Example #26
0
 public InfoExecutionPeriod run(Integer executionCourseCode) throws FenixServiceException {
   ExecutionCourse executionCourse =
       rootDomainObject.readExecutionCourseByOID(executionCourseCode);
   ExecutionSemester executionSemester = executionCourse.getExecutionPeriod();
   return InfoExecutionPeriod.newInfoFromDomain(executionSemester);
 }
Example #27
0
  protected Set<Teacher> getTeachers(List<ExecutionSemester> executionSemesters) {
    Set<Teacher> teachers = new HashSet<Teacher>();
    ExecutionYear previousExecutionYear =
        executionSemester.getExecutionYear().getPreviousExecutionYear();
    for (final DegreeCurricularPlan degreeCurricularPlan : degree.getDegreeCurricularPlansSet()) {
      for (final CurricularCourse course : degreeCurricularPlan.getCurricularCourses()) {
        for (final ExecutionCourse executionCourse : course.getAssociatedExecutionCourses()) {
          if (executionSemesters.contains(executionCourse.getExecutionPeriod())) {
            for (Professorship professorhip : executionCourse.getProfessorshipsSet()) {
              if (professorhip
                  .getPerson()
                  .getTeacher()
                  .isActiveOrHasAuthorizationForSemester(executionCourse.getExecutionPeriod())) {
                teachers.add(professorhip.getPerson().getTeacher());
              }
            }
          }
          if (previousExecutionYear.equals(
              executionCourse.getExecutionPeriod().getExecutionYear())) {
            if (executionCourse.isDissertation()) {
              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());
                    }
                  }
                }
              }
            }
          }
        }
      }
    }

    PhdProgram phdProgram = degree.getPhdProgram();
    if (phdProgram != null) {
      for (PhdIndividualProgramProcess phdIndividualProgramProcess :
          phdProgram.getIndividualProgramProcesses()) {
        for (ExecutionSemester executionSemester : executionSemesters) {
          if (phdIndividualProgramProcess.isActive(
              executionSemester.getAcademicInterval().toInterval())) {
            for (PhdParticipant phdParticipant : phdIndividualProgramProcess.getParticipants()) {
              if (phdParticipant instanceof InternalPhdParticipant) {
                InternalPhdParticipant internalPhdParticipant =
                    (InternalPhdParticipant) phdParticipant;
                if (internalPhdParticipant.isGuidingOrAssistantGuiding()
                    && internalPhdParticipant.getPerson().getTeacher() != null
                    && internalPhdParticipant
                        .getPerson()
                        .getTeacher()
                        .isActiveOrHasAuthorizationForSemester(executionSemester)) {
                  teachers.add(internalPhdParticipant.getPerson().getTeacher());
                }
              }
            }
          }
        }
      }
    }
    return teachers;
  }