[jboss-user] [jBPM] - Tasks Assigned to Groups Not Found
James Williams
do-not-reply at jboss.com
Wed Jul 13 09:30:15 EDT 2011
James Williams [http://community.jboss.org/people/williajd] created the discussion
"Tasks Assigned to Groups Not Found"
To view the discussion, visit: http://community.jboss.org/message/614902#614902
--------------------------------------------------------------
Hi,
I'm using JBPM 5.1 Final and have spent a couple of hours learning how tasks are returned from the TaskService. I believe I have found a bug in the way tasks are returned when they are not assigned to a particular user.
I have 2 simple processes that I'm using to test my code. I'm making sure I can create a process and then return the first tasks from them.
The first one SimpleHumanTaskProcess has a single task with the owner id set to "testUser". When I create the process I can use the TaskClient.getTasksOwned method to return the created tasks as expected. When I look in the database the tasks are there and have owner and creator set to "testUser".
The second process is called SimpleGroupTaskProcess and has a single Human Task that has groupId = "testGroup". The process is created properly and I am able to examine the database and noticed that the task owner and creator are not set. The potential owner DOES include the "testGroup" so I would expect it to be found. Howevewr it is not retrieved when using the TaskClient.getTasksAssignedAsPotentialOwner passing in the user "testUser" and group "testGroup".
After some digging I think I have found the problem. The key is that the creator and owner is not set on the task. I found the underlying named query called "TasksAssignedAsPotentialOwnerWithGroups" in the orm.xml file. The query was not taking into account the null creator and owner so was only returning the tasks belonging to the "testUser" but not the group assignment.
|| *Old
* || *New
* ||
| select
new org.jbpm.task.query.TaskSummary(
t.id,
t.taskData.processInstanceId,
name.text,
subject.text,
description.text,
t.taskData.status,
t.priority,
t.taskData.skipable,
t.taskData.actualOwner,
t.taskData.createdBy,
t.taskData.createdOn,
t.taskData.activationTime,
t.taskData.expirationTime)
from
Task t
left join t.taskData.createdBy
left join t.taskData.actualOwner
left join t.subjects as subject
left join t.descriptions as description
left join t.names as name,
OrganizationalEntity potentialOwners
where
( potentialOwners.id = :userId or potentialOwners.id in (:groupIds) ) and
potentialOwners in elements ( t.peopleAssignments.potentialOwners ) and
(
name.language = :language
or t.names.size = 0
) and
(
subject.language = :language
or t.subjects.size = 0
) and
(
description.language = :language
or t.descriptions.size = 0
) and
t.taskData.status in ('Created', 'Ready', 'Reserved', 'InProgress', 'Suspended') and
t.taskData.expirationTime is nul | select
new org.jbpm.task.query.TaskSummary(
t.id,
t.taskData.processInstanceId,
name.text,
subject.text,
description.text,
t.taskData.status,
t.priority,
t.taskData.skipable,
owner,
creator,
t.taskData.createdOn,
t.taskData.activationTime,
t.taskData.expirationTime)
from
Task t
left join t.taskData.createdBy as creator
left join t.taskData.actualOwner as owner
left join t.subjects as subject
left join t.descriptions as description
left join t.names as name,
OrganizationalEntity potentialOwners
where
( potentialOwners.id = :userId or potentialOwners.id in (:groupIds) ) and
potentialOwners in elements ( t.peopleAssignments.potentialOwners ) and
(
name.language = :language
or t.names.size = 0
) and
(
subject.language = :language
or t.subjects.size = 0
) and
(
description.language = :language
or t.descriptions.size = 0
) and
t.taskData.status in ('Created', 'Ready', 'Reserved', 'InProgress', 'Suspended') and
t.taskData.expirationTime is null |
This appears to work.
I do have a couple of questions though. Should tasks be created in the database without having at least a creator id? Is this expected behaviour for tasks assigned to groups?
I have attached my processes, just in case there is something I've done wrong that someone can help me with.
Thanks
James
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/614902#614902]
Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110713/52826e67/attachment.html
More information about the jboss-user
mailing list