Java Code Examples for org.activiti.engine.impl.persistence.entity.TaskEntity#getProcessDefinitionId()
The following examples show how to use
org.activiti.engine.impl.persistence.entity.TaskEntity#getProcessDefinitionId() .
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: JsonTaskConverter.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public JSONObject toJsonObject(Task task) { TaskEntity taskEntity = (TaskEntity) task; JSONObject jsonObject = new JSONObject(); jsonObject.put("id", taskEntity.getId()); jsonObject.put("dbversion", taskEntity.getRevision()); jsonObject.put("assignee", taskEntity.getAssignee()); jsonObject.put("name", taskEntity.getName()); jsonObject.put("priority", taskEntity.getPriority()); jsonObject.put("createTime", taskEntity.getCreateTime()); if (taskEntity.getExecutionId() != null) { jsonObject.put("activityInstance", taskEntity.getExecutionId()); } if (taskEntity.getProcessDefinitionId() != null) { jsonObject.put("processDefinition", taskEntity.getProcessDefinitionId()); } return jsonObject; }
Example 2
Source File: SubmitTaskFormCmd.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected Void execute(CommandContext commandContext, TaskEntity task) { // Backwards compatibility if (task.getProcessDefinitionId() != null) { if (Activiti5Util.isActiviti5ProcessDefinitionId(commandContext, task.getProcessDefinitionId())) { Activiti5CompatibilityHandler activiti5CompatibilityHandler = Activiti5Util.getActiviti5CompatibilityHandler(); activiti5CompatibilityHandler.submitTaskFormData(taskId, properties, completeTask); return null; } } commandContext.getHistoryManager().recordFormPropertiesSubmitted(task.getExecution(), properties, taskId); TaskFormHandler taskFormHandler = FormHandlerUtil.getTaskFormHandlder(task); if (taskFormHandler != null) { taskFormHandler.submitFormProperties(properties, task.getExecution()); if (completeTask) { executeTaskComplete(commandContext, task, null, false); } } return null; }
Example 3
Source File: RemoveTaskVariablesCmd.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected Void execute(CommandContext commandContext, TaskEntity task) { if (task.getProcessDefinitionId() != null && Activiti5Util.isActiviti5ProcessDefinitionId(commandContext, task.getProcessDefinitionId())) { Activiti5CompatibilityHandler activiti5CompatibilityHandler = Activiti5Util.getActiviti5CompatibilityHandler(); activiti5CompatibilityHandler.removeTaskVariables(taskId, variableNames, isLocal); return null; } if (isLocal) { task.removeVariablesLocal(variableNames); } else { task.removeVariables(variableNames); } return null; }
Example 4
Source File: DeleteIdentityLinkCmd.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected Void execute(CommandContext commandContext, TaskEntity task) { if (task.getProcessDefinitionId() != null && Activiti5Util.isActiviti5ProcessDefinitionId(commandContext, task.getProcessDefinitionId())) { Activiti5CompatibilityHandler activiti5CompatibilityHandler = Activiti5Util.getActiviti5CompatibilityHandler(); activiti5CompatibilityHandler.deleteIdentityLink(taskId, userId, groupId, type); return null; } if (IdentityLinkType.ASSIGNEE.equals(type)) { commandContext.getTaskEntityManager().changeTaskAssignee(task, null); } else if (IdentityLinkType.OWNER.equals(type)) { commandContext.getTaskEntityManager().changeTaskOwner(task, null); } else { commandContext.getIdentityLinkEntityManager().deleteIdentityLink(task, userId, groupId, type); } commandContext.getHistoryManager().createIdentityLinkComment(taskId, userId, groupId, type, false); return null; }
Example 5
Source File: RollbackTaskCmd.java From lemon with Apache License 2.0 | 6 votes |
/** * 查找回退的目的节点. */ public ActivityImpl findTargetActivity(CommandContext commandContext, TaskEntity taskEntity) { if (activityId == null) { String historyTaskId = this.findNearestUserTask(commandContext); HistoricTaskInstanceEntity historicTaskInstanceEntity = commandContext .getHistoricTaskInstanceEntityManager() .findHistoricTaskInstanceById(historyTaskId); this.activityId = historicTaskInstanceEntity.getTaskDefinitionKey(); } String processDefinitionId = taskEntity.getProcessDefinitionId(); ProcessDefinitionEntity processDefinitionEntity = new GetDeploymentProcessDefinitionCmd( processDefinitionId).execute(commandContext); return processDefinitionEntity.findActivity(activityId); }
Example 6
Source File: AddIdentityLinkCmd.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected Void execute(CommandContext commandContext, TaskEntity task) { if (task.getProcessDefinitionId() != null && Activiti5Util.isActiviti5ProcessDefinitionId(commandContext, task.getProcessDefinitionId())) { Activiti5CompatibilityHandler activiti5CompatibilityHandler = Activiti5Util.getActiviti5CompatibilityHandler(); activiti5CompatibilityHandler.addIdentityLink(taskId, identityId, identityIdType, identityType); return null; } boolean assignedToNoOne = false; if (IdentityLinkType.ASSIGNEE.equals(identityType)) { commandContext.getTaskEntityManager().changeTaskAssignee(task, identityId); assignedToNoOne = identityId == null; } else if (IdentityLinkType.OWNER.equals(identityType)) { commandContext.getTaskEntityManager().changeTaskOwner(task, identityId); } else if (IDENTITY_USER == identityIdType) { task.addUserIdentityLink(identityId, identityType); } else if (IDENTITY_GROUP == identityIdType) { task.addGroupIdentityLink(identityId, identityType); } boolean forceNullUserId = false; if (assignedToNoOne) { // ACT-1317: Special handling when assignee is set to NULL, a // CommentEntity notifying of assignee-delete should be created forceNullUserId = true; } if (IDENTITY_USER == identityIdType) { commandContext.getHistoryManager().createUserIdentityLinkComment(taskId, identityId, identityType, true, forceNullUserId); } else { commandContext.getHistoryManager().createGroupIdentityLinkComment(taskId, identityId, identityType, true); } return null; }
Example 7
Source File: CompleteTaskCmd.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected Void execute(CommandContext commandContext, TaskEntity task) { // Backwards compatibility if (task.getProcessDefinitionId() != null) { if (Activiti5Util.isActiviti5ProcessDefinitionId(commandContext, task.getProcessDefinitionId())) { Activiti5CompatibilityHandler activiti5CompatibilityHandler = Activiti5Util.getActiviti5CompatibilityHandler(); activiti5CompatibilityHandler.completeTask(task, variables, localScope); return null; } } if (variables != null) { if (localScope) { task.setVariablesLocal(variables); } else if (task.getExecutionId() != null) { task.setExecutionVariables(variables); } else { task.setVariables(variables); } } if (transientVariables != null) { if (localScope) { task.setTransientVariablesLocal(transientVariables); } else { task.setTransientVariables(transientVariables); } } executeTaskComplete(commandContext, task, variables, localScope); return null; }
Example 8
Source File: ListenerNotificationHelper.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void executeTaskListeners(TaskEntity taskEntity, String eventType) { if (taskEntity.getProcessDefinitionId() != null) { org.activiti.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(taskEntity.getProcessDefinitionId()); FlowElement flowElement = process.getFlowElement(taskEntity.getTaskDefinitionKey(), true); if (flowElement instanceof UserTask) { UserTask userTask = (UserTask) flowElement; executeTaskListeners(userTask, taskEntity, eventType); } } }
Example 9
Source File: ActivityPermissionAssignmentHandler.java From openwebflow with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void handleAssignment(TaskAssignmentHandlerChain chain, Expression assigneeExpression, Expression ownerExpression, Set<Expression> candidateUserExpressions, Set<Expression> candidateGroupExpressions, TaskEntity task, ActivityExecution execution) { //设置assignment信息 String processDefinitionId = task.getProcessDefinitionId(); String taskDefinitionKey = task.getTaskDefinitionKey(); ActivityPermissionEntity entity; try { entity = _activityPermissionManager.load(processDefinitionId, taskDefinitionKey, true); } catch (Exception e) { throw new OwfException(e); } //没有自定义授权规则 if (entity == null) { chain.resume(assigneeExpression, ownerExpression, candidateUserExpressions, candidateGroupExpressions, task, execution); return; } //彻底忽略原有规则 task.setAssignee(entity.getAssignee()); task.addCandidateGroups(asList(entity.getGrantedGroupIds())); task.addCandidateUsers(asList(entity.getGrantedUserIds())); }
Example 10
Source File: FormHandlerUtil.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public static TaskFormHandler getTaskFormHandlder(TaskEntity taskEntity) { if (taskEntity.getProcessDefinitionId() != null) { return getTaskFormHandlder(taskEntity.getProcessDefinitionId(), taskEntity.getTaskDefinitionKey()); } return null; }
Example 11
Source File: AddCommentCmd.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public Comment execute(CommandContext commandContext) { TaskEntity task = null; // Validate task if (taskId != null) { task = commandContext.getTaskEntityManager().findById(taskId); if (task == null) { throw new ActivitiObjectNotFoundException("Cannot find task with id " + taskId, Task.class); } if (task.isSuspended()) { throw new ActivitiException(getSuspendedTaskException()); } } ExecutionEntity execution = null; if (processInstanceId != null) { execution = commandContext.getExecutionEntityManager().findById(processInstanceId); if (execution == null) { throw new ActivitiObjectNotFoundException("execution " + processInstanceId + " doesn't exist", Execution.class); } if (execution.isSuspended()) { throw new ActivitiException(getSuspendedExceptionMessage()); } } String processDefinitionId = null; if (execution != null) { processDefinitionId = execution.getProcessDefinitionId(); } else if (task != null) { processDefinitionId = task.getProcessDefinitionId(); } if (processDefinitionId != null && Activiti5Util.isActiviti5ProcessDefinitionId(commandContext, processDefinitionId)) { Activiti5CompatibilityHandler activiti5CompatibilityHandler = Activiti5Util.getActiviti5CompatibilityHandler(); return activiti5CompatibilityHandler.addComment(taskId, processInstanceId, type, message); } String userId = Authentication.getAuthenticatedUserId(); CommentEntity comment = commandContext.getCommentEntityManager().create(); comment.setUserId(userId); comment.setType((type == null) ? CommentEntity.TYPE_COMMENT : type); comment.setTime(commandContext.getProcessEngineConfiguration().getClock().getCurrentTime()); comment.setTaskId(taskId); comment.setProcessInstanceId(processInstanceId); comment.setAction(Event.ACTION_ADD_COMMENT); String eventMessage = message.replaceAll("\\s+", " "); if (eventMessage.length() > 163) { eventMessage = eventMessage.substring(0, 160) + "..."; } comment.setMessage(eventMessage); comment.setFullMessage(message); commandContext.getCommentEntityManager().insert(comment); return comment; }
Example 12
Source File: RollbackTaskCmd.java From lemon with Apache License 2.0 | 4 votes |
/** * 回退到startEvent. */ public Integer rollbackStartEvent(CommandContext commandContext) { // 获得任务 TaskEntity taskEntity = this.findTask(commandContext); // 找到想要回退到的节点 ActivityImpl targetActivity = this.findTargetActivity(commandContext, taskEntity); if (taskEntity.getExecutionId().equals( taskEntity.getProcessInstanceId())) { // 如果退回的目标节点的executionId与当前task的executionId一样,说明是同一个分支 // 只删除当前分支的task TaskEntity targetTaskEntity = Context.getCommandContext() .getTaskEntityManager().findTaskById(this.taskId); this.deleteActiveTask(targetTaskEntity); } else { // 否则认为是从分支跳回主干 // 删除所有活动中的task this.deleteActiveTasks(taskEntity.getProcessInstanceId()); } // 把流程指向任务对应的节点 ExecutionEntity executionEntity = Context.getCommandContext() .getExecutionEntityManager() .findExecutionById(taskEntity.getExecutionId()); executionEntity.setActivity(targetActivity); // 创建HistoricActivityInstance Context.getCommandContext().getHistoryManager() .recordActivityStart(executionEntity); String processDefinitionId = taskEntity.getProcessDefinitionId(); GetStartFormCmd getStartFormCmd = new GetStartFormCmd( processDefinitionId); StartFormData startFormData = getStartFormCmd.execute(commandContext); try { logger.info("{}", targetActivity.getProperties()); // humanTask HumanTaskConnector humanTaskConnector = ApplicationContextHelper .getBean(HumanTaskConnector.class); HumanTaskDTO humanTaskDto = humanTaskConnector.createHumanTask(); humanTaskDto.setName((String) targetActivity.getProperty("name")); humanTaskDto.setDescription((String) targetActivity .getProperty("description")); humanTaskDto.setCode(targetActivity.getId()); humanTaskDto.setAssignee(this.userId); humanTaskDto.setOwner(null); humanTaskDto.setDelegateStatus("none"); humanTaskDto.setPriority(50); humanTaskDto.setCreateTime(new Date()); humanTaskDto.setDuration(null); humanTaskDto.setSuspendStatus("none"); humanTaskDto.setCategory("startEvent"); humanTaskDto.setForm(startFormData.getFormKey()); humanTaskDto.setTaskId(null); humanTaskDto.setExecutionId(taskEntity.getExecutionId()); humanTaskDto .setProcessInstanceId(taskEntity.getProcessInstanceId()); humanTaskDto.setProcessDefinitionId(taskEntity .getProcessDefinitionId()); humanTaskDto.setTenantId(taskEntity.getTenantId()); humanTaskDto.setStatus("active"); humanTaskDto = humanTaskConnector.saveHumanTask(humanTaskDto); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } // 处理多实例 this.processMultiInstance(); return 0; }
Example 13
Source File: RollbackTaskCmd.java From lemon with Apache License 2.0 | 4 votes |
/** * 根据任务历史,创建待办任务. */ public void processHistoryTask(CommandContext commandContext, TaskEntity taskEntity, HistoricTaskInstanceEntity historicTaskInstanceEntity, HistoricActivityInstanceEntity historicActivityInstanceEntity) { if (this.userId == null) { if (this.useLastAssignee) { this.userId = historicTaskInstanceEntity.getAssignee(); } else { String processDefinitionId = taskEntity .getProcessDefinitionId(); ProcessDefinitionEntity processDefinitionEntity = new GetDeploymentProcessDefinitionCmd( processDefinitionId).execute(commandContext); TaskDefinition taskDefinition = processDefinitionEntity .getTaskDefinitions().get( historicTaskInstanceEntity .getTaskDefinitionKey()); if (taskDefinition == null) { String message = "cannot find taskDefinition : " + historicTaskInstanceEntity.getTaskDefinitionKey(); logger.info(message); throw new IllegalStateException(message); } if (taskDefinition.getAssigneeExpression() != null) { logger.info("assignee expression is null : {}", taskDefinition.getKey()); this.userId = (String) taskDefinition .getAssigneeExpression().getValue(taskEntity); } } } /* * historicTaskInstanceEntity.setEndTime(null); historicTaskInstanceEntity.setDurationInMillis(null); * historicActivityInstanceEntity.setEndTime(null); historicActivityInstanceEntity.setDurationInMillis(null); */ // 创建新任务 TaskEntity task = TaskEntity.create(new Date()); task.setProcessDefinitionId(historicTaskInstanceEntity .getProcessDefinitionId()); // task.setId(historicTaskInstanceEntity.getId()); task.setAssigneeWithoutCascade(userId); task.setParentTaskIdWithoutCascade(historicTaskInstanceEntity .getParentTaskId()); task.setNameWithoutCascade(historicTaskInstanceEntity.getName()); task.setTaskDefinitionKey(historicTaskInstanceEntity .getTaskDefinitionKey()); task.setExecutionId(historicTaskInstanceEntity.getExecutionId()); task.setPriority(historicTaskInstanceEntity.getPriority()); task.setProcessInstanceId(historicTaskInstanceEntity .getProcessInstanceId()); task.setExecutionId(historicTaskInstanceEntity.getExecutionId()); task.setDescriptionWithoutCascade(historicTaskInstanceEntity .getDescription()); task.setTenantId(historicTaskInstanceEntity.getTenantId()); Context.getCommandContext().getTaskEntityManager().insert(task); // 把流程指向任务对应的节点 ExecutionEntity executionEntity = Context.getCommandContext() .getExecutionEntityManager() .findExecutionById(historicTaskInstanceEntity.getExecutionId()); executionEntity .setActivity(getActivity(historicActivityInstanceEntity)); // 创建HistoricActivityInstance Context.getCommandContext().getHistoryManager() .recordActivityStart(executionEntity); // 创建HistoricTaskInstance Context.getCommandContext().getHistoryManager() .recordTaskCreated(task, executionEntity); Context.getCommandContext().getHistoryManager().recordTaskId(task); // 更新ACT_HI_ACTIVITY里的assignee字段 Context.getCommandContext().getHistoryManager() .recordTaskAssignment(task); try { // humanTask this.createHumanTask(task, historicTaskInstanceEntity); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } }