cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieve task definition ID with Java API

mano_swerts
Champ in-the-making
Champ in-the-making
Hi all,

We are fiddling with Activiti in Alfresco 4.2.c for an upcoming project. We created a simple workflow with a user task. The user task definition in the Activiti designer and in the XML shows an id with value "verwittigDirectieleden". The description is set to "Verwittig directieleden". The snippet from the XML file:


<userTask id="verwittigDirectieleden" name="Verwittig directieleden" activiti:candidateGroups="GROUP_directieassistenten"></userTask>


In Java we we're able to retrieve all the pooled tasks and claim this task to  a person. However when we look at the properties of this task, we see the following values for some properties:


definition = WorkflowTaskDefinition [id=bpm_workflowTask,metadata=ClassDef[name={http://www.alfresco.org/model/bpm/1.0}workflowTask]]
id = "activity$130"
name = "bpm_workflowTask"
properties = { {http://www.alfresco.org/model/bpm/1.0}description=Verwittig directieleden, … }


As you can see, the id in the WorkflowTaskDefinition class does not match the id in the XML. We see the description from the XML appear in the "properties" variable, but the XML id is nowhere to be seen.

Is this a bug in Activiti or are we approaching this the wrong way? Any help is greatly appreciated.

Kind regards,

Mano Swerts
3 REPLIES 3

abarisone
Star Contributor
Star Contributor
Hi,
you can take a look here http://dev.alfresco.com/resource/docs/java/repository/org/alfresco/service/cmr/workflow/WorkflowServ... for WorkflowService interface.
The method you're looking for might be
getTaskById(java.lang.String taskId)
Gets a Task by unique Id

Regards,
Andrea

Hi Andrea,

As you can read in my post, the problem is not retrieving a task. Retrieving all tasks for a certain person works fine. The problem is that I cannot find the id from the workflow XML (the .bpmn file) in the WorkflowTask object. I would expect that it matches the id in the WorkflowTaskDefinition object, but that does not seem the case. I can see the description from the .bpmn file in the properties Map, but the id from the .bpmn file is nowhere to be found.

I wonder if we are searching in the wrong place or that it is a bug and that the id in the WorkflowTaskDefinition object must match the id in the .bpmn file.

Kind regards,

Mano

Appearantly I had to look a little deeper into the WorkflowTaskDefinition class. I can retrieve the XML id with the following code on a WorkflowTask:


task.getDefinition().getNode().getName();