目前只有camunda专有
使用场景
在实际项目开发中,可以将个人常用的一些任务查询操作保存起来,这样可以根据某个人查询到该人常用的一些查询操作。
我们将上述行为称为个人查询偏好,Camunda有一个filterService专门用来处理个人查询偏好操作。
创建及注意事项
/**
* insert into ACT_RU_FILTER (ID_, RESOURCE_TYPE_, NAME_, OWNER_, QUERY_, PROPERTIES_, REV_) values ( ?, ?, ?, ?, ?, ?, 1 )
*/
@Test
public void saveFilter(){
TaskQuery taskQuery = taskService.createTaskQuery().taskAssignee("关羽");
Map<String,Object> properties = new HashMap<>();
properties.put("guanyu","guangyu");
Filter filter = filterService.newTaskFilter()
.setName("关羽") //注意 null or "" 会报错
.setOwner("关羽")
.setQuery(taskQuery) // null 会报错
.setProperties(properties);
filterService.saveFilter(filter);
}
过滤器查询
@Test
public void getFilter(){
Filter filter = filterService.getFilter("3901");
}
过滤器继承
@Test
public void extend(){
Filter filter = filterService.getFilter("3901");
TaskQuery taskQuery = taskService.createTaskQuery()
.taskName("关二爷")
.taskCandidateUser("关羽");
Filter extend = filter.extend(taskQuery);
filterService.saveFilter(extend);
}
过滤器查询对象使用
/**
* select distinct RES.REV_, RES.ID_, RES.NAME_, RES.PARENT_TASK_ID_, RES.DESCRIPTION_, RES.PRIORITY_, RES.CREATE_TIME_, RES.OWNER_, RES.ASSIGNEE_, RES.DELEGATION_, RES.EXECUTION_ID_, RES.PROC_INST_ID_, RES.PROC_DEF_ID_, RES.CASE_EXECUTION_ID_, RES.CASE_INST_ID_, RES.CASE_DEF_ID_, RES.TASK_DEF_KEY_, RES.DUE_DATE_, RES.FOLLOW_UP_DATE_, RES.SUSPENSION_STATE_, RES.TENANT_ID_
* from ACT_RU_TASK RES inner join ACT_RU_IDENTITYLINK I on I.TASK_ID_ = RES.ID_
* WHERE ( 1 = 1 and UPPER(RES.NAME_) = UPPER(?) and RES.ASSIGNEE_ = ? and ( RES.ASSIGNEE_ is null and I.TYPE_ = 'candidate' and ( I.USER_ID_ = ? ) ) )
* order by RES.ID_ asc LIMIT ? OFFSET ?
*/
@Test
public void query() {
Filter filter = filterService.getFilter("4001");
ServiceImpl serviceImpl = (ServiceImpl) this.filterService;
serviceImpl.getCommandExecutor().execute((Command<Object>) commandContext -> {
TaskQuery query = filter.getQuery() ;
return query.list();
});
}
过滤器删除
@Test
public void delete() {
filterService.deleteFilter("3901");
}