コード例 #1
0
ファイル: SearchParameters.java プロジェクト: ajinkyas/SSP
  static List<Person> getCoaches(
      final UUID coachId, String homeDepartment, PersonService personService)
      throws ObjectNotFoundException {
    List<Person> coaches;
    if (coachId != null) {
      Person coach = personService.get(coachId);
      coaches = new ArrayList<Person>();
      coaches.add(coach);
    } else {
      coaches =
          new ArrayList<Person>(
              personService.getAllCurrentCoaches(Person.PERSON_NAME_AND_ID_COMPARATOR));

      if (homeDepartment != null && homeDepartment.length() > 0) {
        List<Person> homeCoaches = new ArrayList<Person>();
        for (Person coach : coaches) {
          if (coach.getStaffDetails() != null
              && coach.getStaffDetails().getDepartmentName() != null
              && coach.getStaffDetails().getDepartmentName().equals(homeDepartment))
            homeCoaches.add(coach);
        }
        coaches = homeCoaches;
      }
    }

    return coaches;
  }
コード例 #2
0
ファイル: PlanController.java プロジェクト: maestrocorona/SSP
  /**
   * Returns an html page valid for printing
   *
   * <p>
   *
   * @param obj instance to print.
   * @return html text strem
   * @throws ObjectNotFoundException If specified object could not be found.
   * @throws SendFailedException
   */
  @PreAuthorize("hasRole('ROLE_PERSON_READ') or hasRole('ROLE_PERSON_MAP_READ')")
  @RequestMapping(value = "/emailCurrent", method = RequestMethod.POST)
  public @ResponseBody String email(
      final HttpServletResponse response,
      final @PathVariable UUID personId,
      @RequestBody final PlanOutputTO planOutputDataTO)
      throws ObjectNotFoundException {

    Plan currentPlan = service.getCurrentForStudent(personId);
    PlanTO planTO = getFactory().from(currentPlan);
    planOutputDataTO.setPlan(planTO);

    SubjectAndBody messageText = service.createOutput(planOutputDataTO);
    if (messageText == null) return null;
    Person person = personService.get(UUID.fromString(planOutputDataTO.getPlan().getPersonId()));
    Set<String> watcherAddresses = new HashSet<String>(person.getWatcherEmailAddresses());
    watcherAddresses.addAll(
        org.springframework.util.StringUtils.commaDelimitedListToSet(
            planOutputDataTO.getEmailCC()));

    messageService.createMessage(
        planOutputDataTO.getEmailTo(),
        org.springframework.util.StringUtils.arrayToCommaDelimitedString(
            watcherAddresses.toArray(new String[watcherAddresses.size()])),
        messageText);

    return "Map Plan has been queued.";
  }
コード例 #3
0
ファイル: SearchParameters.java プロジェクト: ajinkyas/SSP
 static final PersonTO getPerson(
     final UUID personId, PersonService personService, PersonTOFactory personTOFactory)
     throws ObjectNotFoundException {
   if (personId != null) {
     return personTOFactory.from(personService.get(personId));
   }
   return null;
 }
コード例 #4
0
ファイル: PlanController.java プロジェクト: maestrocorona/SSP
 private PlanTO validatePlan(PlanTO plan) throws ObjectNotFoundException {
   String schoolId = null;
   if (StringUtils.isNotBlank(plan.getPersonId())) {
     Person student = personService.get(UUID.fromString(plan.getPersonId()));
     schoolId = student.getSchoolId();
   }
   return getService().validate(plan);
 }
コード例 #5
0
  /**
   * Load the specified Person.
   *
   * <p>Be careful when walking the tree to avoid performance issues that can arise if eager
   * fetching from the database layer is not used appropriately.
   */
  @Override
  public AccommodationForm loadForPerson(final UUID studentId) throws ObjectNotFoundException {
    final AccommodationForm form = new AccommodationForm();

    final Person person = personService.get(studentId);
    form.setPerson(person);

    return form;
  }
コード例 #6
0
 /**
  * Using the Student UUID passed, return the ExternalStudentRecordsLiteTO in its current state,
  * creating it if necessary.
  *
  * @param id Student identifier Any errors will throw this generic exception.
  * @return Service response with success value, in the JSON format.
  * @throws ObjectNotFoundException, IOException If any reference data could not be loaded.
  */
 @RequestMapping(value = "/test/details", method = RequestMethod.GET)
 @PreAuthorize(Permission.SECURITY_PERSON_READ)
 public String getTestProviderDetails(
     final @PathVariable UUID id,
     final @RequestParam(required = true) String testCode,
     final @RequestParam(required = false) String subTestCode,
     HttpServletResponse httpServletResponse)
     throws ObjectNotFoundException, IOException {
   Person person = personService.get(id);
   String url = (String) externalStudentTestService.getTestDetails(testCode, subTestCode, person);
   return "redirect:" + url;
 }
コード例 #7
0
  @Override
  public EarlyAlert create(@NotNull final EarlyAlert earlyAlert)
      throws ObjectNotFoundException, ValidationException {
    // Validate objects
    if (earlyAlert == null) {
      throw new IllegalArgumentException("EarlyAlert must be provided.");
    }

    if (earlyAlert.getPerson() == null) {
      throw new ValidationException("EarlyAlert Student data must be provided.");
    }

    final Person student = earlyAlert.getPerson();

    // Figure student advisor or early alert coordinator
    final UUID assignedAdvisor = getEarlyAlertAdvisor(earlyAlert);
    if (assignedAdvisor == null) {
      throw new ValidationException(
          "Could not determine the Early Alert Advisor for student ID " + student.getId());
    }

    if (student.getCoach() == null || assignedAdvisor.equals(student.getCoach().getId())) {
      student.setCoach(personService.get(assignedAdvisor));
    }

    ensureValidAlertedOnPersonStateNoFail(student);

    // Create alert
    final EarlyAlert saved = getDao().save(earlyAlert);

    // Send e-mail to assigned advisor (coach)
    try {
      sendMessageToAdvisor(saved, earlyAlert.getEmailCC());
    } catch (final SendFailedException e) {
      LOGGER.warn("Could not send Early Alert message to advisor.", e);
      throw new ValidationException(
          "Early Alert notification e-mail could not be sent to advisor. Early Alert was NOT created.",
          e);
    }

    // Send e-mail CONFIRMATION to faculty
    try {
      sendConfirmationMessageToFaculty(saved);
    } catch (final SendFailedException e) {
      LOGGER.warn("Could not send Early Alert confirmation to faculty.", e);
      throw new ValidationException(
          "Early Alert confirmation e-mail could not be sent. Early Alert was NOT created.", e);
    }

    return saved;
  }
コード例 #8
0
  @Override
  public EarlyAlert save(@NotNull final EarlyAlert obj) throws ObjectNotFoundException {
    final EarlyAlert current = getDao().get(obj.getId());

    current.setCourseName(obj.getCourseName());
    current.setCourseTitle(obj.getCourseTitle());
    current.setEmailCC(obj.getEmailCC());
    current.setCampus(obj.getCampus());
    current.setEarlyAlertReasonOtherDescription(obj.getEarlyAlertReasonOtherDescription());
    current.setComment(obj.getComment());
    current.setClosedDate(obj.getClosedDate());
    current.setClosedById(obj.getClosedById());

    if (obj.getPerson() == null) {
      current.setPerson(null);
    } else {
      current.setPerson(personService.get(obj.getPerson().getId()));
    }

    final Set<EarlyAlertReason> earlyAlertReasons = new HashSet<EarlyAlertReason>();
    if (obj.getEarlyAlertReasonIds() != null) {
      for (final EarlyAlertReason reason : obj.getEarlyAlertReasonIds()) {
        earlyAlertReasons.add(earlyAlertReasonService.load(reason.getId()));
      }
    }

    current.setEarlyAlertReasonIds(earlyAlertReasons);

    final Set<EarlyAlertSuggestion> earlyAlertSuggestions = new HashSet<EarlyAlertSuggestion>();
    if (obj.getEarlyAlertSuggestionIds() != null) {
      for (final EarlyAlertSuggestion reason : obj.getEarlyAlertSuggestionIds()) {
        earlyAlertSuggestions.add(earlyAlertSuggestionService.load(reason.getId()));
      }
    }

    current.setEarlyAlertSuggestionIds(earlyAlertSuggestions);

    return getDao().save(current);
  }
