Search in sources :

Example 1 with TaskDefinition

use of org.camunda.bpm.engine.impl.task.TaskDefinition 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 2 with TaskDefinition

use of org.camunda.bpm.engine.impl.task.TaskDefinition in project camunda-bpm-platform by camunda.

the class BpmnParse method parseUserTask.

/**
 * Parses a userTask declaration.
 */
public ActivityImpl parseUserTask(Element userTaskElement, ScopeImpl scope) {
    ActivityImpl activity = createActivityOnScope(userTaskElement, scope);
    parseAsynchronousContinuationForActivity(userTaskElement, activity);
    TaskDefinition taskDefinition = parseTaskDefinition(userTaskElement, activity.getId(), (ProcessDefinitionEntity) scope.getProcessDefinition());
    TaskDecorator taskDecorator = new TaskDecorator(taskDefinition, expressionManager);
    UserTaskActivityBehavior userTaskActivity = new UserTaskActivityBehavior(taskDecorator);
    activity.setActivityBehavior(userTaskActivity);
    parseProperties(userTaskElement, activity);
    parseExecutionListenersOnScope(userTaskElement, activity);
    for (BpmnParseListener parseListener : parseListeners) {
        parseListener.parseUserTask(userTaskElement, scope, activity);
    }
    return activity;
}
Also used : TaskDecorator(org.camunda.bpm.engine.impl.task.TaskDecorator) TaskDefinition(org.camunda.bpm.engine.impl.task.TaskDefinition)

Example 3 with TaskDefinition

use of org.camunda.bpm.engine.impl.task.TaskDefinition 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 4 with TaskDefinition

use of org.camunda.bpm.engine.impl.task.TaskDefinition in project camunda-bpm-platform by camunda.

the class GetFormKeyCmd method execute.

public String execute(CommandContext commandContext) {
    ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
    DeploymentCache deploymentCache = processEngineConfiguration.getDeploymentCache();
    ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
    for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
        checker.checkReadProcessDefinition(processDefinition);
    }
    Expression formKeyExpression = null;
    if (taskDefinitionKey == null) {
        // TODO: Maybe add getFormKey() to FormHandler interface to avoid the following cast
        FormHandler formHandler = processDefinition.getStartFormHandler();
        if (formHandler instanceof DelegateStartFormHandler) {
            DelegateStartFormHandler delegateFormHandler = (DelegateStartFormHandler) formHandler;
            formHandler = delegateFormHandler.getFormHandler();
        }
        // form handler (for a startForm) has always to extend the DefaultStartFormHandler!
        if (formHandler instanceof DefaultStartFormHandler) {
            DefaultStartFormHandler startFormHandler = (DefaultStartFormHandler) formHandler;
            formKeyExpression = startFormHandler.getFormKey();
        }
    } else {
        TaskDefinition taskDefinition = processDefinition.getTaskDefinitions().get(taskDefinitionKey);
        formKeyExpression = taskDefinition.getFormKey();
    }
    String formKey = null;
    if (formKeyExpression != null) {
        formKey = formKeyExpression.getExpressionText();
    }
    return formKey;
}
Also used : TaskDefinition(org.camunda.bpm.engine.impl.task.TaskDefinition) Expression(org.camunda.bpm.engine.delegate.Expression) DefaultStartFormHandler(org.camunda.bpm.engine.impl.form.handler.DefaultStartFormHandler) FormHandler(org.camunda.bpm.engine.impl.form.handler.FormHandler) DelegateStartFormHandler(org.camunda.bpm.engine.impl.form.handler.DelegateStartFormHandler) DelegateStartFormHandler(org.camunda.bpm.engine.impl.form.handler.DelegateStartFormHandler) DeploymentCache(org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache) DefaultStartFormHandler(org.camunda.bpm.engine.impl.form.handler.DefaultStartFormHandler) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker)

Example 5 with TaskDefinition

use of org.camunda.bpm.engine.impl.task.TaskDefinition 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)

Aggregations

TaskDefinition (org.camunda.bpm.engine.impl.task.TaskDefinition)39 HumanTaskActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.HumanTaskActivityBehavior)24 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)23 Test (org.junit.Test)23 Expression (org.camunda.bpm.engine.delegate.Expression)12 TaskListener (org.camunda.bpm.engine.delegate.TaskListener)12 ClassDelegateTaskListener (org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener)12 DelegateExpressionTaskListener (org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener)12 ExpressionTaskListener (org.camunda.bpm.engine.impl.task.listener.ExpressionTaskListener)12 ExtensionElements (org.camunda.bpm.model.cmmn.instance.ExtensionElements)12 CamundaTaskListener (org.camunda.bpm.model.cmmn.instance.camunda.CamundaTaskListener)12 ConditionExpression (org.camunda.bpm.model.cmmn.instance.ConditionExpression)11 CaseDefinitionEntity (org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity)4 UserTaskActivityBehavior (org.camunda.bpm.engine.impl.bpmn.behavior.UserTaskActivityBehavior)3 TaskEntity (org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)3 TaskDecorator (org.camunda.bpm.engine.impl.task.TaskDecorator)3 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)2 ExpressionManager (org.camunda.bpm.engine.impl.el.ExpressionManager)2 TaskFormHandler (org.camunda.bpm.engine.impl.form.handler.TaskFormHandler)2 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)2