示例#1
0
  /**
   * Send confirmation e-mail ({@link Message}) to the faculty who created this alert.
   *
   * @param earlyAlert Early Alert
   * @throws ObjectNotFoundException
   * @throws SendFailedException
   * @throws ValidationException
   */
  private void sendConfirmationMessageToFaculty(final EarlyAlert earlyAlert)
      throws ObjectNotFoundException, SendFailedException, ValidationException {
    if (earlyAlert == null) {
      throw new IllegalArgumentException("EarlyAlert was missing.");
    }

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

    final Person person = earlyAlert.getCreatedBy();
    if (person == null) {
      LOGGER.warn(
          "EarlyAlert {} has no creator. Unable to send" + " confirmation message to faculty.",
          earlyAlert);
    } else {
      final SubjectAndBody subjAndBody =
          messageTemplateService.createEarlyAlertFacultyConfirmationMessage(
              fillTemplateParameters(earlyAlert));

      // Create and queue the message
      final Message message = messageService.createMessage(person, null, subjAndBody);

      LOGGER.info("Message {} created for EarlyAlert {}", message, earlyAlert);
    }
  }
示例#2
0
  /**
   * 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
  @Override
  public void sendMessageToStudent(@NotNull final EarlyAlert earlyAlert)
      throws ObjectNotFoundException, SendFailedException, ValidationException {
    if (earlyAlert == null) {
      throw new IllegalArgumentException("EarlyAlert was missing.");
    }

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

    final Person person = earlyAlert.getPerson();
    final SubjectAndBody subjAndBody =
        messageTemplateService.createEarlyAlertToStudentMessage(fillTemplateParameters(earlyAlert));

    // Create and queue the message
    final Message message = messageService.createMessage(person, null, subjAndBody);

    LOGGER.info("Message {} created for EarlyAlert {}", message, earlyAlert);
  }
示例#4
0
  /**
   * Send e-mail ({@link Message}) to the assigned advisor for the student.
   *
   * @param earlyAlert Early Alert
   * @param emailCC Email address to also CC this message
   * @throws ObjectNotFoundException
   * @throws SendFailedException
   * @throws ValidationException
   */
  private void sendMessageToAdvisor(
      @NotNull final EarlyAlert earlyAlert, // NOPMD
      final String emailCC)
      throws ObjectNotFoundException, SendFailedException, ValidationException {
    if (earlyAlert == null) {
      throw new IllegalArgumentException("Early alert was missing.");
    }

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

    final Person person = earlyAlert.getPerson().getCoach();
    final SubjectAndBody subjAndBody =
        messageTemplateService.createEarlyAlertAdvisorConfirmationMessage(
            fillTemplateParameters(earlyAlert));

    if (person == null) {
      LOGGER.warn(
          "Student {} had no coach when EarlyAlert {} was"
              + " created. Unable to send message to coach.",
          earlyAlert.getPerson(),
          earlyAlert);
    } else {
      // Create and queue the message
      final Message message = messageService.createMessage(person, emailCC, subjAndBody);
      LOGGER.info("Message {} created for EarlyAlert {}", message, earlyAlert);
    }

    // Send same message to all applicable Campus Early Alert routing
    // entries
    final PagingWrapper<EarlyAlertRouting> routes =
        earlyAlertRoutingService.getAllForCampus(
            earlyAlert.getCampus(), new SortingAndPaging(ObjectStatus.ACTIVE));
    if (routes.getResults() > 0) {
      for (final EarlyAlertRouting route : routes.getRows()) {
        // Check that route applies
        if (route.getEarlyAlertReason() == null) {
          throw new ObjectNotFoundException(
              "EarlyAlertRouting missing EarlyAlertReason.", "EarlyAlertReason");
        }

        // Only routes that are for any of the Reasons in this
        // EarlyAlert should be applied.
        if ((earlyAlert.getEarlyAlertReasonIds() == null)
            || !earlyAlert.getEarlyAlertReasonIds().contains(route.getEarlyAlertReason())) {
          continue;
        }

        // Send e-mail to specific person
        final Person to = route.getPerson();
        if ((to != null) && !StringUtils.isEmpty(to.getPrimaryEmailAddress())) {
          final Message message = messageService.createMessage(to, null, subjAndBody);
          LOGGER.info(
              "Message {} for EarlyAlert {} also routed to {}",
              new Object[] {message, earlyAlert, to}); // NOPMD
        }

        // Send e-mail to a group
        if (!StringUtils.isEmpty(route.getGroupName())
            && !StringUtils.isEmpty(route.getGroupEmail())) {
          final Message message =
              messageService.createMessage(route.getGroupEmail(), null, subjAndBody);
          LOGGER.info(
              "Message {} for EarlyAlert {} also routed to {}",
              new Object[] {
                message,
                earlyAlert, // NOPMD
                route.getGroupEmail()
              });
        }
      }
    }
  }