Search in sources :

Example 6 with TaskEntity

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

the class SetProcessDefinitionVersionCmd method validateAndSwitchVersionOfExecution.

protected void validateAndSwitchVersionOfExecution(CommandContext commandContext, ExecutionEntity execution, ProcessDefinitionEntity newProcessDefinition) {
    // check that the new process definition version contains the current activity
    if (execution.getActivity() != null) {
        String activityId = execution.getActivity().getId();
        PvmActivity newActivity = newProcessDefinition.findActivity(activityId);
        if (newActivity == null) {
            throw new ProcessEngineException("The new process definition " + "(key = '" + newProcessDefinition.getKey() + "') " + "does not contain the current activity " + "(id = '" + activityId + "') " + "of the process instance " + "(id = '" + processInstanceId + "').");
        }
        // clear cached activity so that outgoing transitions are refreshed
        execution.setActivity(newActivity);
    }
    // switch the process instance to the new process definition version
    execution.setProcessDefinition(newProcessDefinition);
    // and change possible existing tasks (as the process definition id is stored there too)
    List<TaskEntity> tasks = commandContext.getTaskManager().findTasksByExecutionId(execution.getId());
    for (TaskEntity taskEntity : tasks) {
        taskEntity.setProcessDefinitionId(newProcessDefinition.getId());
    }
}
Also used : TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) PvmActivity(org.camunda.bpm.engine.impl.pvm.PvmActivity) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 7 with TaskEntity

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

the class SetTaskVariablesCmd method getEntity.

protected TaskEntity getEntity() {
    ensureNotNull("taskId", entityId);
    TaskEntity task = commandContext.getTaskManager().findTaskById(entityId);
    ensureNotNull("task " + entityId + " doesn't exist", "task", task);
    checkSetTaskVariables(task);
    return task;
}
Also used : TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)

Example 8 with TaskEntity

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

the class SetTaskVariablesCmd method logVariableOperation.

protected void logVariableOperation(AbstractVariableScope scope) {
    TaskEntity task = (TaskEntity) scope;
    commandContext.getOperationLogManager().logVariableOperation(getLogEntryOperation(), null, task.getId(), PropertyChange.EMPTY_CHANGE);
}
Also used : TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)

Example 9 with TaskEntity

use of org.camunda.bpm.engine.impl.persistence.entity.TaskEntity 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 10 with TaskEntity

use of org.camunda.bpm.engine.impl.persistence.entity.TaskEntity 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)

Aggregations

TaskEntity (org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)53 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)17 Deployment (org.camunda.bpm.engine.test.Deployment)11 TaskManager (org.camunda.bpm.engine.impl.persistence.entity.TaskManager)10 Date (java.util.Date)4 PropertyChange (org.camunda.bpm.engine.impl.persistence.entity.PropertyChange)4 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)3 TaskFormHandler (org.camunda.bpm.engine.impl.form.handler.TaskFormHandler)3 ExternalTaskEntity (org.camunda.bpm.engine.impl.persistence.entity.ExternalTaskEntity)3 VariableInstanceEntity (org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity)3 TaskDefinition (org.camunda.bpm.engine.impl.task.TaskDefinition)3 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)2 TaskFormData (org.camunda.bpm.engine.form.TaskFormData)2 HistoryEvent (org.camunda.bpm.engine.impl.history.event.HistoryEvent)2 AttachmentEntity (org.camunda.bpm.engine.impl.persistence.entity.AttachmentEntity)2 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)2 Task (org.camunda.bpm.engine.task.Task)2 VariableMapImpl (org.camunda.bpm.engine.variable.impl.VariableMapImpl)2 TypedValue (org.camunda.bpm.engine.variable.value.TypedValue)2 Before (org.junit.Before)2