diff --git a/dsf-bpe/dsf-bpe-process-base/src/main/java/org/highmed/dsf/bpe/delegate/AbstractServiceDelegate.java b/dsf-bpe/dsf-bpe-process-base/src/main/java/org/highmed/dsf/bpe/delegate/AbstractServiceDelegate.java
index 3979c6602..3d10e4bb1 100755
--- a/dsf-bpe/dsf-bpe-process-base/src/main/java/org/highmed/dsf/bpe/delegate/AbstractServiceDelegate.java
+++ b/dsf-bpe/dsf-bpe-process-base/src/main/java/org/highmed/dsf/bpe/delegate/AbstractServiceDelegate.java
@@ -25,12 +25,6 @@ public abstract class AbstractServiceDelegate implements JavaDelegate, Initializ
private final TaskHelper taskHelper;
private final ReadAccessHelper readAccessHelper;
- /**
- * @deprecated as of release 0.8.0, use {@link #getExecution()} instead
- */
- @Deprecated
- protected DelegateExecution execution;
-
public AbstractServiceDelegate(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper,
ReadAccessHelper readAccessHelper)
{
@@ -50,8 +44,6 @@ public void afterPropertiesSet() throws Exception
@Override
public final void execute(DelegateExecution execution) throws Exception
{
- this.execution = execution;
-
try
{
logger.trace("Execution of task with id='{}'", execution.getCurrentActivityId());
@@ -61,7 +53,7 @@ public final void execute(DelegateExecution execution) throws Exception
// Error boundary event, do not stop process execution
catch (BpmnError error)
{
- Task task = getTask();
+ Task task = getTask(execution);
logger.debug("Error while executing service delegate " + getClass().getName(), error);
logger.error(
@@ -74,12 +66,12 @@ public final void execute(DelegateExecution execution) throws Exception
// Not an error boundary event, stop process execution
catch (Exception exception)
{
- Task task = getTask();
+ Task task = getTask(execution);
logger.debug("Error while executing service delegate " + getClass().getName(), exception);
- logger.error("Process {} has fatal error in step {} for task with id {}, reason: {}",
+ logger.error("Process {} has fatal error in step {} for task with id {}, reason: {} - {}",
execution.getProcessDefinitionId(), execution.getActivityInstanceId(), task.getId(),
- exception.getMessage());
+ exception.getClass().getName(), exception.getMessage());
String errorMessage = "Process " + execution.getProcessDefinitionId() + " has fatal error in step "
+ execution.getActivityInstanceId() + ", reason: " + exception.getMessage();
@@ -109,11 +101,6 @@ public final void execute(DelegateExecution execution) throws Exception
*/
protected abstract void doExecute(DelegateExecution execution) throws BpmnError, Exception;
- protected final DelegateExecution getExecution()
- {
- return execution;
- }
-
protected final TaskHelper getTaskHelper()
{
return taskHelper;
@@ -130,36 +117,42 @@ protected final ReadAccessHelper getReadAccessHelper()
}
/**
+ * @param execution
+ * not null
* @return the active task from execution variables, i.e. the leading task if the main process is running or the
* current task if a subprocess is running.
* @throws IllegalStateException
* if execution of this service delegate has not been started
* @see ConstantsBase#BPMN_EXECUTION_VARIABLE_TASK
*/
- protected final Task getTask()
+ protected final Task getTask(DelegateExecution execution)
{
return taskHelper.getTask(execution);
}
/**
+ * @param execution
+ * not null
* @return the current task from execution variables, the task resource that started the current process or
* subprocess
* @throws IllegalStateException
* if execution of this service delegate has not been started
* @see ConstantsBase#BPMN_EXECUTION_VARIABLE_TASK
*/
- protected final Task getCurrentTaskFromExecutionVariables()
+ protected final Task getCurrentTaskFromExecutionVariables(DelegateExecution execution)
{
return taskHelper.getCurrentTaskFromExecutionVariables(execution);
}
/**
+ * @param execution
+ * not null
* @return the leading task from execution variables, same as current task if not in a subprocess
* @throws IllegalStateException
* if execution of this service delegate has not been started
* @see ConstantsBase#BPMN_EXECUTION_VARIABLE_LEADING_TASK
*/
- protected final Task getLeadingTaskFromExecutionVariables()
+ protected final Task getLeadingTaskFromExecutionVariables(DelegateExecution execution)
{
return taskHelper.getLeadingTaskFromExecutionVariables(execution);
}
@@ -168,13 +161,15 @@ protected final Task getLeadingTaskFromExecutionVariables()
* Use this method to update the process engine variable {@link ConstantsBase#BPMN_EXECUTION_VARIABLE_TASK},
* after modifying the {@link Task}.
*
+ * @param execution
+ * not null
* @param task
* not null
* @throws IllegalStateException
* if execution of this service delegate has not been started
* @see ConstantsBase#BPMN_EXECUTION_VARIABLE_TASK
*/
- protected final void updateCurrentTaskInExecutionVariables(Task task)
+ protected final void updateCurrentTaskInExecutionVariables(DelegateExecution execution, Task task)
{
taskHelper.updateCurrentTaskInExecutionVariables(execution, task);
}
@@ -185,13 +180,15 @@ protected final void updateCurrentTaskInExecutionVariables(Task task)
*
* Updates the current task if no leading task is set.
*
+ * @param execution
+ * not null
* @param task
* not null
* @throws IllegalStateException
* if execution of this service delegate has not been started
* @see ConstantsBase#BPMN_EXECUTION_VARIABLE_LEADING_TASK
*/
- protected final void updateLeadingTaskInExecutionVariables(Task task)
+ protected final void updateLeadingTaskInExecutionVariables(DelegateExecution execution, Task task)
{
taskHelper.updateLeadingTaskInExecutionVariables(execution, task);
}
diff --git a/dsf-bpe/dsf-bpe-process-base/src/main/java/org/highmed/dsf/bpe/listener/DefaultUserTaskListener.java b/dsf-bpe/dsf-bpe-process-base/src/main/java/org/highmed/dsf/bpe/listener/DefaultUserTaskListener.java
index 86bc1bbae..6a4a5c1ca 100644
--- a/dsf-bpe/dsf-bpe-process-base/src/main/java/org/highmed/dsf/bpe/listener/DefaultUserTaskListener.java
+++ b/dsf-bpe/dsf-bpe-process-base/src/main/java/org/highmed/dsf/bpe/listener/DefaultUserTaskListener.java
@@ -44,12 +44,6 @@ public class DefaultUserTaskListener implements TaskListener, InitializingBean
private final TaskHelper taskHelper;
private final ReadAccessHelper readAccessHelper;
- /**
- * @deprecated as of release 0.8.0, use {@link #getExecution()} instead
- */
- @Deprecated
- protected DelegateExecution execution;
-
public DefaultUserTaskListener(FhirWebserviceClientProvider clientProvider,
OrganizationProvider organizationProvider, QuestionnaireResponseHelper questionnaireResponseHelper,
TaskHelper taskHelper, ReadAccessHelper readAccessHelper)
@@ -74,7 +68,7 @@ public void afterPropertiesSet() throws Exception
@Override
public final void notify(DelegateTask userTask)
{
- this.execution = userTask.getExecution();
+ DelegateExecution execution = userTask.getExecution();
try
{
@@ -102,7 +96,7 @@ public final void notify(DelegateTask userTask)
}
catch (Exception exception)
{
- Task task = getTask();
+ Task task = getTask(execution);
logger.debug("Error while executing user task listener " + getClass().getName(), exception);
logger.error("Process {} has fatal error in step {} for task with id {}, reason: {}",
@@ -213,11 +207,6 @@ protected void modifyQuestionnaireResponse(DelegateTask userTask, QuestionnaireR
// Nothing to do in default behaviour
}
- protected final DelegateExecution getExecution()
- {
- return execution;
- }
-
protected final TaskHelper getTaskHelper()
{
return taskHelper;
@@ -234,36 +223,42 @@ protected final ReadAccessHelper getReadAccessHelper()
}
/**
+ * @param execution
+ * not null
* @return the active task from execution variables, i.e. the leading task if the main process is running or the
* current task if a subprocess is running.
* @throws IllegalStateException
* if execution of this service delegate has not been started
* @see ConstantsBase#BPMN_EXECUTION_VARIABLE_TASK
*/
- protected final Task getTask()
+ protected final Task getTask(DelegateExecution execution)
{
return taskHelper.getTask(execution);
}
/**
+ * @param execution
+ * not null
* @return the current task from execution variables, the task resource that started the current process or
* subprocess
* @throws IllegalStateException
* if execution of this service delegate has not been started
* @see ConstantsBase#BPMN_EXECUTION_VARIABLE_TASK
*/
- protected final Task getCurrentTaskFromExecutionVariables()
+ protected final Task getCurrentTaskFromExecutionVariables(DelegateExecution execution)
{
return taskHelper.getCurrentTaskFromExecutionVariables(execution);
}
/**
+ * @param execution
+ * not null
* @return the leading task from execution variables, same as current task if not in a subprocess
* @throws IllegalStateException
* if execution of this service delegate has not been started
* @see ConstantsBase#BPMN_EXECUTION_VARIABLE_LEADING_TASK
*/
- protected final Task getLeadingTaskFromExecutionVariables()
+ protected final Task getLeadingTaskFromExecutionVariables(DelegateExecution execution)
{
return taskHelper.getLeadingTaskFromExecutionVariables(execution);
}
@@ -272,13 +267,15 @@ protected final Task getLeadingTaskFromExecutionVariables()
* Use this method to update the process engine variable {@link ConstantsBase#BPMN_EXECUTION_VARIABLE_TASK},
* after modifying the {@link Task}.
*
+ * @param execution
+ * not null
* @param task
* not null
* @throws IllegalStateException
* if execution of this service delegate has not been started
* @see ConstantsBase#BPMN_EXECUTION_VARIABLE_TASK
*/
- protected final void updateCurrentTaskInExecutionVariables(Task task)
+ protected final void updateCurrentTaskInExecutionVariables(DelegateExecution execution, Task task)
{
taskHelper.updateCurrentTaskInExecutionVariables(execution, task);
}
@@ -289,13 +286,15 @@ protected final void updateCurrentTaskInExecutionVariables(Task task)
*
* Updates the current task if no leading task is set.
*
+ * @param execution
+ * not null
* @param task
* not null
* @throws IllegalStateException
* if execution of this service delegate has not been started
* @see ConstantsBase#BPMN_EXECUTION_VARIABLE_LEADING_TASK
*/
- protected final void updateLeadingTaskInExecutionVariables(Task task)
+ protected final void updateLeadingTaskInExecutionVariables(DelegateExecution execution, Task task)
{
taskHelper.updateLeadingTaskInExecutionVariables(execution, task);
}
diff --git a/dsf-bpe/dsf-bpe-process-base/src/main/java/org/highmed/dsf/fhir/task/AbstractTaskMessageSend.java b/dsf-bpe/dsf-bpe-process-base/src/main/java/org/highmed/dsf/fhir/task/AbstractTaskMessageSend.java
index 36053a38d..5e269bb1e 100755
--- a/dsf-bpe/dsf-bpe-process-base/src/main/java/org/highmed/dsf/fhir/task/AbstractTaskMessageSend.java
+++ b/dsf-bpe/dsf-bpe-process-base/src/main/java/org/highmed/dsf/fhir/task/AbstractTaskMessageSend.java
@@ -84,11 +84,11 @@ public void doExecute(DelegateExecution execution) throws Exception
// String targetOrganizationId = (String) execution.getVariable(Constants.VARIABLE_TARGET_ORGANIZATION_ID);
// String correlationKey = (String) execution.getVariable(Constants.VARIABLE_CORRELATION_KEY);
- Target target = getTarget();
+ Target target = getTarget(execution);
try
{
- sendTask(target, instantiatesUri, messageName, businessKey, profile,
+ sendTask(execution, target, instantiatesUri, messageName, businessKey, profile,
getAdditionalInputParameters(execution));
}
catch (Exception e)
@@ -102,11 +102,11 @@ public void doExecute(DelegateExecution execution) throws Exception
logger.debug("Error while sending Task", e);
if (execution.getBpmnModelElementInstance() instanceof IntermediateThrowEvent)
- handleIntermediateThrowEventError(e, errorMessage);
+ handleIntermediateThrowEventError(execution, e, errorMessage);
else if (execution.getBpmnModelElementInstance() instanceof EndEvent)
- handleEndEventError(e, errorMessage);
+ handleEndEventError(execution, e, errorMessage);
else if (execution.getBpmnModelElementInstance() instanceof SendTask)
- handleSendTaskError(e, errorMessage);
+ handleSendTaskError(execution, e, errorMessage);
else
logger.warn("Error handling for {} not implemented",
execution.getBpmnModelElementInstance().getClass().getName());
@@ -119,13 +119,14 @@ protected void addErrorMessage(Task task, String errorMessage)
errorMessage));
}
- protected void handleIntermediateThrowEventError(Exception exception, String errorMessage)
+ protected void handleIntermediateThrowEventError(DelegateExecution execution, Exception exception,
+ String errorMessage)
{
- Task task = getLeadingTaskFromExecutionVariables();
+ Task task = getLeadingTaskFromExecutionVariables(execution);
logger.debug("Error while executing Task message send " + getClass().getName(), exception);
logger.error("Process {} has fatal error in step {} for task with id {}, reason: {}",
- getExecution().getProcessDefinitionId(), getExecution().getActivityInstanceId(),
+ execution.getProcessDefinitionId(), execution.getActivityInstanceId(),
task == null ? "?" : task.getId(), exception.getMessage());
try
@@ -141,25 +142,25 @@ protected void handleIntermediateThrowEventError(Exception exception, String err
}
finally
{
- getExecution().getProcessEngine().getRuntimeService()
- .deleteProcessInstance(getExecution().getProcessInstanceId(), exception.getMessage());
+ execution.getProcessEngine().getRuntimeService().deleteProcessInstance(execution.getProcessInstanceId(),
+ exception.getMessage());
}
}
- protected void handleEndEventError(Exception exception, String errorMessage)
+ protected void handleEndEventError(DelegateExecution execution, Exception exception, String errorMessage)
{
- Task task = getLeadingTaskFromExecutionVariables();
+ Task task = getLeadingTaskFromExecutionVariables(execution);
logger.debug("Error while executing Task message send " + getClass().getName(), exception);
logger.error("Process {} has fatal error in step {} for task with id {}, reason: {}",
- getExecution().getProcessDefinitionId(), getExecution().getActivityInstanceId(),
+ execution.getProcessDefinitionId(), execution.getActivityInstanceId(),
task == null ? "?" : task.getId(), exception.getMessage());
if (task != null)
{
addErrorMessage(task, errorMessage);
task.setStatus(Task.TaskStatus.FAILED);
- updateLeadingTaskInExecutionVariables(task);
+ updateLeadingTaskInExecutionVariables(execution, task);
}
else
logger.warn("Leading Task null, unable to set failed state");
@@ -167,20 +168,20 @@ protected void handleEndEventError(Exception exception, String errorMessage)
// Task update and process-end handled by EndListener
}
- protected void handleSendTaskError(Exception exception, String errorMessage)
+ protected void handleSendTaskError(DelegateExecution execution, Exception exception, String errorMessage)
{
- Task task = getLeadingTaskFromExecutionVariables();
- Targets targets = getTargets();
+ Task task = getLeadingTaskFromExecutionVariables(execution);
+ Targets targets = getTargets(execution);
// if we are a multi instance message send task, remove target
if (targets != null)
{
addErrorMessage(task, errorMessage);
- updateLeadingTaskInExecutionVariables(task);
+ updateLeadingTaskInExecutionVariables(execution, task);
- Target target = getTarget();
+ Target target = getTarget(execution);
targets = targets.removeByEndpointIdentifierValue(target);
- updateTargets(targets);
+ updateTargets(execution, targets);
logger.debug("Target organization {}, endpoint {} with error {} removed from target list",
target.getOrganizationIdentifierValue(), target.getEndpointIdentifierValue(),
exception.getMessage());
@@ -189,7 +190,7 @@ protected void handleSendTaskError(Exception exception, String errorMessage)
{
logger.debug("Error while executing Task message send " + getClass().getName(), exception);
logger.error("Process {} has fatal error in step {} for task with id {}, last reason: {}",
- getExecution().getProcessDefinitionId(), getExecution().getActivityInstanceId(),
+ execution.getProcessDefinitionId(), execution.getActivityInstanceId(),
task == null ? "?" : task.getId(), exception.getMessage());
try
@@ -204,8 +205,8 @@ protected void handleSendTaskError(Exception exception, String errorMessage)
}
finally
{
- getExecution().getProcessEngine().getRuntimeService()
- .deleteProcessInstance(getExecution().getProcessInstanceId(), exception.getMessage());
+ execution.getProcessEngine().getRuntimeService()
+ .deleteProcessInstance(execution.getProcessInstanceId(), exception.getMessage());
}
}
}
@@ -216,57 +217,39 @@ protected void handleSendTaskError(Exception exception, String errorMessage)
* then {@link ConstantsBase#BPMN_EXECUTION_VARIABLE_TARGET}.
*
* @param execution
- * the delegate execution of this process instance
+ * not null
* @return {@link Target} that should receive the message
- * @deprecated use {@link #getTarget()}
*/
- @Deprecated
protected Target getTarget(DelegateExecution execution)
{
return (Target) execution.getVariable(BPMN_EXECUTION_VARIABLE_TARGET);
}
- /**
- * Override this method if the {@link Target} variable is stored in a different process engine variable other
- * then {@link ConstantsBase#BPMN_EXECUTION_VARIABLE_TARGET}.
- *
- * @return {@link Target} that should receive the message
- */
- protected Target getTarget()
- {
- if (getExecution() == null)
- throw new IllegalStateException("execution not started");
-
- return (Target) getExecution().getVariable(BPMN_EXECUTION_VARIABLE_TARGET);
- }
-
/**
* Override this method if the {@link Targets} variable is stored in a different process engine variable other
* then {@link ConstantsBase#BPMN_EXECUTION_VARIABLE_TARGETS}.
*
+ * @param execution
+ * not null
* @return {@link Targets} that should receive the message
*/
- protected Targets getTargets()
+ protected Targets getTargets(DelegateExecution execution)
{
- if (getExecution() == null)
- throw new IllegalStateException("execution not started");
-
- return (Targets) getExecution().getVariable(BPMN_EXECUTION_VARIABLE_TARGETS);
+ return (Targets) execution.getVariable(BPMN_EXECUTION_VARIABLE_TARGETS);
}
/**
* Override this method if the {@link Targets} variable should stored in a different process engine variable
* other then {@link ConstantsBase#BPMN_EXECUTION_VARIABLE_TARGETS}.
*
+ * @param execution
+ * not null
* @param targets
* the targets to save in process engine variable {@link ConstantsBase#BPMN_EXECUTION_VARIABLE_TARGETS}
*/
- protected void updateTargets(Targets targets)
+ protected void updateTargets(DelegateExecution execution, Targets targets)
{
- if (getExecution() == null)
- throw new IllegalStateException("execution not started");
-
- getExecution().setVariable(BPMN_EXECUTION_VARIABLE_TARGETS, TargetsValues.create(targets));
+ execution.setVariable(BPMN_EXECUTION_VARIABLE_TARGETS, TargetsValues.create(targets));
}
/**
@@ -286,33 +269,35 @@ protected Stream
*
* Use this method in combination with overriding
- * {@link #sendTask(Target, String, String, String, String, Stream)} to use an alternative business-key with the
- * communication target.
+ * {@link #sendTask(DelegateExecution, Target, String, String, String, String, Stream)} to use an alternative
+ * business-key with the communication target.
*
*
* @Override
- * protected void sendTask(Target target, String instantiatesUri, String messageName, String businessKey,
- * String profile, Stream<ParameterComponent> additionalInputParameters)
+ * protected void sendTask(DelegateExecution execution, Target target, String instantiatesUri, String messageName,
+ * String businessKey, String profile, Stream<ParameterComponent> additionalInputParameters)
* {
* String alternativeBusinesKey = createAndSaveAlternativeBusinessKey();
- * super.sendTask(target, instantiatesUri, messageName, alternativeBusinesKey, profile,
+ * super.sendTask(execution, target, instantiatesUri, messageName, alternativeBusinesKey, profile,
* additionalInputParameters);
* }
*
*
+ * @param execution
+ * not null
* @return the alternative business-key stored as variable
* {@link ConstantsBase#BPMN_EXECUTION_VARIABLE_ALTERNATIVE_BUSINESS_KEY}
*/
- protected final String createAndSaveAlternativeBusinessKey()
+ protected final String createAndSaveAlternativeBusinessKey(DelegateExecution execution)
{
String alternativeBusinessKey = UUID.randomUUID().toString();
- getExecution().setVariable(BPMN_EXECUTION_VARIABLE_ALTERNATIVE_BUSINESS_KEY, alternativeBusinessKey);
+ execution.setVariable(BPMN_EXECUTION_VARIABLE_ALTERNATIVE_BUSINESS_KEY, alternativeBusinessKey);
return alternativeBusinessKey;
}
- protected void sendTask(Target target, String instantiatesUri, String messageName, String businessKey,
- String profile, Stream