コード例 #9
0
ファイル: PlanController.java プロジェクト: maestrocorona/SSP
 /**
  * Return plan status for given student.
  *
  * @param personId Explicit personId to the instance to persist.
  * @return The current plan status of the student.
  */
 @DynamicPermissionChecking
 @RequestMapping(value = "/planstatus", method = RequestMethod.GET)
 public @ResponseBody ExternalPersonPlanStatusTO getPlanStatus(
     final HttpServletRequest request,
     final HttpServletResponse response,
     @PathVariable final UUID personId)
     throws ObjectNotFoundException {
   assertStandardMapReadApiAuthorization(request);
   if (personId == null) {
     return null;
   }
   String schoolId = null;
   Person student = personService.get(personId);
   schoolId = student.getSchoolId();
   // TODO not the cleanest way to handle but clientside generates 500 error in console
   // Currently plan status is not required.
   try {
     return planStatusFactory.from(externalPlanStatusService.getBySchoolId(schoolId));
   } catch (Exception exp) {
     return null;
   }
 }
コード例 #10
0
  @RequestMapping(value = "/studentactivity", method = RequestMethod.GET)
  @PreAuthorize(Permission.SECURITY_PERSON_READ)
  public @ResponseBody List<RecentActivityTO> loadRecentStudentActivity(final @PathVariable UUID id)
      throws ObjectNotFoundException {
    List<RecentActivityTO> recentActivities = new ArrayList<RecentActivityTO>();
    Person person = personService.get(id);
    SortingAndPaging sAndP =
        SortingAndPaging.createForSingleSortWithPaging(
            ObjectStatus.ACTIVE, 0, 1000, "createdDate", "DESC", "createdDate");

    PagingWrapper<EarlyAlert> earlyAlerts = earlyAlertService.getAllForPerson(person, sAndP);
    SspUser currentUser = securityService.currentUser();
    List<EarlyAlertTO> earlyAlertTOs = earlyAlertTOFactory.asTOList(earlyAlerts.getRows());

    PagingWrapper<JournalEntry> journalEntries =
        journalEntryService.getAllForPerson(person, currentUser, sAndP);

    List<JournalEntryTO> journalEntriesTOs =
        journalEntryTOFactory.asTOList(journalEntries.getRows());

    PagingWrapper<Task> actions = taskService.getAllForPerson(person, currentUser, sAndP);

    List<TaskTO> actionsTOs = taskTOFactory.asTOList(actions.getRows());

    PagingWrapper<Plan> plans =
        planService.getAllForStudent(
            SortingAndPaging.createForSingleSortWithPaging(
                ObjectStatus.ALL, 0, 1000, null, null, null),
            id);

    List<PlanTO> planTOs = planTOFactory.asTOList(plans.getRows());

    for (EarlyAlertTO earlyAlert : earlyAlertTOs) {
      if (earlyAlert.getClosedDate() != null) {
        recentActivities.add(
            new RecentActivityTO(
                earlyAlert.getClosedById(),
                earlyAlert.getClosedByName(),
                "Early Alert Closed",
                earlyAlert.getClosedDate()));
      } else {
        recentActivities.add(
            new RecentActivityTO(
                earlyAlert.getCreatedBy().getId(),
                getPersonLiteName(earlyAlert.getCreatedBy()),
                "Early Alert Created",
                earlyAlert.getCreatedDate()));
      }
    }

    for (JournalEntryTO journalEntry : journalEntriesTOs) {
      recentActivities.add(
          new RecentActivityTO(
              journalEntry.getCreatedBy().getId(),
              getPersonLiteName(journalEntry.getCreatedBy()),
              "Journal Entry",
              journalEntry.getEntryDate()));
    }

    for (TaskTO action : actionsTOs) {
      if (action.isCompleted()) {
        recentActivities.add(
            new RecentActivityTO(
                action.getModifiedBy().getId(),
                getPersonLiteName(action.getModifiedBy()),
                "Action Plan Task Created",
                action.getCompletedDate()));
      } else {
        recentActivities.add(
            new RecentActivityTO(
                action.getCreatedBy().getId(),
                getPersonLiteName(action.getCreatedBy()),
                "Action Plan Task Created",
                action.getCreatedDate()));
      }
    }

    for (PlanTO planTO : planTOs) {
      Date testDate = DateUtils.addDays(planTO.getCreatedDate(), 1);
      String planName = planTO.getName();
      if (planTO.getModifiedDate().before(testDate)) {
        recentActivities.add(
            new RecentActivityTO(
                planTO.getCreatedBy().getId(),
                getPersonLiteName(planTO.getCreatedBy()),
                "Map Plan (" + planName + ") Created",
                planTO.getModifiedDate()));
      } else {
        recentActivities.add(
            new RecentActivityTO(
                planTO.getModifiedBy().getId(),
                getPersonLiteName(planTO.getModifiedBy()),
                "Map Plan (" + planName + ") Updated",
                planTO.getModifiedDate()));
      }
    }

    if (person.getStudentIntakeCompleteDate() != null) {
      recentActivities.add(
          new RecentActivityTO(
              person.getCoach().getId(),
              person.getCoach().getFullName(),
              "Student Intake Completed",
              person.getStudentIntakeCompleteDate()));
    }
    if (person.getStudentIntakeRequestDate() != null) {
      recentActivities.add(
          new RecentActivityTO(
              person.getCoach().getId(),
              person.getCoach().getFullName(),
              "Student Intake Requested",
              person.getStudentIntakeRequestDate()));
    }

    Collections.sort(recentActivities, RecentActivityTO.RECENT_ACTIVITY_TO_DATE_COMPARATOR);
    return recentActivities;
  }
