use of org.camunda.bpm.engine.impl.persistence.entity.TaskEntity 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);
}
use of org.camunda.bpm.engine.impl.persistence.entity.TaskEntity 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;
}
use of org.camunda.bpm.engine.impl.persistence.entity.TaskEntity 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;
}
use of org.camunda.bpm.engine.impl.persistence.entity.TaskEntity 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);
}
}
use of org.camunda.bpm.engine.impl.persistence.entity.TaskEntity in project camunda-bpm-platform by camunda.
the class UserTaskActivityBehavior method performExecution.
@Override
public void performExecution(ActivityExecution execution) throws Exception {
TaskEntity task = TaskEntity.createAndInsert(execution);
taskDecorator.decorate(task, execution);
Context.getCommandContext().getHistoricTaskInstanceManager().createHistoricTask(task);
// All properties set, now firing 'create' event
task.fireEvent(TaskListener.EVENTNAME_CREATE);
}
Aggregations