protected void executeInternal()

in ddm-bpm-extension/src/main/java/com/epam/digital/data/platform/bpms/extension/delegate/notification/SendUserNotificationByAddress.java [71:106]


  protected void executeInternal(DelegateExecution execution) throws Exception {
    var notificationChannel = notificationChannelVariable.from(execution).getOrThrow();
    var notificationAddress = notificationAddressVariable.from(execution).getOrThrow();
    if (Channel.EMAIL.name().equals(notificationChannel)) {
      validateEmail(notificationAddress);
    }
    var notificationSubject = notificationSubjectVariable.from(execution).get();
    var notificationTemplate = notificationTemplateVariable.from(execution).get();
    var notificationTemplateModel = (Map<String, Object>) notificationTemplateModelVariable.from(execution)
            .getOrThrow().mapTo(Map.class);
    var notificationMessage = UserNotificationMessageDto.builder()
            .recipients(List.of(Recipient.builder()
                    .channels(List.of(ChannelObject.builder()
                            .email(notificationAddress)
                            .channel(notificationChannel.toLowerCase())
                            .build()))
                    .parameters(notificationTemplateModel)
                    .build()))
            .context(NotificationContextDto.builder()
                    .system("Low-code Platform")
                    .application(springAppName)
                    .businessActivity(execution.getCurrentActivityId())
                    .businessActivityInstanceId(execution.getActivityInstanceId())
                    .businessProcessInstanceId(execution.getProcessInstanceId())
                    .businessProcess(((ExecutionEntity) execution).getProcessDefinition().getKey())
                    .businessProcessDefinitionId(execution.getProcessDefinitionId())
                    .build())
            .notification(UserNotificationDto.builder()
                    .ignoreChannelPreferences(true)
                    .templateName(notificationTemplate)
                    .title(notificationSubject)
                    .build())
            .build();

    notificationFacade.sendNotification(notificationMessage);
  }