コード例 #11
0
  @Override
  public Map<String, Object> fillTemplateParameters(@NotNull final EarlyAlert earlyAlert) {
    if (earlyAlert == null) {
      throw new IllegalArgumentException("EarlyAlert was missing.");
    }

    if (earlyAlert.getPerson() == null) {
      throw new IllegalArgumentException("EarlyAlert.Person is missing.");
    }

    if (earlyAlert.getCreatedBy() == null) {
      throw new IllegalArgumentException("EarlyAlert.CreatedBy is missing.");
    }

    if (earlyAlert.getCampus() == null) {
      throw new IllegalArgumentException("EarlyAlert.Campus is missing.");
    }

    // ensure earlyAlert.createdBy is populated
    if ((earlyAlert.getCreatedBy().getFirstName() == null)
        || (earlyAlert.getCreatedBy().getLastName() == null)) {
      if (earlyAlert.getCreatedBy().getId() == null) {
        throw new IllegalArgumentException("EarlyAlert.CreatedBy.Id is missing.");
      }

      try {
        earlyAlert.setCreatedBy(personService.get(earlyAlert.getCreatedBy().getId()));
      } catch (final ObjectNotFoundException e) {
        throw new IllegalArgumentException("EarlyAlert.CreatedBy.Id could not be loaded.", e);
      }
    }

    final Map<String, Object> templateParameters = Maps.newHashMap();

    final String courseName = earlyAlert.getCourseName();
    if (StringUtils.isNotBlank(courseName)) {
      final String facultySchoolId = earlyAlert.getCreatedBy().getSchoolId();
      if ((StringUtils.isNotBlank(facultySchoolId))) {
        String termCode = earlyAlert.getCourseTermCode();
        FacultyCourse course = null;
        try {
          if (StringUtils.isBlank(termCode)) {
            course =
                facultyCourseService.getCourseByFacultySchoolIdAndFormattedCourse(
                    facultySchoolId, courseName);
          } else {
            course =
                facultyCourseService.getCourseByFacultySchoolIdAndFormattedCourseAndTermCode(
                    facultySchoolId, courseName, termCode);
          }
        } catch (ObjectNotFoundException e) {
          // Trace irrelevant. see below for logging. prefer to
          // do it there, after the null check b/c not all service
          // methods implement ObjectNotFoundException reliably.
        }
        if (course != null) {
          templateParameters.put("course", course);
          if (StringUtils.isBlank(termCode)) {
            termCode = course.getTermCode();
          }
          if (StringUtils.isNotBlank(termCode)) {
            Term term = null;
            try {
              term = termService.getByCode(termCode);
            } catch (ObjectNotFoundException e) {
              // Trace irrelevant. See below for logging.
            }
            if (term != null) {
              templateParameters.put("term", term);
            } else {
              LOGGER.info(
                  "Not adding term to message template"
                      + " params or early alert {} because"
                      + " the term code {} did not resolve to"
                      + " an external term record",
                  earlyAlert.getId(),
                  termCode);
            }
          }
        } else {
          LOGGER.info(
              "Not adding course nor term to message template"
                  + " params for early alert {} because the associated"
                  + " course {} and faculty school id {} did not"
                  + " resolve to an external course record.",
              new Object[] {earlyAlert.getId(), courseName, facultySchoolId});
        }
      }
    }

    templateParameters.put("earlyAlert", earlyAlert);
    templateParameters.put(
        "termToRepresentEarlyAlert", configService.getByNameEmpty("term_to_represent_early_alert"));
    templateParameters.put("linkToSSP", configService.getByNameEmpty("serverExternalPath"));
    templateParameters.put("applicationTitle", configService.getByNameEmpty("app_title"));
    templateParameters.put("institutionName", configService.getByNameEmpty("inst_name"));

    return templateParameters;
  }