Search in sources :

Example 11 with TaskManager

use of org.camunda.bpm.engine.impl.persistence.entity.TaskManager in project camunda-bpm-platform by camunda.

the class ClaimTaskCmd method execute.

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)) {
                // 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.createHistoricTaskDetails(UserOperationLogEntry.OPERATION_TYPE_CLAIM);
    return null;
}
Also used : TaskManager(org.camunda.bpm.engine.impl.persistence.entity.TaskManager) TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) TaskAlreadyClaimedException(org.camunda.bpm.engine.TaskAlreadyClaimedException)

Example 12 with TaskManager

use of org.camunda.bpm.engine.impl.persistence.entity.TaskManager in project camunda-bpm-platform by camunda.

the class DelegateTaskCmd method execute.

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.createHistoricTaskDetails(UserOperationLogEntry.OPERATION_TYPE_DELEGATE);
    return null;
}
Also used : TaskManager(org.camunda.bpm.engine.impl.persistence.entity.TaskManager) TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)

Aggregations

TaskManager (org.camunda.bpm.engine.impl.persistence.entity.TaskManager)12 TaskEntity (org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)10 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)3 TaskFormHandler (org.camunda.bpm.engine.impl.form.handler.TaskFormHandler)3 TaskFormData (org.camunda.bpm.engine.form.TaskFormData)2 TaskDefinition (org.camunda.bpm.engine.impl.task.TaskDefinition)2 List (java.util.List)1 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 TaskAlreadyClaimedException (org.camunda.bpm.engine.TaskAlreadyClaimedException)1 FormField (org.camunda.bpm.engine.form.FormField)1 FormEngine (org.camunda.bpm.engine.impl.form.engine.FormEngine)1 IdentityLinkEntity (org.camunda.bpm.engine.impl.persistence.entity.IdentityLinkEntity)1 IdentityLink (org.camunda.bpm.engine.task.IdentityLink)1 VariableMapImpl (org.camunda.bpm.engine.variable.impl.VariableMapImpl)1