Search in sources :

Example 1 with TaskFormHandler

use of org.camunda.bpm.engine.impl.form.handler.TaskFormHandler 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 TaskFormHandler

use of org.camunda.bpm.engine.impl.form.handler.TaskFormHandler 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)

Example 3 with TaskFormHandler

use of org.camunda.bpm.engine.impl.form.handler.TaskFormHandler in project camunda-bpm-platform by camunda.

the class HumanTaskItemHandler method createTaskDefinition.

protected TaskDefinition createTaskDefinition(CmmnElement element, CmmnHandlerContext context) {
    // at the moment a default task form handler is only supported,
    // custom task form handler are not supported.
    TaskFormHandler taskFormHandler = new DefaultTaskFormHandler();
    // create new taskDefinition
    TaskDefinition taskDefinition = new TaskDefinition(taskFormHandler);
    // the plan item id will be handled as taskDefinitionKey
    String taskDefinitionKey = element.getId();
    taskDefinition.setKey(taskDefinitionKey);
    // name
    initializeTaskDefinitionName(element, taskDefinition, context);
    // dueDate
    initializeTaskDefinitionDueDate(element, taskDefinition, context);
    // followUp
    initializeTaskDefinitionFollowUpDate(element, taskDefinition, context);
    // priority
    initializeTaskDefinitionPriority(element, taskDefinition, context);
    // assignee
    initializeTaskDefinitionAssignee(element, taskDefinition, context);
    // candidateUsers
    initializeTaskDefinitionCandidateUsers(element, taskDefinition, context);
    // candidateGroups
    initializeTaskDefinitionCandidateGroups(element, taskDefinition, context);
    // formKey
    initializeTaskDefinitionFormKey(element, taskDefinition, context);
    // description
    initializeTaskDescription(element, taskDefinition, context);
    return taskDefinition;
}
Also used : TaskDefinition(org.camunda.bpm.engine.impl.task.TaskDefinition) DefaultTaskFormHandler(org.camunda.bpm.engine.impl.form.handler.DefaultTaskFormHandler) TaskFormHandler(org.camunda.bpm.engine.impl.form.handler.TaskFormHandler) DefaultTaskFormHandler(org.camunda.bpm.engine.impl.form.handler.DefaultTaskFormHandler)

Example 4 with TaskFormHandler

use of org.camunda.bpm.engine.impl.form.handler.TaskFormHandler 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)

Aggregations

TaskFormHandler (org.camunda.bpm.engine.impl.form.handler.TaskFormHandler)4 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)3 TaskEntity (org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)3 TaskManager (org.camunda.bpm.engine.impl.persistence.entity.TaskManager)3 TaskDefinition (org.camunda.bpm.engine.impl.task.TaskDefinition)2 TaskFormData (org.camunda.bpm.engine.form.TaskFormData)1 FormEngine (org.camunda.bpm.engine.impl.form.engine.FormEngine)1 DefaultTaskFormHandler (org.camunda.bpm.engine.impl.form.handler.DefaultTaskFormHandler)1