Flowable 6.6.0 BPMN用户指南 - 17 高级用例 - 17.7 高级查询API:运行时和历史任务查询之间的无缝切换

Flowable 6.6.0 用户指南相关文档下载


《Flowable 6.6.0 BPMN用户指南》

1. 入门
2. 配置
3 The Flowable API
4 Flowable 6.6.0 BPMN用户指南 - (4)Spring集成
5 Spring Boot
6 部署
7 BPMN 2.0简介
8 BPMN 2.0的构造
9 表单(Forms)
10 流程实例迁移
11 JPA
12 历史(History)
13 身份管理(Identity management)
14 REST API
15 CDI集成
16 LDAP集成
17 高级用例

有关Flowable的更多文档,参见:

《Flowable文档大全》


17.7 高级查询API:运行时和历史任务查询之间的无缝切换

One core component of any BPM user interface is the task list. Typically, end users work on open, runtime tasks, filtering their inbox with various setting. Often also the historic tasks need to be displayed in those lists, with similar filtering. To make that code-wise easier, the TaskQuery and HistoricTaskInstanceQuery both have a shared parent interface, which contains all common operations (and most of the operations are common).

This common interface is the org.flowable.engine.task.TaskInfoQuery class. Both org.flowable.engine.task.Task and org.flowable.engine.task.HistoricTaskInstance have a common superclass org.flowable.engine.task.TaskInfo (with common properties) which is returned from e.g. the list() method. However, Java generics are sometimes more harming than helping: if you want to use the TaskInfoQuery type directly, it would look like this:
TaskInfoQuery<? extends TaskInfoQuery<?,?>, ? extends TaskInfo> taskInfoQuery
Ugh, Right. To ‘solve’ this, a org.flowable.engine.task.TaskInfoQueryWrapper class that can be used to avoid the generics (the following code could come from REST code that returns a task list where the user can switch between open and completed tasks):

任何BPM用户界面的一个核心组件是任务列表。通常,最终用户处理打开的运行时任务,使用各种设置过滤收件箱。通常,历史任务也需要通过类似的过滤显示在那些列表中。为了使代码更简单,TaskQuery 和HistoricTaskInstanceQuery 都有一个共享的父接口,其中包含所有常用操作(大多数操作都是通用的)。

这个公共接口是 org.flowable.engine.task.TaskInfoQuery类。org.flowable.engine.task.Task和org.flowable.engine.task.HistoricTaskInstance 都有一个共同的超类org.flowable.engine.task.TaskInfo(具有公共属性),它是从类似list()方法返回的。但是,Java泛型有时弊大于利:如果您想直接使用TaskInfoQuery 类型,它应该如下所示:

TaskInfoQuery<? extends TaskInfoQuery<?,?>, ? extends TaskInfo> taskInfoQuery
为了“解决”这个问题,可用org.flowable.engine.task.TaskInfoQueryWrapper类来避免泛型(以下代码可来自REST代码,该代码返回任务列表,用户可以在开放的任务和已完成的任务之间切换):

TaskInfoQueryWrapper taskInfoQueryWrapper = null;
if (runtimeQuery) {
    taskInfoQueryWrapper = new TaskInfoQueryWrapper(taskService.createTaskQuery());
} else {
    taskInfoQueryWrapper = new TaskInfoQueryWrapper(historyService.createHistoricTaskInstanceQuery());
}

List<? extends TaskInfo> taskInfos = taskInfoQueryWrapper.getTaskInfoQuery().or()
    .taskNameLike("%k1%")
    .taskDueAfter(new Date(now.getTime() + (3 * 24L * 60L * 60L * 1000L)))
.endOr()
.list();

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

月满闲庭

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值