Java Code Examples for org.camunda.bpm.engine.impl.interceptor.CommandContext#getTaskManager()
The following examples show how to use
org.camunda.bpm.engine.impl.interceptor.CommandContext#getTaskManager() .
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: AddIdentityLinkCmd.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public Void execute(CommandContext commandContext) { ensureNotNull("taskId", taskId); TaskManager taskManager = commandContext.getTaskManager(); task = taskManager.findTaskById(taskId); EnsureUtil.ensureNotNull("Cannot find task with id " + taskId, "task", task); checkAddIdentityLink(task, commandContext); if (IdentityLinkType.ASSIGNEE.equals(type)) { task.setAssignee(userId); } else if (IdentityLinkType.OWNER.equals(type)) { task.setOwner(userId); } else { task.addIdentityLink(userId, groupId, type); } task.triggerUpdateEvent(); return null; }
Example 2
Source File: DeleteTaskCmd.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected void deleteTask(String taskId, CommandContext commandContext) { TaskManager taskManager = commandContext.getTaskManager(); TaskEntity task = taskManager.findTaskById(taskId); if (task != null) { if(task.getExecutionId() != null) { throw new ProcessEngineException("The task cannot be deleted because is part of a running process"); } else if (task.getCaseExecutionId() != null) { throw new ProcessEngineException("The task cannot be deleted because is part of a running case instance"); } checkDeleteTask(task, commandContext); task.logUserOperation(UserOperationLogEntry.OPERATION_TYPE_DELETE); String reason = (deleteReason == null || deleteReason.length() == 0) ? TaskEntity.DELETE_REASON_DELETED : deleteReason; task.delete(reason, cascade); } else if (cascade) { Context .getCommandContext() .getHistoricTaskInstanceManager() .deleteHistoricTaskInstanceById(taskId); } }
Example 3
Source File: GetTaskFormCmd.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public TaskFormData execute(CommandContext commandContext) { TaskManager taskManager = commandContext.getTaskManager(); TaskEntity task = taskManager.findTaskById(taskId); ensureNotNull("No task found for taskId '" + taskId + "'", "task", task); for(CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) { checker.checkReadTaskVariable(task); } if (task.getTaskDefinition() != null) { TaskFormHandler taskFormHandler = task.getTaskDefinition().getTaskFormHandler(); ensureNotNull("No taskFormHandler specified for task '" + taskId + "'", "taskFormHandler", taskFormHandler); return taskFormHandler.createTaskForm(task); } else { // Standalone task, no TaskFormData available return null; } }
Example 4
Source File: GetRenderedTaskFormCmd.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public Object execute(CommandContext commandContext) { TaskManager taskManager = commandContext.getTaskManager(); TaskEntity task = taskManager.findTaskById(taskId); ensureNotNull("Task '" + taskId + "' not found", "task", task); for(CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) { checker.checkReadTaskVariable(task); } ensureNotNull("Task form definition for '" + taskId + "' not found", "task.getTaskDefinition()", task.getTaskDefinition()); TaskFormHandler taskFormHandler = task.getTaskDefinition().getTaskFormHandler(); if (taskFormHandler == null) { return null; } FormEngine formEngine = Context .getProcessEngineConfiguration() .getFormEngines() .get(formEngineName); ensureNotNull("No formEngine '" + formEngineName + "' defined process engine configuration", "formEngine", formEngine); TaskFormData taskForm = taskFormHandler.createTaskForm(task); return formEngine.renderTaskForm(taskForm); }
Example 5
Source File: DeleteIdentityLinkCmd.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public Void execute(CommandContext commandContext) { ensureNotNull("taskId", taskId); TaskManager taskManager = commandContext.getTaskManager(); task = taskManager.findTaskById(taskId); ensureNotNull("Cannot find task with id " + taskId, "task", task); checkDeleteIdentityLink(task, commandContext); if (IdentityLinkType.ASSIGNEE.equals(type)) { task.setAssignee(null); } else if (IdentityLinkType.OWNER.equals(type)) { task.setOwner(null); } else { task.deleteIdentityLink(userId, groupId, type); } task.triggerUpdateEvent(); return null; }
Example 6
Source File: GetTaskFormVariablesCmd.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public VariableMap execute(CommandContext commandContext) { final TaskManager taskManager = commandContext.getTaskManager(); TaskEntity task = taskManager.findTaskById(resourceId); ensureNotNull(BadUserRequestException.class, "Cannot find task with id '" + resourceId + "'.", "task", task); checkGetTaskFormVariables(task, commandContext); VariableMapImpl result = new VariableMapImpl(); // first, evaluate form fields TaskDefinition taskDefinition = task.getTaskDefinition(); if (taskDefinition != null) { TaskFormData taskFormData = taskDefinition.getTaskFormHandler().createTaskForm(task); for (FormField formField : taskFormData.getFormFields()) { if(formVariableNames == null || formVariableNames.contains(formField.getId())) { result.put(formField.getId(), createVariable(formField, task)); } } } // collect remaining variables from task scope and parent scopes task.collectVariables(result, formVariableNames, false, deserializeObjectValues); return result; }
Example 7
Source File: ClaimTaskCmd.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public Void execute(CommandContext commandContext) { ensureNotNull("taskId", taskId); TaskManager taskManager = commandContext.getTaskManager(); TaskEntity task = taskManager.findTaskById(taskId); ensureNotNull("Cannot find task with id " + taskId, "task", task); checkClaimTask(task, commandContext); if (userId != null) { if (task.getAssignee() != null) { if (!task.getAssignee().equals(userId)) { // When the task is already claimed by another user, throw exception. Otherwise, ignore // this, post-conditions of method already met. throw new TaskAlreadyClaimedException(task.getId(), task.getAssignee()); } } else { task.setAssignee(userId); } } else { // Task should be assigned to no one task.setAssignee(null); } task.triggerUpdateEvent(); task.logUserOperation(UserOperationLogEntry.OPERATION_TYPE_CLAIM); return null; }
Example 8
Source File: AbstractSetProcessInstanceStateCmd.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override protected void updateSuspensionState(CommandContext commandContext, SuspensionState suspensionState) { ExecutionManager executionManager = commandContext.getExecutionManager(); TaskManager taskManager = commandContext.getTaskManager(); ExternalTaskManager externalTaskManager = commandContext.getExternalTaskManager(); if (processInstanceId != null) { executionManager.updateExecutionSuspensionStateByProcessInstanceId(processInstanceId, suspensionState); taskManager.updateTaskSuspensionStateByProcessInstanceId(processInstanceId, suspensionState); externalTaskManager.updateExternalTaskSuspensionStateByProcessInstanceId(processInstanceId, suspensionState); } else if (processDefinitionId != null) { executionManager.updateExecutionSuspensionStateByProcessDefinitionId(processDefinitionId, suspensionState); taskManager.updateTaskSuspensionStateByProcessDefinitionId(processDefinitionId, suspensionState); externalTaskManager.updateExternalTaskSuspensionStateByProcessDefinitionId(processDefinitionId, suspensionState); } else if (isProcessDefinitionTenantIdSet) { executionManager.updateExecutionSuspensionStateByProcessDefinitionKeyAndTenantId(processDefinitionKey, processDefinitionTenantId, suspensionState); taskManager.updateTaskSuspensionStateByProcessDefinitionKeyAndTenantId(processDefinitionKey, processDefinitionTenantId, suspensionState); externalTaskManager.updateExternalTaskSuspensionStateByProcessDefinitionKeyAndTenantId(processDefinitionKey, processDefinitionTenantId, suspensionState); } else { executionManager.updateExecutionSuspensionStateByProcessDefinitionKey(processDefinitionKey, suspensionState); taskManager.updateTaskSuspensionStateByProcessDefinitionKey(processDefinitionKey, suspensionState); externalTaskManager.updateExternalTaskSuspensionStateByProcessDefinitionKey(processDefinitionKey, suspensionState); } }
Example 9
Source File: CompleteTaskCmd.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public VariableMap execute(CommandContext commandContext) { ensureNotNull("taskId", taskId); TaskManager taskManager = commandContext.getTaskManager(); TaskEntity task = taskManager.findTaskById(taskId); ensureNotNull("Cannot find task with id " + taskId, "task", task); checkCompleteTask(task, commandContext); if (variables != null) { task.setExecutionVariables(variables); } ExecutionEntity execution = task.getProcessInstance(); ExecutionVariableSnapshotObserver variablesListener = null; if (returnVariables && execution != null) { variablesListener = new ExecutionVariableSnapshotObserver(execution, false, deserializeReturnedVariables); } completeTask(task); if (returnVariables) { if (variablesListener != null) { return variablesListener.getVariables(); } else { return task.getCaseDefinitionId() != null ? null : task.getVariablesTyped(false); } } else { return null; } }
Example 10
Source File: TaskEntity.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public void insert() { CommandContext commandContext = Context.getCommandContext(); TaskManager taskManager = commandContext.getTaskManager(); taskManager.insertTask(this); }
Example 11
Source File: TaskEntity.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
protected void saveAuthorizations(AuthorizationEntity[] authorizations) { CommandContext commandContext = Context.getCommandContext(); TaskManager taskManager = commandContext.getTaskManager(); taskManager.saveDefaultAuthorizations(authorizations); }
Example 12
Source File: TaskEntity.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
protected void deleteAuthorizations(AuthorizationEntity[] authorizations) { CommandContext commandContext = Context.getCommandContext(); TaskManager taskManager = commandContext.getTaskManager(); taskManager.deleteDefaultAuthorizations(authorizations); }
Example 13
Source File: SubmitTaskFormCmd.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public VariableMap execute(CommandContext commandContext) { ensureNotNull("taskId", taskId); TaskManager taskManager = commandContext.getTaskManager(); TaskEntity task = taskManager.findTaskById(taskId); ensureNotNull("Cannot find task with id " + taskId, "task", task); for(CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) { checker.checkTaskWork(task); } TaskDefinition taskDefinition = task.getTaskDefinition(); if(taskDefinition != null) { TaskFormHandler taskFormHandler = taskDefinition.getTaskFormHandler(); taskFormHandler.submitFormVariables(properties, task); } else { // set variables on standalone task task.setVariables(properties); } ExecutionEntity execution = task.getProcessInstance(); ExecutionVariableSnapshotObserver variablesListener = null; if (returnVariables && execution != null) { variablesListener = new ExecutionVariableSnapshotObserver(execution, false, deserializeValues); } // complete or resolve the task if (DelegationState.PENDING.equals(task.getDelegationState())) { task.resolve(); task.logUserOperation(UserOperationLogEntry.OPERATION_TYPE_RESOLVE); task.triggerUpdateEvent(); } else { task.logUserOperation(UserOperationLogEntry.OPERATION_TYPE_COMPLETE); task.complete(); } if (returnVariables) { if (variablesListener != null) { return variablesListener.getVariables(); } else { return task.getCaseDefinitionId() == null ? null : task.getVariablesTyped(false); } } else { return null; } }
Example 14
Source File: DelegateTaskCmd.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public Object execute(CommandContext commandContext) { ensureNotNull("taskId", taskId); TaskManager taskManager = commandContext.getTaskManager(); TaskEntity task = taskManager.findTaskById(taskId); ensureNotNull("Cannot find task with id " + taskId, "task", task); checkDelegateTask(task, commandContext); task.delegate(userId); task.triggerUpdateEvent(); task.logUserOperation(UserOperationLogEntry.OPERATION_TYPE_DELEGATE); return null; }
Example 15
Source File: SetTaskPriorityCmd.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public Void execute(CommandContext commandContext) { ensureNotNull("taskId", taskId); TaskManager taskManager = commandContext.getTaskManager(); TaskEntity task = taskManager.findTaskById(taskId); ensureNotNull("Cannot find task with id " + taskId, "task", task); checkTaskPriority(task, commandContext); task.setPriority(priority); task.triggerUpdateEvent(); task.logUserOperation(UserOperationLogEntry.OPERATION_TYPE_SET_PRIORITY); return null; }