@RequestMapping(value = "/transcript/currentcourses", method = RequestMethod.GET)
  @PreAuthorize(Permission.SECURITY_PERSON_READ)
  public @ResponseBody List<ExternalStudentTranscriptCourseTO> loadCurrentCourses(
      final @PathVariable UUID id) throws ObjectNotFoundException {
    String schoolId = getStudentId(id);

    Term currentTerm;
    try {
      currentTerm = termService.getCurrentTerm();
    } catch (ObjectNotFoundException e) {
      currentTerm = new Term();
      LOGGER.error(
          "CURRENT TERM NOT SET, org.jasig.ssp.web.api.external.ExternalStudentRecordsController.loadCurrentCourses(UUID) is being called but will not function properly");
    }
    List<ExternalStudentTranscriptCourseTO> courses =
        externalStudentTranscriptCourseFactory.asTOList(
            externalStudentTranscriptCourseService.getTranscriptsBySchoolIdAndTermCode(
                schoolId, currentTerm.getCode()));
    Collection<EnrollmentStatus> mappings = statusCodeMappings();

    String defaultStatusCode = getDefaultStatusCode(mappings);

    for (ExternalStudentTranscriptCourseTO course : courses) {
      try {
        Person person =
            !StringUtils.isNotBlank(course.getFacultySchoolId())
                ? null
                : personService.getInternalOrExternalPersonBySchoolId(
                    course.getFacultySchoolId(),
                    false); // TODO: getInternalOrExternalPersonBySchoolId is slow refactor?
        if (person != null) {
          course.setFacultyName(person.getFullName());
        }
      } catch (ObjectNotFoundException e) {
        course.setFacultyName("None Listed");
        LOGGER.debug(
            "FACULTY SCHOOL ID WAS NOT RESOLVED WHILE LOADING TRANSCRIPT RECORD.  Factulty School_id: "
                + course.getFacultySchoolId()
                + " Student ID: "
                + course.getSchoolId()
                + " Course: "
                + course.getFormattedCourse());
      }

      if (StringUtils.isBlank(course.getStatusCode())) {
        course.setStatusCode(defaultStatusCode);
      } else if (mappings != null && !mappings.isEmpty()) {
        for (EnrollmentStatus enrollmentStatus : mappings) {
          if (enrollmentStatus.getCode().equals(course.getStatusCode())) {
            course.setStatusCode(enrollmentStatus.getName());
          }
        }
      }
    }
    return courses;
  }
Esempio n. 2
0
 static void addTermsToMap(final List<Term> terms, final Map<String, Object> parameters)
     throws ObjectNotFoundException {
   final List<String> termCodes = new ArrayList<String>();
   final List<String> termNames = new ArrayList<String>();
   if (terms == null || terms.isEmpty()) {
     parameters.put(TERM_CODES, NOT_USED);
     parameters.put(TERM_NAMES, NOT_USED);
     return;
   }
   for (Term term : terms) {
     if (term == null) continue;
     termCodes.add(term.getCode());
     termNames.add(term.getName());
   }
   parameters.put(TERM_CODES, concatNamesFromStrings(termCodes, NOT_USED));
   parameters.put(TERM_NAMES, concatNamesFromStrings(termNames, NOT_USED));
 }
  @RequestMapping(method = RequestMethod.GET)
  @PreAuthorize(Permission.SECURITY_REPORT_READ)
  public @ResponseBody void getEarlyAlertCaseCountsReport(
      final HttpServletResponse response,
      final @RequestParam(required = false) UUID campusId,
      final @RequestParam(required = false) String rosterStatus,
      final @RequestParam(required = false) List<String> termCodes,
      final @RequestParam(required = false, defaultValue = DEFAULT_REPORT_TYPE) String reportType)
      throws ObjectNotFoundException, IOException {

    Campus campus = SearchParameters.getCampus(campusId, campusService);

    final List<EarlyAlertTermCaseCountsTO> caseLoads = new ArrayList<EarlyAlertTermCaseCountsTO>();
    final List<String> cleanTermCodes = SearchParameters.cleanStringListOfNulls(termCodes);
    final List<Term> terms = SearchParameters.getTerms(cleanTermCodes, termService);
    if (terms.size() > 0) {
      for (Term term : terms) {
        EarlyAlertTermCaseCountsTO caseCounts =
            new EarlyAlertTermCaseCountsTO(
                term.getCode(),
                term.getName(),
                earlyAlertService.getStudentCountForEarlyAlertCreatedDateRange(
                    term.getStartDate(), term.getEndDate(), campus, rosterStatus),
                earlyAlertService.getEarlyAlertCountForCreatedDateRange(
                    term.getStartDate(), term.getEndDate(), campus, rosterStatus),
                earlyAlertResponseService
                    .getRespondedToEarlyAlertCountForEarlyAlertCreatedDateRange(
                        term.getStartDate(), term.getEndDate(), campus, rosterStatus),
                earlyAlertService.getClosedEarlyAlertsCountForEarlyAlertCreatedDateRange(
                    term.getStartDate(), term.getEndDate(), campus, rosterStatus));

        caseLoads.add(caseCounts);
      }

    } else {

      EarlyAlertTermCaseCountsTO caseCounts =
          new EarlyAlertTermCaseCountsTO(
              "All",
              "All",
              earlyAlertService.getStudentCountForEarlyAlertCreatedDateRange(
                  null, null, campus, rosterStatus),
              earlyAlertService.getEarlyAlertCountForCreatedDateRange(
                  null, null, campus, rosterStatus),
              earlyAlertResponseService.getRespondedToEarlyAlertCountForEarlyAlertCreatedDateRange(
                  null, null, campus, rosterStatus),
              earlyAlertService.getClosedEarlyAlertsCountForEarlyAlertCreatedDateRange(
                  null, null, campus, rosterStatus));
      caseLoads.add(caseCounts);
    }

    final Map<String, Object> parameters = Maps.newHashMap();
    SearchParameters.addCampusToParameters(campus, parameters);

    SearchParameters.addTermsToMap(terms, parameters);
    renderReport(
        response,
        parameters,
        caseLoads,
        reportType.equals("csv") ? REPORT_URL_CSV : REPORT_URL,
        reportType,
        REPORT_FILE_TITLE);
  }