Search in sources :

Example 21 with CommandContext

use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.

the class TaskEntity method createHistoricTaskDetails.

public void createHistoricTaskDetails(String operation) {
    final CommandContext commandContext = Context.getCommandContext();
    if (commandContext != null) {
        List<PropertyChange> values = new ArrayList<PropertyChange>(propertyChanges.values());
        commandContext.getOperationLogManager().logTaskOperations(operation, this, values);
        fireHistoricIdentityLinks();
        propertyChanges.clear();
    }
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) ArrayList(java.util.ArrayList)

Example 22 with CommandContext

use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.

the class TaskEntity method saveAuthorizations.

protected void saveAuthorizations(AuthorizationEntity[] authorizations) {
    CommandContext commandContext = Context.getCommandContext();
    TaskManager taskManager = commandContext.getTaskManager();
    taskManager.saveDefaultAuthorizations(authorizations);
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext)

Example 23 with CommandContext

use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.

the class TaskManager method deleteTask.

public void deleteTask(TaskEntity task, String deleteReason, boolean cascade, boolean skipCustomListeners) {
    if (!task.isDeleted()) {
        task.setDeleted(true);
        CommandContext commandContext = Context.getCommandContext();
        String taskId = task.getId();
        List<Task> subTasks = findTasksByParentTaskId(taskId);
        for (Task subTask : subTasks) {
            ((TaskEntity) subTask).delete(deleteReason, cascade, skipCustomListeners);
        }
        task.deleteIdentityLinks(false);
        commandContext.getVariableInstanceManager().deleteVariableInstanceByTask(task);
        if (cascade) {
            commandContext.getHistoricTaskInstanceManager().deleteHistoricTaskInstanceById(taskId);
        } else {
            commandContext.getHistoricTaskInstanceManager().markTaskInstanceEnded(taskId, deleteReason);
            if (TaskEntity.DELETE_REASON_COMPLETED.equals(deleteReason)) {
                task.createHistoricTaskDetails(UserOperationLogEntry.OPERATION_TYPE_COMPLETE);
            } else {
                task.createHistoricTaskDetails(UserOperationLogEntry.OPERATION_TYPE_DELETE);
            }
        }
        deleteAuthorizations(Resources.TASK, taskId);
        getDbEntityManager().delete(task);
    }
}
Also used : Task(org.camunda.bpm.engine.task.Task) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext)

Example 24 with CommandContext

use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.

the class HistoricTaskInstanceManager method deleteHistoricTaskInstancesByCaseInstanceIds.

public void deleteHistoricTaskInstancesByCaseInstanceIds(List<String> caseInstanceIds) {
    CommandContext commandContext = Context.getCommandContext();
    getHistoricDetailManager().deleteHistoricDetailsByTaskCaseInstanceIds(caseInstanceIds);
    commandContext.getCommentManager().deleteCommentsByTaskCaseInstanceIds(caseInstanceIds);
    getAttachmentManager().deleteAttachmentsByTaskCaseInstanceIds(caseInstanceIds);
    getHistoricIdentityLinkManager().deleteHistoricIdentityLinksLogByTaskCaseInstanceIds(caseInstanceIds);
    getDbEntityManager().deletePreserveOrder(HistoricTaskInstanceEntity.class, "deleteHistoricTaskInstanceByCaseInstanceIds", caseInstanceIds);
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext)

Example 25 with CommandContext

use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.

the class HistoricIncidentAuthorizationTest method clearDatabase.

protected void clearDatabase() {
    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
    commandExecutor.execute(new Command<Object>() {

        public Object execute(CommandContext commandContext) {
            commandContext.getHistoricJobLogManager().deleteHistoricJobLogsByHandlerType(TimerSuspendProcessDefinitionHandler.TYPE);
            List<HistoricIncident> incidents = Context.getProcessEngineConfiguration().getHistoryService().createHistoricIncidentQuery().list();
            for (HistoricIncident incident : incidents) {
                commandContext.getHistoricIncidentManager().delete((HistoricIncidentEntity) incident);
            }
            return null;
        }
    });
}
Also used : HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) HistoricIncidentEntity(org.camunda.bpm.engine.impl.persistence.entity.HistoricIncidentEntity) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) CommandExecutor(org.camunda.bpm.engine.impl.interceptor.CommandExecutor) List(java.util.List)

Aggregations

CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)120 CommandExecutor (org.camunda.bpm.engine.impl.interceptor.CommandExecutor)31 List (java.util.List)17 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)17 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)11 Deployment (org.camunda.bpm.engine.test.Deployment)11 ArrayList (java.util.ArrayList)10 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)10 Date (java.util.Date)9 HistoricIncident (org.camunda.bpm.engine.history.HistoricIncident)8 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)8 JobManager (org.camunda.bpm.engine.impl.persistence.entity.JobManager)8 Command (org.camunda.bpm.engine.impl.interceptor.Command)6 HistoricIncidentEntity (org.camunda.bpm.engine.impl.persistence.entity.HistoricIncidentEntity)6 After (org.junit.After)6 ProcessApplicationReference (org.camunda.bpm.application.ProcessApplicationReference)5 RepositoryService (org.camunda.bpm.engine.RepositoryService)5 ProcessEngineImpl (org.camunda.bpm.engine.impl.ProcessEngineImpl)5 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)5 HistoricDecisionInstance (org.camunda.bpm.engine.history.HistoricDecisionInstance)4