/** get the traveler profile associated with the given travel document */
 protected TemProfile getTravelProfile(TravelDocument travelDocument) {
   Integer travelProfileId = travelDocument.getProfileId();
   if (travelProfileId != null) {
     return this.getBusinessObjectService()
         .findBySinglePrimaryKey(TemProfile.class, travelProfileId);
   }
   return null;
 }
  /** build mail message object from the given travel document */
  @SuppressWarnings("null")
  protected MailMessage buildDocumentStatusChangeMailMessage(
      TravelDocument travelDocument,
      DocumentRouteStatusChange statusChangeDTO,
      NotificationPreference preference) {
    MailMessage mailMessage = new MailMessage();

    String senderEmailAddress = this.getNotificationSender();
    mailMessage.setFromAddress(senderEmailAddress);

    TravelerDetail traveler = travelDocument.getTraveler();
    String travelerEmailAddress = null;
    if (!ObjectUtils.isNull(traveler) && !ObjectUtils.isNull(travelDocument.getProfileId())) {
      TemProfile profile =
          SpringContext.getBean(TemProfileService.class)
              .findTemProfileById(travelDocument.getProfileId());
      travelerEmailAddress = profile.getEmailAddress();
    } else {
      travelerEmailAddress = traveler.getEmailAddress();
    }

    if (senderEmailAddress != null && travelerEmailAddress != null) {
      mailMessage.addToAddress(travelerEmailAddress);

      String notificationSubject = this.getNotificationSubject(preference);
      mailMessage.setSubject(notificationSubject);

      String notificationBody =
          this.buildNotificationBody(travelDocument, statusChangeDTO, preference);
      mailMessage.setMessage(notificationBody);

      return mailMessage;
    }

    return null;
  }