提交 5662c1f7 编写于 作者: F frederikheremans

ACT-725: priority min/max added to taskQuery - Applied patch submitted by Tim Stephenson

上级 6146c7d4
...@@ -38,6 +38,8 @@ public class TaskQueryImpl extends AbstractQuery<TaskQuery, Task> implements Tas ...@@ -38,6 +38,8 @@ public class TaskQueryImpl extends AbstractQuery<TaskQuery, Task> implements Tas
protected String description; protected String description;
protected String descriptionLike; protected String descriptionLike;
protected Integer priority; protected Integer priority;
protected Integer minPriority;
protected Integer maxPriority;
protected String assignee; protected String assignee;
protected String involvedUser; protected String involvedUser;
protected String owner; protected String owner;
...@@ -115,6 +117,22 @@ public class TaskQueryImpl extends AbstractQuery<TaskQuery, Task> implements Tas ...@@ -115,6 +117,22 @@ public class TaskQueryImpl extends AbstractQuery<TaskQuery, Task> implements Tas
return this; return this;
} }
public TaskQuery taskMinPriority(Integer minPriority) {
if (minPriority == null) {
throw new ActivitiException("Min Priority is null");
}
this.minPriority = minPriority;
return this;
}
public TaskQuery taskMaxPriority(Integer maxPriority) {
if (maxPriority == null) {
throw new ActivitiException("Max Priority is null");
}
this.maxPriority = maxPriority;
return this;
}
public TaskQueryImpl taskAssignee(String assignee) { public TaskQueryImpl taskAssignee(String assignee) {
if (assignee == null) { if (assignee == null) {
throw new ActivitiException("Assignee is null"); throw new ActivitiException("Assignee is null");
......
...@@ -46,6 +46,12 @@ public interface TaskQuery extends Query<TaskQuery, Task>{ ...@@ -46,6 +46,12 @@ public interface TaskQuery extends Query<TaskQuery, Task>{
/** Only select tasks with the given priority. */ /** Only select tasks with the given priority. */
TaskQuery taskPriority(Integer priority); TaskQuery taskPriority(Integer priority);
/** Only select tasks with the given priority or higher. */
TaskQuery taskMinPriority(Integer minPriority);
/** Only select tasks with the given priority or lower. */
TaskQuery taskMaxPriority(Integer maxPriority);
/** Only select tasks which are assigned to the given user. */ /** Only select tasks which are assigned to the given user. */
TaskQuery taskAssignee(String assignee); TaskQuery taskAssignee(String assignee);
......
...@@ -157,6 +157,12 @@ ...@@ -157,6 +157,12 @@
<if test="priority != null"> <if test="priority != null">
and T.PRIORITY_ = #{priority} and T.PRIORITY_ = #{priority}
</if> </if>
<if test="minPriority != null">
and T.PRIORITY_ &gt;= #{minPriority}
</if>
<if test="maxPriority != null">
and T.PRIORITY_ &lt;= #{maxPriority}
</if>
<if test="assignee != null"> <if test="assignee != null">
and T.ASSIGNEE_ = #{assignee} and T.ASSIGNEE_ = #{assignee}
</if> </if>
......
...@@ -208,6 +208,18 @@ public class TaskQueryTest extends PluggableActivitiTestCase { ...@@ -208,6 +208,18 @@ public class TaskQueryTest extends PluggableActivitiTestCase {
assertNull(query.singleResult()); assertNull(query.singleResult());
assertEquals(0, query.list().size()); assertEquals(0, query.list().size());
assertEquals(0, query.count()); assertEquals(0, query.count());
query = taskService.createTaskQuery().taskMinPriority(50);
assertEquals(3, query.list().size());
query = taskService.createTaskQuery().taskMinPriority(10);
assertEquals(5, query.list().size());
query = taskService.createTaskQuery().taskMaxPriority(10);
assertEquals(9, query.list().size());
query = taskService.createTaskQuery().taskMaxPriority(3);
assertEquals(6, query.list().size());
} }
public void testQueryByInvalidPriority() { public void testQueryByInvalidPriority() {
...@@ -546,6 +558,15 @@ public class TaskQueryTest extends PluggableActivitiTestCase { ...@@ -546,6 +558,15 @@ public class TaskQueryTest extends PluggableActivitiTestCase {
Calendar otherDate = Calendar.getInstance(); Calendar otherDate = Calendar.getInstance();
otherDate.add(Calendar.YEAR, 1); otherDate.add(Calendar.YEAR, 1);
assertEquals(0, taskService.createTaskQuery().dueDate(otherDate.getTime()).count()); assertEquals(0, taskService.createTaskQuery().dueDate(otherDate.getTime()).count());
Calendar priorDate = Calendar.getInstance();
priorDate.setTime(dueDate);
priorDate.roll(Calendar.YEAR, -1);
assertEquals(1, taskService.createTaskQuery().dueAfter(priorDate.getTime())
.count());
assertEquals(1, taskService.createTaskQuery()
.dueBefore(otherDate.getTime()).count());
} }
@Deployment(resources={"org/activiti/engine/test/api/task/TaskQueryTest.testProcessDefinition.bpmn20.xml"}) @Deployment(resources={"org/activiti/engine/test/api/task/TaskQueryTest.testProcessDefinition.bpmn20.xml"})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册