Search in sources :

Example 6 with TaskManager

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

the class SetTaskPriorityCmd 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);
    checkTaskPriority(task, commandContext);
    task.setPriority(priority);
    task.createHistoricTaskDetails(UserOperationLogEntry.OPERATION_TYPE_SET_PRIORITY);
    return null;
}
Also used : TaskManager(org.camunda.bpm.engine.impl.persistence.entity.TaskManager) TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)

Example 7 with TaskManager

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

the class GetTaskFormCmd method execute.

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.checkReadTask(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;
    }
}
Also used : TaskManager(org.camunda.bpm.engine.impl.persistence.entity.TaskManager) TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) TaskFormHandler(org.camunda.bpm.engine.impl.form.handler.TaskFormHandler) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker)

Example 8 with TaskManager

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

the class GetIdentityLinksForTaskCmd method execute.

@SuppressWarnings({ "unchecked", "rawtypes" })
public List<IdentityLink> execute(CommandContext commandContext) {
    ensureNotNull("taskId", taskId);
    TaskManager taskManager = commandContext.getTaskManager();
    TaskEntity task = taskManager.findTaskById(taskId);
    ensureNotNull("Cannot find task with id " + taskId, "task", task);
    checkGetIdentityLink(task, commandContext);
    List<IdentityLink> identityLinks = (List) task.getIdentityLinks();
    // and of course this leads to exception while trying to delete a non-existing identityLink
    if (task.getAssignee() != null) {
        IdentityLinkEntity identityLink = new IdentityLinkEntity();
        identityLink.setUserId(task.getAssignee());
        identityLink.setTask(task);
        identityLink.setType(IdentityLinkType.ASSIGNEE);
        identityLinks.add(identityLink);
    }
    if (task.getOwner() != null) {
        IdentityLinkEntity identityLink = new IdentityLinkEntity();
        identityLink.setUserId(task.getOwner());
        identityLink.setTask(task);
        identityLink.setType(IdentityLinkType.OWNER);
        identityLinks.add(identityLink);
    }
    return (List) task.getIdentityLinks();
}
Also used : IdentityLinkEntity(org.camunda.bpm.engine.impl.persistence.entity.IdentityLinkEntity) TaskManager(org.camunda.bpm.engine.impl.persistence.entity.TaskManager) TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) List(java.util.List) IdentityLink(org.camunda.bpm.engine.task.IdentityLink)

Example 9 with TaskManager

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

the class DeleteIdentityLinkCmd method execute.

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

Example 10 with TaskManager

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

the class AddIdentityLinkCmd method execute.

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

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