Java Code Examples for org.activiti.engine.history.HistoricTaskInstance#getProcessInstanceId()
The following examples show how to use
org.activiti.engine.history.HistoricTaskInstance#getProcessInstanceId() .
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: PermissionService.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
/** * Check if the given user is allowed to read the task. */ public HistoricTaskInstance validateReadPermissionOnTask(User user, String taskId) { List<HistoricTaskInstance> tasks = historyService.createHistoricTaskInstanceQuery().taskId(taskId).taskInvolvedUser(String.valueOf(user.getId())).list(); if (CollectionUtils.isNotEmpty(tasks)) { return tasks.get(0); } // Task is maybe accessible through groups of user HistoricTaskInstanceQuery historicTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery(); historicTaskInstanceQuery.taskId(taskId); List<String> groupIds = getGroupIdsForUser(user); if (!groupIds.isEmpty()) { historicTaskInstanceQuery.taskCandidateGroupIn(getGroupIdsForUser(user)); } tasks = historicTaskInstanceQuery.list(); if (CollectionUtils.isNotEmpty(tasks)) { return tasks.get(0); } // Last resort: user has access to proc inst -> can see task tasks = historyService.createHistoricTaskInstanceQuery().taskId(taskId).list(); if (CollectionUtils.isNotEmpty(tasks)) { HistoricTaskInstance task = tasks.get(0); if (task != null && task.getProcessInstanceId() != null) { boolean hasReadPermissionOnProcessInstance = hasReadPermissionOnProcessInstance(user, task.getProcessInstanceId()); if (hasReadPermissionOnProcessInstance) { return task; } } } throw new NotPermittedException("User is not allowed to work with task " + taskId); }
Example 2
Source File: PurchaseApplyUserInnerServiceSMOImpl.java From MicroCommunity with Apache License 2.0 | 5 votes |
/** * 获取用户审批的任务 * * @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 3
Source File: ComplaintUserInnerServiceSMOImpl.java From MicroCommunity with Apache License 2.0 | 5 votes |
/** * 获取用户审批的任务 * * @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 4
Source File: Task.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
public Task(HistoricTaskInstance taskInstance) { this.id = taskInstance.getId(); this.processId = taskInstance.getProcessInstanceId(); this.processDefinitionId = taskInstance.getProcessDefinitionId(); this.activityDefinitionId = taskInstance.getTaskDefinitionKey(); this.name = taskInstance.getName(); this.description = taskInstance.getDescription(); this.dueAt = taskInstance.getDueDate(); this.startedAt = taskInstance.getStartTime(); this.endedAt = taskInstance.getEndTime(); this.durationInMs = taskInstance.getDurationInMillis(); this.priority = taskInstance.getPriority(); this.owner = taskInstance.getOwner(); this.assignee = taskInstance.getAssignee(); this.formResourceKey = taskInstance.getFormKey(); if (taskInstance.getEndTime() != null) { this.state = TaskStateTransition.COMPLETED.name().toLowerCase(); } else if (taskInstance.getAssignee() != null) { this.state = TaskStateTransition.CLAIMED.name().toLowerCase(); } else { this.state = TaskStateTransition.UNCLAIMED.name().toLowerCase(); } }
Example 5
Source File: TasksImpl.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override public Item getItem(String taskId, String itemId) { HistoricTaskInstance task = getValidHistoricTask(taskId); if (task.getProcessInstanceId() == null) { throw new UnsupportedResourceOperationException("Task is not part of process, no items available."); } return getItemFromProcess(itemId, task.getProcessInstanceId()); }
Example 6
Source File: TasksImpl.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override public CollectionWithPagingInfo<Item> getItems(String taskId, Paging paging) { HistoricTaskInstance task = getValidHistoricTask(taskId); if (task.getProcessInstanceId() == null) { throw new UnsupportedResourceOperationException("Task is not part of process, no items available."); } return getItemsFromProcess(task.getProcessInstanceId(), paging); }
Example 7
Source File: ActivitiTaskFormService.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public FormDefinition getTaskForm(String taskId) { HistoricTaskInstance task = permissionService.validateReadPermissionOnTask(SecurityUtils.getCurrentUserObject(), taskId); Map<String, Object> variables = new HashMap<String, Object>(); if (task.getProcessInstanceId() != null) { List<HistoricVariableInstance> variableInstances = historyService.createHistoricVariableInstanceQuery() .processInstanceId(task.getProcessInstanceId()) .list(); for (HistoricVariableInstance historicVariableInstance : variableInstances) { variables.put(historicVariableInstance.getVariableName(), historicVariableInstance.getValue()); } } String parentDeploymentId = null; if (StringUtils.isNotEmpty(task.getProcessDefinitionId())) { try { ProcessDefinition processDefinition = repositoryService.getProcessDefinition(task.getProcessDefinitionId()); parentDeploymentId = processDefinition.getDeploymentId(); } catch (ActivitiException e) { logger.error("Error getting process definition " + task.getProcessDefinitionId(), e); } } FormDefinition formDefinition = null; if (task.getEndTime() != null) { formDefinition = formService.getCompletedTaskFormDefinitionByKeyAndParentDeploymentId(task.getFormKey(), parentDeploymentId, taskId, task.getProcessInstanceId(), variables, task.getTenantId()); } else { formDefinition = formService.getTaskFormDefinitionByKeyAndParentDeploymentId(task.getFormKey(), parentDeploymentId, task.getProcessInstanceId(), variables, task.getTenantId()); } // If form does not exists, we don't want to leak out this info to just anyone if (formDefinition == null) { throw new NotFoundException("Form definition for task " + task.getTaskDefinitionKey() + " cannot be found for form key " + task.getFormKey()); } return formDefinition; }