Hi Sebastian,
traversing the graph is to much details at the moment :-)
I also thought about setting variables after process creation, however I would like to get a more "standardized" solution that is also visible at design time (maybe with validation checks at runtime (after deployment)?)
My currently favoured approach is to go via a "extension variable" (maybe wrong wording) like in this snippet:
https://github.com/camunda/camunda-consulting/blob/master/snippets/extension-attributes-for-user-tasks/src/main/java/com/camunda/bpm/demo/extension_attributes_for_user_tasks/EscalationStartTaskListener.java
So every Usertask beeing a approval task has to have an extension variable like "ApprovalTask". However, after a task has been created, I don't see a quick way to get from a HistoricTaskInstance or a Task to the UserTask, like one can do with delegateTask:
UserTask userTask = delegateTask.getBpmnModelElementInstance();
Is there something like this or do I have to go via such engine queries:
final Task task = processEngine.getTaskService().createTaskQuery().taskId(taskInstance.getId()).singleResult();
final Collection<UserTask> userTasks = processEngine.getRepositoryService().getBpmnModelInstance(task.getProcessDefinitionId()).getModelElementsByType(org.camunda.bpm.model.bpmn.instance.UserTask.class);
for (final UserTask userTask : userTasks) {
final String userTaskId = userTask.getId();
final String taskInstanceId = task.getTaskDefinitionKey();
if (userTaskId.equals(taskInstanceId)) {
final ExtensionElements extensionElements = userTask.getExtensionElements();
final Collection<CamundaProperty> properties = extensionElements.getElementsQuery().filterByType(CamundaProperties.class).singleResult().getCamundaProperties();
for (final CamundaProperty camundaProperty : properties) {
camundaProperty.getCamundaName();
camundaProperty.getCamundaValue();
}
}
}
Regards
Kristian