目前只有camunda专有

使用场景

  1. 在实际项目开发中,可以将个人常用的一些任务查询操作保存起来,这样可以根据某个人查询到该人常用的一些查询操作。
  2. 我们将上述行为称为个人查询偏好,Camunda有一个filterService专门用来处理个人查询偏好操作。

创建及注意事项

  1. /**
  2. * insert into ACT_RU_FILTER (ID_, RESOURCE_TYPE_, NAME_, OWNER_, QUERY_, PROPERTIES_, REV_) values ( ?, ?, ?, ?, ?, ?, 1 )
  3. */
  4. @Test
  5. public void saveFilter(){
  6. TaskQuery taskQuery = taskService.createTaskQuery().taskAssignee("关羽");
  7. Map<String,Object> properties = new HashMap<>();
  8. properties.put("guanyu","guangyu");
  9. Filter filter = filterService.newTaskFilter()
  10. .setName("关羽") //注意 null or "" 会报错
  11. .setOwner("关羽")
  12. .setQuery(taskQuery) // null 会报错
  13. .setProperties(properties);
  14. filterService.saveFilter(filter);
  15. }

过滤器查询

  1. @Test
  2. public void getFilter(){
  3. Filter filter = filterService.getFilter("3901");
  4. }

过滤器继承

  1. @Test
  2. public void extend(){
  3. Filter filter = filterService.getFilter("3901");
  4. TaskQuery taskQuery = taskService.createTaskQuery()
  5. .taskName("关二爷")
  6. .taskCandidateUser("关羽");
  7. Filter extend = filter.extend(taskQuery);
  8. filterService.saveFilter(extend);
  9. }

过滤器查询对象使用

  1. /**
  2. * 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_
  3. * from ACT_RU_TASK RES inner join ACT_RU_IDENTITYLINK I on I.TASK_ID_ = RES.ID_
  4. * WHERE ( 1 = 1 and UPPER(RES.NAME_) = UPPER(?) and RES.ASSIGNEE_ = ? and ( RES.ASSIGNEE_ is null and I.TYPE_ = 'candidate' and ( I.USER_ID_ = ? ) ) )
  5. * order by RES.ID_ asc LIMIT ? OFFSET ?
  6. */
  7. @Test
  8. public void query() {
  9. Filter filter = filterService.getFilter("4001");
  10. ServiceImpl serviceImpl = (ServiceImpl) this.filterService;
  11. serviceImpl.getCommandExecutor().execute((Command<Object>) commandContext -> {
  12. TaskQuery query = filter.getQuery() ;
  13. return query.list();
  14. });
  15. }

过滤器删除

  1. @Test
  2. public void delete() {
  3. filterService.deleteFilter("3901");
  4. }