cancel
Showing results for 
Search instead for 
Did you mean: 

claim, setAssignee and taskAssignee

chantme
Champ in-the-making
Champ in-the-making
Hello

I try to make my own experience with the APIs Smiley Happy

If I do


// case 1
Task myTask = lstCandidateTask.get(0);
myTask.setAssignee(myUser);
List<Task> lstTask = taskServ.createTaskQuery().taskAssignee(myUser).list();

lstTask is empty

But if I do


// case 2
Task myTask = lstCandidateTask.get(0);
taskServ.claim(myTask.getId(), myUser);
List<Task> lstTask = taskServ.createTaskQuery().taskAssignee(myUser).list();

lstTask contains the assigned task to myUser.

I know that claim checks if the task is not already assigned.

But why in the first case the task does not appear assigned to myUser ?

(I use Activiti 5.10)

Thank you  Smiley Happy  Smiley Happy
5 REPLIES 5

heymjo
Champ on-the-rise
Champ on-the-rise

Task myTask = lstCandidateTask.get(0);
myTask.setAssignee(myUser);
taskServ.saveTask(myTask);
List<Task> lstTask = taskServ.createTaskQuery().taskAssignee(myUser).list();

i agree it is not very intuitive.

chantme
Champ in-the-making
Champ in-the-making
Yes indeed  !!

Thank you Jorg !

frederikherema1
Star Contributor
Star Contributor
It's a simple principle IMHO. All operations you perform on the task-service (e.g.. setAssignee and claim) are persisted immediately.

Everything you do on the Task object, should be applied by saving that object, using saveTask().

heymjo
Champ on-the-rise
Champ on-the-rise

It's a simple principle IMHO. All operations you perform on the task-service (e.g.. setAssignee and claim) are persisted immediately.

Everything you do on the Task object, should be applied by saving that object, using saveTask().

Sure, but logically why is there no claim|complete etc on task then ? This is the confusing bit, the fact that some operations are present on both sides but they work differently and some operations are only available on the task service.

From a technical point of view i know of course why they are this way, but it's just slightly confusing as this post demonstrates.

frederikherema1
Star Contributor
Star Contributor
Setting the assignee is the claim… However, this does not alter the state of a task, nor a process. Completing does, so it won't make sense to make this available in the POJO, since it impacts more than meets the eye.