示例#1
0
  /* Called for updating master subjects only. * fires rules to all registrars on whose sites subject is registered */
  private void activateRulesForNewOrUpdatedCorrespondence(Correspondence correspondence) {

    List<Object> objects = new ArrayList<Object>();
    objects.add(correspondence);
    PlannedNotification plannedNotification = getPlannedNotificationsForCorrespondence().get(0);
    plannedNotification.getUserBasedRecipient().clear();
    if (correspondence.getPersonSpokenTo() != null) {
      String email = correspondence.getPersonSpokenTo().getEmail();
      if (!StringUtils.isBlank(email)) {
        UserBasedRecipient ubr = new UserBasedRecipient();
        ubr.setPersonUser(correspondence.getPersonSpokenTo());
        ubr.setEmailAddress(email);
        plannedNotification.getUserBasedRecipient().add(ubr);
      }
    }

    for (PersonUser notifiedPersonUser : correspondence.getNotifiedStudyPersonnel()) {
      String email = notifiedPersonUser.getEmail();
      if (!StringUtils.isBlank(email)) {
        UserBasedRecipient ubr = new UserBasedRecipient();
        ubr.setPersonUser(notifiedPersonUser);
        ubr.setEmailAddress(email);
        plannedNotification.getUserBasedRecipient().add(ubr);
      }
    }

    objects.add(plannedNotification);
    rulesDelegationService.activateRules(
        NotificationEventTypeEnum.CORRESPONDENCE_CREATED_OR_UPDATED_EVENT, objects);
    objects.remove(plannedNotification);
  }