Class AbstractTaskMessageSend

java.lang.Object
dev.dsf.bpe.v1.activity.AbstractTaskMessageSend
All Implemented Interfaces:
org.camunda.bpm.engine.delegate.JavaDelegate, org.springframework.beans.factory.InitializingBean

public abstract class AbstractTaskMessageSend extends Object implements org.camunda.bpm.engine.delegate.JavaDelegate, org.springframework.beans.factory.InitializingBean
Base class for implementing BPMN message send tasks, intermediate message throw events and message end events using FHIR Task resources. Requires three String fields to be injected via BPMN:
  • instantiatesCanonical with the URL (including version) of the Activity to start or continue.
  • messageName with the with the BPMN message-name of the start event, intermediate message catch event or message receive task.
  • profile with the URL (including version) of the profile (StructureDefinition) that the Task resource used should conform to.

Configure BPMN message send tasks, intermediate message throw events and message end event with an implementation of type 'Java class' with the fully qualified class name of the class extending this abstract implementation.

Configure your service task implementation as a Bean in your spring Configuration class with scope "prototype".

See Also:
  • Field Details

  • Constructor Details

    • AbstractTaskMessageSend

      public AbstractTaskMessageSend(ProcessPluginApi api)
      Parameters:
      api - not null
  • Method Details

    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Throws:
      Exception
    • setInstantiatesCanonical

      @Deprecated public final void setInstantiatesCanonical(org.camunda.bpm.engine.impl.el.FixedValue instantiatesCanonical)
      Deprecated.
      only for process engine field injection
      Parameters:
      instantiatesCanonical - not null
    • getInstantiatesCanonical

      protected String getInstantiatesCanonical(org.camunda.bpm.engine.delegate.DelegateExecution execution, Variables variables)
      Retrieves the instantiatesCanonical value used for Task resources send by this class via the injected field instantiatesCanonical.

      Override this method to use a different mechanism for retrieving the value for instantiatesCanonical. For example via a process variable. Note: A non empty value e.g 'disable' still needs to be injected in the BPMN file in order to comply with the validation performed during plugin loading.

      Parameters:
      execution - not null
      variables - not null
      Returns:
      instantiatesCanonical value used for Task resources send by this class
    • setMessageName

      @Deprecated public final void setMessageName(org.camunda.bpm.engine.impl.el.FixedValue messageName)
      Deprecated.
      only for process engine field injection
      Parameters:
      messageName - not null
    • getMessageName

      protected String getMessageName(org.camunda.bpm.engine.delegate.DelegateExecution execution, Variables variables)
      Retrieves the messageName value used for Task resources send by this class via the injected field messageName.

      Override this method to use a different mechanism for retrieving the value for messageName. For example via a process variable. Note: A non empty value e.g 'disable' still needs to be injected in the BPMN file in order to comply with the validation performed during plugin loading.

      Parameters:
      execution - not null
      variables - not null
      Returns:
      messageName value used for Task resources send by this class
    • setProfile

      @Deprecated public final void setProfile(org.camunda.bpm.engine.impl.el.FixedValue profile)
      Deprecated.
      only for process engine field injection
      Parameters:
      profile - not null
    • getProfile

      protected String getProfile(org.camunda.bpm.engine.delegate.DelegateExecution execution, Variables variables)
      Retrieves the profile value used for Task resources send by this class via the injected field profile.

      Override this method to use a different mechanism for retrieving the value for profile. For example via a process variable. Note: A non empty value e.g 'disable' still needs to be injected in the BPMN file in order to comply with the validation performed during plugin loading.

      Parameters:
      execution - not null
      variables - not null
      Returns:
      profile value used for Task resources send by this class
    • execute

      public final void execute(org.camunda.bpm.engine.delegate.DelegateExecution execution) throws Exception
      Specified by:
      execute in interface org.camunda.bpm.engine.delegate.JavaDelegate
      Throws:
      Exception
    • doExecute

      protected void doExecute(org.camunda.bpm.engine.delegate.DelegateExecution execution, Variables variables) throws Exception
      Throws:
      Exception
    • handleIntermediateThrowEventError

      protected void handleIntermediateThrowEventError(org.camunda.bpm.engine.delegate.DelegateExecution execution, Variables variables, Exception exception, String errorMessage)
    • handleEndEventError

      protected void handleEndEventError(org.camunda.bpm.engine.delegate.DelegateExecution execution, Variables variables, Exception exception, String errorMessage)
    • handleSendTaskError

      protected void handleSendTaskError(org.camunda.bpm.engine.delegate.DelegateExecution execution, Variables variables, Exception exception, String errorMessage)
    • addErrorMessage

      protected void addErrorMessage(org.hl7.fhir.r4.model.Task task, String errorMessage)
    • getAdditionalInputParameters

      protected Stream<org.hl7.fhir.r4.model.Task.ParameterComponent> getAdditionalInputParameters(org.camunda.bpm.engine.delegate.DelegateExecution execution, Variables variables)
      Override this method to add additional input parameters to the task resource being send.
      Parameters:
      execution - the delegate execution of this process instance
      Returns:
      Stream of Task.ParameterComponents to be added as input parameters
    • createAndSaveAlternativeBusinessKey

      protected final String createAndSaveAlternativeBusinessKey(org.camunda.bpm.engine.delegate.DelegateExecution execution, Variables variables)
      Generates an alternative business-key and stores it as a process variable with name BpmnExecutionVariables.ALTERNATIVE_BUSINESS_KEY

      Use this method in combination with overriding sendTask(DelegateExecution, Variables, Target, String, String, String, String, Stream) to use an alternative business-key with the communication target.

       @Override
       protected void sendTasksendTask(DelegateExecution execution, Variables variables, Target target,
                      String instantiatesCanonical, String messageName, String businessKey, String profile,
                      Stream<ParameterComponent> additionalInputParameters)
       {
              String alternativeBusinesKey = createAndSaveAlternativeBusinessKey();
              super.sendTask(execution, target, instantiatesUri, messageName, alternativeBusinesKey, profile,
                              additionalInputParameters);
       }
       
      Return tasks from the target using the alternative business-key will correlate with this process instance.

      Parameters:
      execution - not null
      Returns:
      the alternative business-key stored as variable BpmnExecutionVariables.ALTERNATIVE_BUSINESS_KEY
      See Also:
    • sendTask

      protected void sendTask(org.camunda.bpm.engine.delegate.DelegateExecution execution, Variables variables, Target target, String instantiatesCanonical, String messageName, String businessKey, String profile, Stream<org.hl7.fhir.r4.model.Task.ParameterComponent> additionalInputParameters)
      Parameters:
      execution - not null
      variables - not null
      target - not null
      instantiatesCanonical - not null, not empty
      messageName - not null, not empty
      businessKey - not null, not empty
      profile - not null, not empty
      additionalInputParameters - may be null
    • doSend

      protected org.hl7.fhir.r4.model.IdType doSend(FhirWebserviceClient client, org.hl7.fhir.r4.model.Task task)
      Override this method to modify the remote task create behavior, e.g. to implement retries
       
       @Override
       protected void doSend(FhirWebserviceClient client, Task task)
       {
           client.withMinimalReturn().withRetry(2).create(task);
       }
       
       
      Parameters:
      client - not null
      task - not null
      Returns:
      id of created task
    • getRecipient

      protected org.hl7.fhir.r4.model.Reference getRecipient(Target target)
    • getRequester

      protected org.hl7.fhir.r4.model.Reference getRequester()