org.activiti.engine.history.HistoricTaskInstanceQuery Java Examples

The following examples show how to use org.activiti.engine.history.HistoricTaskInstanceQuery. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HistoricTaskInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public HistoricTaskInstanceQuery taskCandidateGroup(String candidateGroup) {
  if (candidateGroup == null) {
    throw new ActivitiIllegalArgumentException("Candidate group is null");
  }
  
  if (candidateGroups != null) {
    throw new ActivitiIllegalArgumentException("Invalid query usage: cannot set both candidateGroup and candidateGroupIn");
  }

  if (inOrStatement) {
    this.currentOrQueryObject.candidateGroup = candidateGroup;
  } else {
    this.candidateGroup = candidateGroup;
  }
  return this;
}
 
Example #2
Source File: ActivitiWorkflowEngine.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void addProcessPropertiesToQuery(Map<QName, Object> processCustomProps, 
            HistoricTaskInstanceQuery taskQuery) 
{
    for(Entry<QName, Object> customProperty : processCustomProps.entrySet()) 
    {
        String name =factory.mapQNameToName(customProperty.getKey());
        
        // Exclude the special "VAR_TENANT_DOMAIN" variable, this cannot be queried by users
        if(name != ActivitiConstants.VAR_TENANT_DOMAIN)
        {
            // Perform minimal property conversions
            Object converted = propertyConverter.convertPropertyToValue(customProperty.getValue());
            taskQuery.processVariableValueEquals(name, converted);
        }
    }
}
 
Example #3
Source File: HistoricTaskInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public HistoricTaskInstanceQuery processCategoryNotIn(List<String> processCategoryNotInList) {
    if (processCategoryNotInList == null) {
        throw new ActivitiIllegalArgumentException("Process category list is null");
    }
    if (processCategoryNotInList.isEmpty()) {
        throw new ActivitiIllegalArgumentException("Process category list is empty");
    }
    for (String processCategory : processCategoryNotInList) {
        if (processCategory == null) {
            throw new ActivitiIllegalArgumentException("None of the given process categories can be null");
        }
    }

    if (inOrStatement) {
        currentOrQueryObject.processCategoryNotInList = processCategoryNotInList;
    } else {
        this.processCategoryNotInList = processCategoryNotInList;
    }
    return this;
}
 
Example #4
Source File: HistoricTaskInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Override
public HistoricTaskInstanceQuery processCategoryIn(List<String> processCategoryInList) {
  if (processCategoryInList == null) {
    throw new ActivitiIllegalArgumentException("Process category list is null");
  }
  if (processCategoryInList.isEmpty()) {
    throw new ActivitiIllegalArgumentException("Process category list is empty");
  }
  for (String processCategory : processCategoryInList) {
    if (processCategory == null) {
      throw new ActivitiIllegalArgumentException("None of the given process categories can be null");
    }
  }

  if(inOrStatement) {
    currentOrQueryObject.processCategoryInList = processCategoryInList;
  } else {
    this.processCategoryInList = processCategoryInList;
  }
  return this;
}
 
Example #5
Source File: HistoricTaskInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public HistoricTaskInstanceQuery taskNameIn(List<String> taskNameList) {
    if (taskNameList == null) {
        throw new ActivitiIllegalArgumentException("Task name list is null");
    }
    if (taskNameList.isEmpty()) {
        throw new ActivitiIllegalArgumentException("Task name list is empty");
    }

    if (taskName != null) {
        throw new ActivitiIllegalArgumentException("Invalid query usage: cannot set both taskNameIn and taskName");
    }
    if (taskNameLike != null) {
        throw new ActivitiIllegalArgumentException("Invalid query usage: cannot set both taskNameIn and taskNameLike");
    }
    if (taskNameLikeIgnoreCase != null) {
        throw new ActivitiIllegalArgumentException("Invalid query usage: cannot set both taskNameIn and taskNameLikeIgnoreCase");
    }

    if (inOrStatement) {
        currentOrQueryObject.taskNameList = taskNameList;
    } else {
        this.taskNameList = taskNameList;
    }
    return this;
}
 
Example #6
Source File: PurchaseApplyUserInnerServiceSMOImpl.java    From MicroCommunity with Apache License 2.0 6 votes vote down vote up
/**
     * 查询用户任务数
     *
     * @param user
     * @return
     */
    public long getUserHistoryTaskCount(@RequestBody AuditUser user) {
        HistoryService historyService = processEngine.getHistoryService();
//        Query query = historyService.createHistoricTaskInstanceQuery()
//                .processDefinitionKey("complaint")
//                .taskAssignee(user.getUserId());

        HistoricTaskInstanceQuery historicTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
                .processDefinitionKey("resourceEnter")
                .taskAssignee(user.getUserId());
        if (!StringUtil.isEmpty(user.getAuditLink()) && "START".equals(user.getAuditLink())) {
            historicTaskInstanceQuery.taskName("resourceEnter");
        } else if (!StringUtil.isEmpty(user.getAuditLink()) && "AUDIT".equals(user.getAuditLink())) {
            historicTaskInstanceQuery.taskName("resourceEnterDealUser");
        }

        Query query = historicTaskInstanceQuery;
        return query.count();
    }
 
Example #7
Source File: HistoricTaskInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public HistoricTaskInstanceQuery taskCandidateGroup(String candidateGroup) {
    if (candidateGroup == null) {
        throw new ActivitiIllegalArgumentException("Candidate group is null");
    }

    if (candidateGroups != null) {
        throw new ActivitiIllegalArgumentException("Invalid query usage: cannot set both candidateGroup and candidateGroupIn");
    }

    if (inOrStatement) {
        this.currentOrQueryObject.candidateGroup = candidateGroup;
    } else {
        this.candidateGroup = candidateGroup;
    }
    return this;
}
 
Example #8
Source File: HistoricTaskInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public HistoricTaskInstanceQuery processCategoryIn(List<String> processCategoryInList) {
    if (processCategoryInList == null) {
        throw new ActivitiIllegalArgumentException("Process category list is null");
    }
    if (processCategoryInList.isEmpty()) {
        throw new ActivitiIllegalArgumentException("Process category list is empty");
    }
    for (String processCategory : processCategoryInList) {
        if (processCategory == null) {
            throw new ActivitiIllegalArgumentException("None of the given process categories can be null");
        }
    }

    if (inOrStatement) {
        currentOrQueryObject.processCategoryInList = processCategoryInList;
    } else {
        this.processCategoryInList = processCategoryInList;
    }
    return this;
}
 
Example #9
Source File: HistoryServiceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = { "org/activiti5/engine/test/api/oneTaskProcess.bpmn20.xml", "org/activiti5/engine/test/api/runtime/oneTaskProcess2.bpmn20.xml" })
public void testHistoricTaskInstanceQueryByDeploymentId() {
  org.activiti.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery().singleResult();
  HashSet<String> processInstanceIds = new HashSet<String>();
  for (int i = 0; i < 4; i++) {
    processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess", i + "").getId());
  }
  processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess2", "1").getId());

  HistoricTaskInstanceQuery taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().deploymentId(deployment.getId());
  assertEquals(5, taskInstanceQuery.count());

  List<HistoricTaskInstance> taskInstances = taskInstanceQuery.list();
  assertNotNull(taskInstances);
  assertEquals(5, taskInstances.size());
  
  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().deploymentId("invalid");
  assertEquals(0, taskInstanceQuery.count());
}
 
Example #10
Source File: HistoricTaskAndVariablesQueryTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Deployment
public void testOrQueryMultipleVariableValues() {
  if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
    Map<String, Object> startMap = new HashMap<String, Object>();
    startMap.put("processVar", true);
    startMap.put("anotherProcessVar", 123);
    runtimeService.startProcessInstanceByKey("oneTaskProcess", startMap);

    startMap.put("anotherProcessVar", 999);
    runtimeService.startProcessInstanceByKey("oneTaskProcess", startMap);

    HistoricTaskInstanceQuery query0 = historyService.createHistoricTaskInstanceQuery().includeProcessVariables().or();
    for (int i = 0; i < 20; i++) {
      query0 = query0.processVariableValueEquals("anotherProcessVar", i);
    }
    query0 = query0.endOr();
    assertNull(query0.singleResult());

    HistoricTaskInstanceQuery query1 = historyService.createHistoricTaskInstanceQuery().includeProcessVariables().or().processVariableValueEquals("anotherProcessVar", 123);
    for (int i = 0; i < 20; i++) {
      query1 = query1.processVariableValueEquals("anotherProcessVar", i);
    }
    query1 = query1.endOr();
    HistoricTaskInstance task = query1.singleResult();
    assertEquals(2, task.getProcessVariables().size());
    assertEquals(true, task.getProcessVariables().get("processVar"));
    assertEquals(123, task.getProcessVariables().get("anotherProcessVar"));
  }
}
 
Example #11
Source File: HistoricTaskInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public HistoricTaskInstanceQuery processVariableValueGreaterThanOrEqual(String name, Object value) {
    if (inOrStatement) {
        currentOrQueryObject.variableValueGreaterThanOrEqual(name, value, false);
        return this;
    } else {
        return variableValueGreaterThanOrEqual(name, value, false);
    }
}
 
Example #12
Source File: HistoricTaskInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public HistoricTaskInstanceQuery taskCompletedBefore(Date completedBeforeDate) {
    if (inOrStatement) {
        this.currentOrQueryObject.completedBeforeDate = completedBeforeDate;
    } else {
        this.completedBeforeDate = completedBeforeDate;
    }
    return this;
}
 
Example #13
Source File: HistoricTaskInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public HistoricTaskInstanceQuery deploymentIdIn(List<String> deploymentIds) {
    if (inOrStatement) {
        currentOrQueryObject.deploymentIds = deploymentIds;
    } else {
        this.deploymentIds = deploymentIds;
    }
    return this;
}
 
Example #14
Source File: HistoryServiceTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml", "org/activiti/engine/test/api/runtime/oneTaskProcess2.bpmn20.xml" })
public void testHistoricTaskInstanceOrQueryByDeploymentIdIn() {
  org.activiti.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery().singleResult();
  HashSet<String> processInstanceIds = new HashSet<String>();
  for (int i = 0; i < 4; i++) {
    processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess", i + "").getId());
  }
  processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess2", "1").getId());

  List<String> deploymentIds = new ArrayList<String>();
  deploymentIds.add(deployment.getId());
  HistoricTaskInstanceQuery taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().deploymentIdIn(deploymentIds).processDefinitionId("invalid").endOr();
  assertEquals(5, taskInstanceQuery.count());

  List<HistoricTaskInstance> taskInstances = taskInstanceQuery.list();
  assertNotNull(taskInstances);
  assertEquals(5, taskInstances.size());

  deploymentIds.add("invalid");
  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().deploymentIdIn(deploymentIds).processDefinitionId("invalid").endOr();
  assertEquals(5, taskInstanceQuery.count());

  deploymentIds = new ArrayList<String>();
  deploymentIds.add("invalid");
  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().deploymentIdIn(deploymentIds).processDefinitionId("invalid").endOr();
  assertEquals(0, taskInstanceQuery.count());

  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().taskDefinitionKey("theTask").deploymentIdIn(deploymentIds).endOr();
  assertEquals(5, taskInstanceQuery.count());

  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().taskDefinitionKey("theTask").or().deploymentIdIn(deploymentIds).endOr();
  assertEquals(0, taskInstanceQuery.count());
}
 
Example #15
Source File: PurchaseApplyUserInnerServiceSMOImpl.java    From MicroCommunity with Apache License 2.0 5 votes vote down vote up
/**
     * 获取用户审批的任务
     *
     * @param user 用户信息
     */
    public List<PurchaseApplyDto> getUserHistoryTasks(@RequestBody AuditUser user) {
        HistoryService historyService = processEngine.getHistoryService();

        HistoricTaskInstanceQuery historicTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
                .processDefinitionKey("resourceEnter")
                .taskAssignee(user.getUserId());
        if (!StringUtil.isEmpty(user.getAuditLink()) && "START".equals(user.getAuditLink())) {
            historicTaskInstanceQuery.taskName("resourceEnter");
        } else if (!StringUtil.isEmpty(user.getAuditLink()) && "AUDIT".equals(user.getAuditLink())) {
            historicTaskInstanceQuery.taskName("resourceEnterDealUser");
        }

        Query query = historicTaskInstanceQuery.orderByHistoricTaskInstanceStartTime().desc();

        List<HistoricTaskInstance> list = null;
        if (user.getPage() != PageDto.DEFAULT_PAGE) {
            list = query.listPage((user.getPage() - 1) * user.getRow(), user.getRow());
        } else {
            list = query.list();
        }

        List<String> complaintIds = new ArrayList<>();
        for (HistoricTaskInstance task : list) {
            String processInstanceId = task.getProcessInstanceId();
            //3.使用流程实例,查询
            HistoricProcessInstance pi = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
            //4.使用流程实例对象获取BusinessKey
            String business_key = pi.getBusinessKey();
            complaintIds.add(business_key);
        }

        //查询 投诉信息
//        ComplaintDto complaintDto = new ComplaintDto();
//        complaintDto.setStoreId(user.getStoreId());
//        complaintDto.setCommunityId(user.getCommunityId());
//        complaintDto.setComplaintIds(complaintIds.toArray(new String[complaintIds.size()]));
//        List<ComplaintDto> tmpComplaintDtos = complaintInnerServiceSMOImpl.queryComplaints(complaintDto);
        return null;
    }
 
Example #16
Source File: HistoricTaskInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public HistoricTaskInstanceQuery taskTenantIdLike(String tenantIdLike) {
	if (tenantIdLike == null) {
		throw new ActivitiIllegalArgumentException("task tenant id is null");
	}
	if (inOrStatement) {
    this.currentOrQueryObject.tenantIdLike = tenantIdLike;
  } else {
    this.tenantIdLike = tenantIdLike;
  }
  return this;
}
 
Example #17
Source File: ComplaintUserInnerServiceSMOImpl.java    From MicroCommunity with Apache License 2.0 5 votes vote down vote up
/**
 * 获取用户审批的任务
 *
 * @param user 用户信息
 */
public List<ComplaintDto> getUserHistoryTasks(@RequestBody AuditUser user) {
    HistoryService historyService = processEngine.getHistoryService();

    HistoricTaskInstanceQuery historicTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
            .processDefinitionKey(getWorkflowDto(user.getCommunityId()))
            .taskAssignee(user.getUserId());
    if (!StringUtil.isEmpty(user.getAuditLink()) && "START".equals(user.getAuditLink())) {
        historicTaskInstanceQuery.taskName("complaint");
    } else if (!StringUtil.isEmpty(user.getAuditLink()) && "AUDIT".equals(user.getAuditLink())) {
        historicTaskInstanceQuery.taskName("complaitDealUser");
    }

    Query query = historicTaskInstanceQuery.orderByHistoricTaskInstanceStartTime().desc();

    List<HistoricTaskInstance> list = null;
    if (user.getPage() != PageDto.DEFAULT_PAGE) {
        list = query.listPage((user.getPage() - 1) * user.getRow(), user.getRow());
    } else {
        list = query.list();
    }

    List<String> complaintIds = new ArrayList<>();
    for (HistoricTaskInstance task : list) {
        String processInstanceId = task.getProcessInstanceId();
        //3.使用流程实例,查询
        HistoricProcessInstance pi = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
        //4.使用流程实例对象获取BusinessKey
        String business_key = pi.getBusinessKey();
        complaintIds.add(business_key);
    }

    //查询 投诉信息
    ComplaintDto complaintDto = new ComplaintDto();
    complaintDto.setStoreId(user.getStoreId());
    complaintDto.setCommunityId(user.getCommunityId());
    complaintDto.setComplaintIds(complaintIds.toArray(new String[complaintIds.size()]));
    List<ComplaintDto> tmpComplaintDtos = complaintInnerServiceSMOImpl.queryComplaints(complaintDto);
    return tmpComplaintDtos;
}
 
Example #18
Source File: HistoricTaskInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public HistoricTaskInstanceQuery taskInvolvedGroupsIn(List<String> involvedGroups) {
  if (involvedGroups == null || involvedGroups.isEmpty()) {
    throw new ActivitiIllegalArgumentException("Involved groups list is null or empty.");
  }

  if (inOrStatement) {
    this.currentOrQueryObject.involvedGroups = involvedGroups;
  } else {
    this.involvedGroups = involvedGroups;
  }
  return this;
}
 
Example #19
Source File: HistoricTaskInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public HistoricTaskInstanceQuery taskTenantId(String tenantId) {
	if (tenantId == null) {
		throw new ActivitiIllegalArgumentException("task tenant id is null");
	}
	if (inOrStatement) {
    this.currentOrQueryObject.tenantId = tenantId;
  } else {
    this.tenantId = tenantId;
  }
  return this;
}
 
Example #20
Source File: HistoricTaskInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public HistoricTaskInstanceQuery taskInvolvedUser(String involvedUser) {
  if (inOrStatement) {
    this.currentOrQueryObject.involvedUser = involvedUser;
  } else {
    this.involvedUser = involvedUser;
  }
  return this;
}
 
Example #21
Source File: HistoricTaskInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public HistoricTaskInstanceQuery taskCategory(String category) {
  if (inOrStatement) {
    this.currentOrQueryObject.category = category;
  } else {
    this.category = category;
  }
  return this;
}
 
Example #22
Source File: HistoricTaskInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public HistoricTaskInstanceQuery withoutTaskDueDate() {
  if (inOrStatement) {
    this.currentOrQueryObject.withoutDueDate = true;
  } else {
    this.withoutDueDate = true;
  }
  return this;
}
 
Example #23
Source File: HistoricTaskInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public HistoricTaskInstanceQuery taskCompletedBefore(Date completedBeforeDate) {
  if (inOrStatement) {
    this.currentOrQueryObject.completedBeforeDate = completedBeforeDate;
  } else {
    this.completedBeforeDate = completedBeforeDate;
  }
  return this;
}
 
Example #24
Source File: ActivitiUtil.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @param localId String
 * @return HistoricTaskInstance
 */
public HistoricTaskInstance getHistoricTaskInstance(String localId)
{
    HistoricTaskInstanceQuery taskQuery =  historyService.createHistoricTaskInstanceQuery()
        .taskId(localId);
    if(!deployWorkflowsInTenant) {
    	taskQuery.processVariableValueEquals(ActivitiConstants.VAR_TENANT_DOMAIN, TenantUtil.getCurrentDomain());
    }
    return taskQuery.singleResult();
}
 
Example #25
Source File: HistoricTaskInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public HistoricTaskInstanceQuery taskCreatedAfter(Date creationAfterDate) {
  if (inOrStatement) {
    this.currentOrQueryObject.creationAfterDate = creationAfterDate;
  } else {
    this.creationAfterDate = creationAfterDate;
  }
  return this;
}
 
Example #26
Source File: HistoricTaskInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public HistoricTaskInstanceQuery taskInvolvedUser(String involvedUser) {
    if (inOrStatement) {
        this.currentOrQueryObject.involvedUser = involvedUser;
    } else {
        this.involvedUser = involvedUser;
    }
    return this;
}
 
Example #27
Source File: HistoricTaskInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public HistoricTaskInstanceQuery taskVariableValueEquals(Object variableValue) {
    if (inOrStatement) {
        currentOrQueryObject.variableValueEquals(variableValue);
        return this;
    } else {
        return variableValueEquals(variableValue);
    }
}
 
Example #28
Source File: HistoricTaskInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public HistoricTaskInstanceQuery taskDueDate(Date dueDate) {
  if (inOrStatement) {
    this.currentOrQueryObject.dueDate = dueDate;
  } else {
    this.dueDate = dueDate;
  }
  return this;
}
 
Example #29
Source File: HistoricTaskInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public HistoricTaskInstanceQuery processFinished() {
  if (inOrStatement) {
    this.currentOrQueryObject.processFinished = true;
  } else {
    this.processFinished = true;
  }
  return this;
}
 
Example #30
Source File: HistoricTaskInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public HistoricTaskInstanceQuery processVariableValueLikeIgnoreCase(String name, String value) {
  if (inOrStatement) {
    currentOrQueryObject.variableValueLikeIgnoreCase(name, value, false);
    return this;
  } else {
    return variableValueLikeIgnoreCase(name, value, false);
  }
}