/* 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);
  }
Exemple #2
0
 /**
  * returns false if input values are %'s or blanks
  *
  * @param firstName
  * @param middleName
  * @param lastName
  * @return boolean
  */
 private boolean isDataValid(String firstName, String middleName, String lastName) {
   if ((StringUtils.isBlank(firstName) || firstName.matches("%+"))
       && (StringUtils.isBlank(middleName) || middleName.matches("%+"))
       && (StringUtils.isBlank(lastName) || lastName.matches("%+"))) {
     return false;
   }
   return true;
 }