Search in sources :

Example 1 with TaskManager

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

the class GetRenderedTaskFormCmd method execute.

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.checkReadTask(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);
}
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) TaskFormData(org.camunda.bpm.engine.form.TaskFormData) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker) FormEngine(org.camunda.bpm.engine.impl.form.engine.FormEngine)

Example 2 with TaskManager

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

the class GetTaskFormVariablesCmd method execute.

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;
}
Also used : VariableMapImpl(org.camunda.bpm.engine.variable.impl.VariableMapImpl) TaskDefinition(org.camunda.bpm.engine.impl.task.TaskDefinition) TaskManager(org.camunda.bpm.engine.impl.persistence.entity.TaskManager) TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) TaskFormData(org.camunda.bpm.engine.form.TaskFormData) FormField(org.camunda.bpm.engine.form.FormField)

Example 3 with TaskManager

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

the class CompleteTaskCmd 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);
    checkCompleteTask(task, commandContext);
    if (variables != null) {
        task.setExecutionVariables(variables);
    }
    completeTask(task);
    return null;
}
Also used : TaskManager(org.camunda.bpm.engine.impl.persistence.entity.TaskManager) TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)

Example 4 with TaskManager

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

the class DeleteTaskCmd method deleteTask.

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);
        String reason = (deleteReason == null || deleteReason.length() == 0) ? TaskEntity.DELETE_REASON_DELETED : deleteReason;
        task.delete(reason, cascade);
    } else if (cascade) {
        Context.getCommandContext().getHistoricTaskInstanceManager().deleteHistoricTaskInstanceById(taskId);
    }
}
Also used : TaskManager(org.camunda.bpm.engine.impl.persistence.entity.TaskManager) TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 5 with TaskManager

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

the class SubmitTaskFormCmd 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);
    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);
    }
    // complete or resolve the task
    if (DelegationState.PENDING.equals(task.getDelegationState())) {
        task.resolve();
        task.createHistoricTaskDetails(UserOperationLogEntry.OPERATION_TYPE_RESOLVE);
    } else {
        task.complete();
        task.createHistoricTaskDetails(UserOperationLogEntry.OPERATION_TYPE_COMPLETE);
    }
    return null;
}
Also used : TaskDefinition(org.camunda.bpm.engine.impl.task.TaskDefinition) 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)

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