public UserOperationLogContextEntryBuilder inContextOf( TaskEntity task, List<PropertyChange> propertyChanges) { if (propertyChanges == null || propertyChanges.isEmpty()) { if (OPERATION_TYPE_CREATE.equals(entry.getOperationType())) { propertyChanges = Arrays.asList(PropertyChange.EMPTY_CHANGE); } } entry.setPropertyChanges(propertyChanges); ResourceDefinitionEntity definition = task.getProcessDefinition(); if (definition != null) { entry.setProcessDefinitionKey(definition.getKey()); entry.setDeploymentId(definition.getDeploymentId()); } else if (task.getCaseDefinitionId() != null) { definition = task.getCaseDefinition(); entry.setDeploymentId(definition.getDeploymentId()); } entry.setProcessDefinitionId(task.getProcessDefinitionId()); entry.setProcessInstanceId(task.getProcessInstanceId()); entry.setExecutionId(task.getExecutionId()); entry.setCaseDefinitionId(task.getCaseDefinitionId()); entry.setCaseInstanceId(task.getCaseInstanceId()); entry.setCaseExecutionId(task.getCaseExecutionId()); entry.setTaskId(task.getId()); return this; }
public TaskEntity createTask(TaskDecorator taskDecorator) { TaskEntity task = TaskEntity.createAndInsert(this); setTask(task); taskDecorator.decorate(task, this); Context.getCommandContext().getHistoricTaskInstanceManager().createHistoricTask(task); // All properties set, now firing 'create' event task.fireEvent(TaskListener.EVENTNAME_CREATE); return task; }
protected void deleteTask(String taskId) { TaskEntity task = Context.getCommandContext().getTaskManager().findTaskById(taskId); if (task != null) { if (task.getExecutionId() != null) { throw new ProcessEngineException( "The task cannot be deleted because is part of a running process"); } String reason = (deleteReason == null || deleteReason.length() == 0) ? TaskEntity.DELETE_REASON_DELETED : deleteReason; task.delete(reason, cascade); } else if (cascade) { Context.getCommandContext() .getHistoricTaskInstanceManager() .deleteHistoricTaskInstanceById(taskId); } }
public TaskFormData execute(CommandContext commandContext) { TaskManager taskManager = commandContext.getTaskManager(); TaskEntity task = taskManager.findTaskById(taskId); ensureNotNull("No task found for taskId '" + taskId + "'", "task", task); AuthorizationManager authorizationManager = commandContext.getAuthorizationManager(); authorizationManager.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; } }