[jbpm-commits] JBoss JBPM SVN: r6448 - in jbpm4/trunk/modules: pvm/src/main/java/org/jbpm/pvm/internal/query and 1 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Jul 1 11:55:47 EDT 2010
Author: swiderski.maciej
Date: 2010-07-01 11:55:46 -0400 (Thu, 01 Jul 2010)
New Revision: 6448
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/TaskQuery.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/TaskQueryImpl.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskQueryProcessTest.java
Log:
JBPM-2901: task query extended with executionId as query condition. Incorporated changes done by Micheal
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/TaskQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/TaskQuery.java 2010-07-01 08:54:37 UTC (rev 6447)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/TaskQuery.java 2010-07-01 15:55:46 UTC (rev 6448)
@@ -58,6 +58,9 @@
* associated as a candidate group to the task. */
TaskQuery candidate(String userId);
+ /** only select tasks that are associated to the given execution */
+ TaskQuery executionId(String executionId);
+
/** only select tasks that are associated to the given process instance */
TaskQuery processInstanceId(String processInstanceId);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/TaskQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/TaskQueryImpl.java 2010-07-01 08:54:37 UTC (rev 6447)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/TaskQueryImpl.java 2010-07-01 15:55:46 UTC (rev 6448)
@@ -54,6 +54,7 @@
protected String assignee;
protected String candidate;
protected Boolean suspended;
+ protected String executionId;
protected String processInstanceId;
protected String processDefinitionId;
protected String activityName;
@@ -75,6 +76,11 @@
return this;
}
+ public TaskQuery executionId(String executionId) {
+ this.executionId = executionId;
+ return this;
+ }
+
public TaskQuery processInstanceId(String processInstanceId) {
this.processInstanceId = processInstanceId;
return this;
@@ -190,6 +196,10 @@
}
}
+ if (executionId!=null) {
+ appendWhereClause("task.execution.id = '"+executionId+"' ", hql);
+ }
+
if (processInstanceId!=null) {
appendWhereClause("task.processInstance.id = '"+processInstanceId+"' ", hql);
}
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskQueryProcessTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskQueryProcessTest.java 2010-07-01 08:54:37 UTC (rev 6447)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskQueryProcessTest.java 2010-07-01 15:55:46 UTC (rev 6448)
@@ -21,11 +21,13 @@
*/
package org.jbpm.test.task;
+import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.jbpm.api.Execution;
import org.jbpm.api.ProcessInstance;
import org.jbpm.api.task.Task;
@@ -243,4 +245,55 @@
assertEquals(0, workHardForTheMoneyTasks);
}
+
+ public void testTaskQueryExecutionId() {
+ deployJpdlXmlString(
+ "<process name='VacationTrip'>"
+ + " <start>"
+ + " <transition to='f' />"
+ + " </start>"
+ + " <fork name='f'>"
+ + " <transition to='select destination' />"
+ + " <transition to='work hard for the money' />"
+ + " </fork>"
+ + " <task name='select destination' "
+ + " assignee='johndoe'>"
+ + " <transition to='join' />"
+ + " </task>"
+ + " <task name='work hard for the money' "
+ + " assignee='johndoe'>"
+ + " <transition to='join' />"
+ + " </task>"
+ + " <join name='join'>"
+ + " <transition to='end' />"
+ + " </join>"
+ + " <end name='end'/>"
+ + "</process>");
+ // start the process
+ ProcessInstance process = executionService.startProcessInstanceByKey("VacationTrip");
+
+ // we should have two tasks and two executions here:
+ Collection<? extends Execution> executions = process.getExecutions();
+ assertEquals(2, executions.size());
+
+ // check if there is one task in each execution:
+ for (Execution execution : executions) {
+ Task task = taskService.createTaskQuery().executionId(execution.getId()).uniqueResult();
+ assertNotNull(task);
+ assertEquals(execution.getId(), task.getExecutionId());
}
+
+ // complete the tasks
+ process = executionService.findProcessInstanceById(process.getId());
+ executions = process.getExecutions();
+ for (Execution execution : executions) {
+ assertFalse(execution.isEnded());
+ Task task = taskService.createTaskQuery().executionId(execution.getId()).uniqueResult();
+ taskService.completeTask(task.getId());
+ }
+
+ // process should be ended now
+ process = executionService.findProcessInstanceById(process.getId());
+ assertNull(process);
+ }
+}
More information about the jbpm-commits
mailing list