protected void acceptTaskFormData(Task task, Map<String, Object> formData) { formData.put("processTaskId", task.getId()); formData.put("processTaskDefineKey", task.getTaskDefinitionKey()); formData.put("processTaskName", task.getName()); }
@Override public void deleteCandidateGroups(CandidateGroupsPayload candidateGroupsPayload) { org.activiti.engine.task.Task internalTask; try { internalTask = taskRuntimeHelper.getInternalTaskWithChecks(candidateGroupsPayload.getTaskId()); } catch (IllegalStateException ex) { throw new IllegalStateException("The authenticated user cannot update the task" + candidateGroupsPayload.getTaskId() + " due it is not the current assignee"); } String authenticatedUserId = securityManager.getAuthenticatedUserId(); // validate that you are trying to add CandidateGroups to the task where you are the assignee if (!Objects.equals(internalTask.getAssignee(), authenticatedUserId)) { throw new IllegalStateException("You cannot update a task where you are not the assignee"); } if (candidateGroupsPayload.getCandidateGroups() != null && !candidateGroupsPayload.getCandidateGroups().isEmpty()) { for (String g : candidateGroupsPayload.getCandidateGroups()) { taskService.deleteCandidateGroup(internalTask.getId(), g); } } }
@Override public void addCandidateUsers(CandidateUsersPayload candidateUsersPayload) { org.activiti.engine.task.Task internalTask; try { internalTask = taskRuntimeHelper.getInternalTaskWithChecks(candidateUsersPayload.getTaskId()); } catch (IllegalStateException ex) { throw new IllegalStateException("The authenticated user cannot update the task" + candidateUsersPayload.getTaskId() + " due it is not the current assignee"); } String authenticatedUserId = securityManager.getAuthenticatedUserId(); // validate that you are trying to add CandidateUsers to the task where you are the assignee if (!Objects.equals(internalTask.getAssignee(), authenticatedUserId)) { throw new IllegalStateException("You cannot update a task where you are not the assignee"); } if (candidateUsersPayload.getCandidateUsers() != null && !candidateUsersPayload.getCandidateUsers().isEmpty()) { for (String u : candidateUsersPayload.getCandidateUsers()) { taskService.addCandidateUser(internalTask.getId(), u); } } }
@Override public void deleteCandidateUsers(CandidateUsersPayload candidateUsersPayload) { org.activiti.engine.task.Task internalTask; try { internalTask = taskRuntimeHelper.getInternalTaskWithChecks(candidateUsersPayload.getTaskId()); } catch (IllegalStateException ex) { throw new IllegalStateException("The authenticated user cannot update the task" + candidateUsersPayload.getTaskId() + " due it is not the current assignee"); } String authenticatedUserId = securityManager.getAuthenticatedUserId(); // validate that you are trying to add CandidateUsers to the task where you are the assignee if (!Objects.equals(internalTask.getAssignee(), authenticatedUserId)) { throw new IllegalStateException("You cannot update a task where you are not the assignee"); } if (candidateUsersPayload.getCandidateUsers() != null && !candidateUsersPayload.getCandidateUsers().isEmpty()) { for (String u : candidateUsersPayload.getCandidateUsers()) { taskService.deleteCandidateUser(internalTask.getId(), u); } } }
@Override public void addCandidateGroups(CandidateGroupsPayload candidateGroupsPayload) { org.activiti.engine.task.Task internalTask; try { internalTask = taskRuntimeHelper.getInternalTaskWithChecks(candidateGroupsPayload.getTaskId()); } catch (IllegalStateException ex) { throw new IllegalStateException("The authenticated user cannot update the task" + candidateGroupsPayload.getTaskId() + " due it is not the current assignee"); } String authenticatedUserId = securityManager.getAuthenticatedUserId(); // validate that you are trying to add CandidateGroups to the task where you are the assignee if (!Objects.equals(internalTask.getAssignee(), authenticatedUserId)) { throw new IllegalStateException("You cannot update a task where you are not the assignee"); } if (candidateGroupsPayload.getCandidateGroups() != null && !candidateGroupsPayload.getCandidateGroups().isEmpty()) { for (String g : candidateGroupsPayload.getCandidateGroups()) { taskService.addCandidateGroup(internalTask.getId(), g); } } }
@Override public void setCandidate(String doingUserId, Task task) { if (task == null) { return; } if (task.getTaskDefinitionKey() != null) { //从配置中获取候选人 List<CandidateInfo> candidateInfoList = processConfigurationService .getActivityConfiguration(doingUserId, task.getProcessDefinitionId(), task.getTaskDefinitionKey()) .getCandidateInfo(task); if (CollectionUtils.isEmpty(candidateInfoList)) { logger.warn("任务:{}未能设置候选人,此任务可能无法办理!", task); } else { for (CandidateInfo candidateInfo : candidateInfoList) { Authentication user = candidateInfo.user(); if (user != null) { taskService.addCandidateUser(task.getId(), user.getUser().getId()); } } } } else { logger.warn("未能成功设置环节候选人,task:{}", task); } }
target.put("taskId", t.getId()); target.put("taskName", t.getName()); target.put("activityId", t.getTaskDefinitionKey()); .processDefineId(processInstance.getProcessDefinitionId()) .processInstanceId(processInstance.getProcessInstanceId()) .taskId(task.getId()) .taskDefineKey(task.getTaskDefinitionKey()) .taskName(task.getName())
task.setOwner(securityManager.getAuthenticatedUserId()); taskService.saveTask(task); taskService.addCandidateUser(task.getId(), securityManager.getAuthenticatedUserId()); if (createTaskPayload.getCandidateGroups() != null && !createTaskPayload.getCandidateGroups().isEmpty()) { for (String g : createTaskPayload.getCandidateGroups()) { taskService.addCandidateGroup(task.getId(), g); taskService.addCandidateUser(task.getId(), u);
variable.put("preTaskId", task.getId()); Map<String, Object> transientVariables = new HashMap<>(); taskService.complete(task.getId(), null, transientVariables); setVariablesLocal(next.getId(), variable); if (!StringUtils.isNullOrEmpty(request.getNextClaimUserId())) { taskService.addCandidateUser(next.getId(), request.getNextClaimUserId()); } else { setCandidate(request.getCompleteUserId(), next); .processDefineId(instance.getProcessDefinitionId()) .processInstanceId(instance.getProcessInstanceId()) .taskId(task.getId()) .taskDefineKey(task.getTaskDefinitionKey()) .taskName(task.getName())
public Task from(org.activiti.engine.task.Task internalTask, Task.TaskStatus status) { TaskImpl task = new TaskImpl(internalTask.getId(), internalTask.getName(), status); task.setProcessDefinitionId(internalTask.getProcessDefinitionId()); task.setProcessInstanceId(internalTask.getProcessInstanceId()); task.setAssignee(internalTask.getAssignee()); task.setClaimedDate(internalTask.getClaimTime()); task.setCreatedDate(internalTask.getCreateTime()); task.setDueDate(internalTask.getDueDate()); task.setDescription(internalTask.getDescription()); task.setOwner(internalTask.getOwner()); task.setParentTaskId(internalTask.getParentTaskId()); task.setPriority(internalTask.getPriority()); task.setFormKey(internalTask.getFormKey()); return task; }
taskService.addCandidateUser(task.getId(), request.getNextClaimUserId()); } else { bpmTaskService.setCandidate(request.getCreatorId(), task);
for (IdentityLink link : taskService.getIdentityLinksForTask(task.getId()))
private void checkAndNotify() throws Exception { //检查即将过期的task Date dueDate = DateTime.now().minus(_parsedPeriodInAdvance).toDate(); for (Task task : _processEngine.getTaskService().createTaskQuery().active().dueAfter(dueDate).list()) { //是否已经通知? if (!_taskNotificationManager.isNotified(task.getId())) { //没有通知则现在通知 List<UserDetailsEntity> involvedUsers = IdentityUtils.getUserDetailsFromIds( IdentityUtils.getInvolvedUsers(_processEngine.getTaskService(), task, _membershipManager), _userDetailsManager); if (!involvedUsers.isEmpty()) { _messageNotifier.notify(involvedUsers.toArray(new UserDetailsEntity[0]), task); } //设置标志 _taskNotificationManager.setNotified(task.getId()); Logger.getLogger(getClass()).debug(String.format("notified %s", involvedUsers)); } } }
System.out.println("通过taskId获取流程启动人:" + runtimePageService.getStartUserId(task.getId())); vactionVars.put("startDate", new Date()); vactionVars.put("motivation", "不想上班了,就是这么任性"); taskService.setVariables(task.getId(), vactionVars); taskService.complete(task.getId(), vactionVars); taskService.claim(task1.getId(), approver); List<FormProperty> list = formService.getTaskFormData(task1.getId()).getFormProperties(); if (!list.isEmpty()) { for (FormProperty formProperty : list) { vars.put("suggestion", "拒绝"); taskService.complete(task1.getId(), vars);
Map<String, String> map = getTaskCandidateUser(task.getId()); String userNames = map.get("names"); if (!StrUtil.isEmpty(userNames)) vo.setCanUnclaim(getTaskState(task.getId()) ? "0" : "1"); vo.setStartUserId(runtimePageService.getStartUserId(task.getId())); vo.setStartUserName(identityPageService.getUserNamesByUserIds(vo.getStartUserId())); voList.add(vo);
protected void addLocalVariables(Task task, Map<String, RestVariable> variableMap) { Map<String, Object> rawVariables = taskService.getVariablesLocal(task.getId()); List<RestVariable> localVariables = restResponseFactory.createRestVariables(rawVariables, task.getId(), RestResponseFactory.VARIABLE_TASK, RestVariableScope.LOCAL); for (RestVariable var : localVariables) { variableMap.put(var.getName(), var); } } }
public Result deleteCurrentTaskInstance(String taskId, HistoricTaskInstance taskInstance) { //删除正在执行的任务 //删除HistoricTaskInstance String sql_task = "delete from " + managementService.getTableName(HistoricTaskInstance.class) + " where " + "ID_='" + taskId + "' or ID_='" + taskInstance.getId() + "'"; this.executeSql(sql_task); //删除HistoricActivityInstance String sql_activity = "delete from " + managementService.getTableName(HistoricActivityInstance.class) + " where " + "TASK_ID_='" + taskId + "' or TASK_ID_='" + taskInstance.getId() + "'"; this.executeSql(sql_activity); //获取当前的任务,保存签收人 Task task = taskService.createTaskQuery().executionId(taskInstance.getExecutionId()).singleResult(); task.setAssignee(taskInstance.getAssignee()); task.setOwner(taskInstance.getOwner()); taskService.saveTask(task); //解决HistoricActivityInstance的Assignee为空的现象 if (!StrUtil.isEmpty(taskInstance.getAssignee())) { String sql_update = "update " + managementService.getTableName(HistoricActivityInstance.class) + " set " + "ASSIGNEE_='" + taskInstance.getAssignee() + "' where TASK_ID_='" + task.getId() + "'"; this.executeSql(sql_update); } String sql_update_execution = "update " + managementService.getTableName(Execution.class) + " set " + "ACT_ID_='" + taskInstance.getTaskDefinitionKey() + "' where ID_='" + taskInstance.getExecutionId() + "'"; this.executeSql(sql_update_execution); return new Result(true); }