Hi there,
I am using Flowable 6.3.0 in a Spring web application. I created a class implementing org.flowable.engine.delegate.TaskListener, and I would like to grab the lane name in the org.flowable.engine.delegate.TaskListener.notify(DelegateTask) method. I skimmed through the methods provided in the org.flowable.task.service.delegate.DelegateTask class, but I couldn’t find what I was looking for. I need this functionality in order to find out which role to assign a task to (I am handling assignation using my own application’s logic). Thanks in advance!
Hi,
I would use org.flowable.task.service.delegate.DelegateTask#getProcessDefinitionId
to get definition. After that you can get model, and based on the taskDefinitionKey
you can obtain task definition. Model parsed from the definition could contain lane as a task ancestor.
Martin
Hi Martin,
Thanks for the reply. However, as I am very new to Flowable, I’m not sure how to do the following:
- getting “model” from process definition
- getting task definition from taskDefinitionKey
- parsing model from task definition
Here is my sample code:
String processDefinitionId = delegateTask.getProcessDefinitionId();
ProcessEngine processEngine = SpringUtil.lookupBean(ProcessEngine.class);
ProcessDefinition processDefinition = processEngine.getRepositoryService().getProcessDefinition(processDefinitionId);
// how to get "model" from process definition?
String taskDefinitionKey = delegateTask.getTaskDefinitionKey();
List<Task> tasks = processEngine.getTaskService().createTaskQuery().taskDefinitionKey(taskDefinitionKey)
.processInstanceId(delegateTask.getProcessInstanceId()).list();
Task task = tasks.get(0);
// how to get task definition?
// how to parse "model" from task definition?
Would you be so kind as to enlighten me? Thanks!
org.flowable.engine.impl.RepositoryServiceImpl#getBpmnModel
Task definitions are not deployed. But it could be worth to do that because of e.g. adhoc tasks.
Bpmn model contains all information about your model And you can find your task somewhere in:
org.flowable.bpmn.model.Process#flowElementList
Martin