[
https://jira.jboss.org/browse/JBPM-2648?page=com.atlassian.jira.plugin.sy...
]
Sandro Röder commented on JBPM-2648:
------------------------------------
I test the source code from the cvs:
this is the resulting sql:
select distinct (task.id) from org.jbpm.pvm.internal.task.TaskImpl as task ,
org.jbpm.pvm.internal.task.ParticipationImpl as participant where participant.task = task
and participant.type = 'candidate' and ((participant.userId = :candidateUserId)
or (participant.groupId in (:candidateGroupIds))) and task.assignee is null
and in the result set is the following:
[1260352, 1260356]
just the task ids.
here is my working change 8on version (4.3) with a subselect to get the tasks directly:
/**
*
*/
package com.ctlmb.vip.jbpm.impl;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import org.jbpm.api.identity.Group;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.identity.spi.IdentitySession;
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.query.TaskQueryImpl;
import org.jbpm.pvm.internal.task.ParticipationImpl;
import org.jbpm.pvm.internal.task.TaskImpl;
/**
* TODO comment me
* @author roeder
*
*/
public class TaskQueryWorkaround extends TaskQueryImpl{
private static final Logger log = Logger.getLogger(TaskQueryWorkaround.class);
/* (non-Javadoc)
* @see org.jbpm.pvm.internal.query.TaskQueryImpl#hql()
*/
@Override
public String hql() {
StringBuilder hql = new StringBuilder();
hql.append("select ");
if (count) {
hql.append("count(task) ");
} else {
hql.append("task ");
}
hql.append("from ");
hql.append(TaskImpl.class.getName());
hql.append(" as task ");
// participations
if (candidate!=null) {
//################# orginal
// hql.append(", ");
// hql.append(ParticipationImpl.class.getName());
// hql.append(" as participant ");
//
// appendWhereClause("participant.task = task ", hql);
// appendWhereClause("participant.type = 'candidate' ", hql);
//
// IdentitySession identitySession =
EnvironmentImpl.getFromCurrent(IdentitySession.class);
// List<Group> groups = identitySession.findGroupsByUser(candidate);
// if (groups.isEmpty()) {
// groupIds = null;
// appendWhereClause("participant.userId = :candidateUserId ", hql);
//
// } else {
// groupIds = new ArrayList<String>();
// for (Group group: groups) {
// groupIds.add(group.getId());
// }
// appendWhereClause("((participant.userId = :candidateUserId) or
(participant.groupId in (:candidateGroupIds)))", hql);
// }
//################# end orginal
//################# my change
appendWhereClause("task in ( ", hql);
StringBuilder innerSelect = new StringBuilder();
innerSelect.append("select participant.task ");
innerSelect.append("from ");
innerSelect.append(ParticipationImpl.class.getName());
innerSelect.append(" as participant ");
innerSelect.append("where ");
innerSelect.append("participant.type = 'candidate' ");
IdentitySession identitySession =
EnvironmentImpl.getFromCurrent(IdentitySession.class);
List<Group> groups = identitySession.findGroupsByUser(candidate);
innerSelect.append("and ");
if (groups.isEmpty()) {
groupIds = null;
innerSelect.append("participant.userId = :candidateUserId ");
} else {
groupIds = new ArrayList<String>();
for (Group group: groups) {
groupIds.add(group.getId());
}
innerSelect.append("((participant.userId = :candidateUserId) or
(participant.groupId in (:candidateGroupIds)))");
}
hql.append(innerSelect);
hql.append(") ");
}
//################# end my change
if (suspended!=null) {
if (suspended) {
appendWhereClause("task.state =
'"+ExecutionImpl.STATE_SUSPENDED+"' ", hql);
} else {
appendWhereClause("task.state !=
'"+ExecutionImpl.STATE_SUSPENDED+"' ", hql);
}
}
if (processInstanceId!=null) {
appendWhereClause("task.processInstance.id =
'"+processInstanceId+"' ", hql);
}
if (activityName!=null) {
appendWhereClause("task.execution.activityName =
'"+activityName+"' ", hql);
}
if (processDefinitionId!=null) {
appendWhereClause("task.processInstance.processDefinitionId =
'"+processDefinitionId+"' ", hql);
}
if (assignee!=null) {
appendWhereClause("task.assignee = :assignee ", hql);
} else if (unassigned) {
appendWhereClause("task.assignee is null ", hql);
}
appendOrderByClause(hql);
String hqlQuery = hql.toString();
log.debug(hqlQuery);
return hqlQuery;
}
/* (non-Javadoc)
* @see org.jbpm.pvm.internal.query.AbstractQuery#count()
*/
@Override
public long count() {
count = true;
return -9999;
}
}
Candidate-Groups
-----------------
Key: JBPM-2648
URL:
https://jira.jboss.org/browse/JBPM-2648
Project: jBPM
Issue Type: Task
Security Level: Public(Everyone can see)
Components: Runtime Engine
Affects Versions: jBPM 4.2
Reporter: Sebastian Castellanos
Assignee: Maciej Swiderski
Fix For: jBPM 4.4
Attachments: candidates.rar, X2678DuplicatedGroupTasksTest.java
Hi,
I have a problem when seeking tasks using candidate-groups.
I created tarea1 which has associated candidate-groups "Group1, Group2, Group3.
Then I have a user "sebastian" which is a member of Group 1, Group 2 and Group
3.
The problem is that when I run taskService().findGroupTasks("sebastian");
I returned a list of 3 tasks equal, Tarea1, Tarea1, Tarea1. When it should be listed just
once the task (Tarea1).
I'm not sure if it's a conceptual issue or a bug in the API.
I would be grateful for your help.
P/d: I'm not using swimlane because I had problems with respect to the Fork / Join.
Greetings. Sebastian
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira