Search in sources :

Example 6 with HistoricIncident

use of org.camunda.bpm.engine.history.HistoricIncident in project camunda-bpm-platform by camunda.

the class HistoryCleanupAuthorizationTest method clearDatabase.

protected void clearDatabase() {
    // reset configuration changes
    String defaultStartTime = processEngineConfiguration.getHistoryCleanupBatchWindowStartTime();
    String defaultEndTime = processEngineConfiguration.getHistoryCleanupBatchWindowEndTime();
    int defaultBatchSize = processEngineConfiguration.getHistoryCleanupBatchSize();
    processEngineConfiguration.setHistoryCleanupBatchWindowStartTime(defaultStartTime);
    processEngineConfiguration.setHistoryCleanupBatchWindowEndTime(defaultEndTime);
    processEngineConfiguration.setHistoryCleanupBatchSize(defaultBatchSize);
    processEngineConfiguration.getCommandExecutorTxRequired().execute(new Command<Void>() {

        public Void execute(CommandContext commandContext) {
            List<Job> jobs = managementService.createJobQuery().list();
            if (jobs.size() > 0) {
                assertEquals(1, jobs.size());
                String jobId = jobs.get(0).getId();
                commandContext.getJobManager().deleteJob((JobEntity) jobs.get(0));
                commandContext.getHistoricJobLogManager().deleteHistoricJobLogByJobId(jobId);
            }
            List<HistoricIncident> historicIncidents = historyService.createHistoricIncidentQuery().list();
            for (HistoricIncident historicIncident : historicIncidents) {
                commandContext.getDbEntityManager().delete((HistoricIncidentEntity) historicIncident);
            }
            commandContext.getMeterLogManager().deleteAll();
            return null;
        }
    });
    List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().list();
    for (HistoricProcessInstance historicProcessInstance : historicProcessInstances) {
        historyService.deleteHistoricProcessInstance(historicProcessInstance.getId());
    }
    List<HistoricDecisionInstance> historicDecisionInstances = historyService.createHistoricDecisionInstanceQuery().list();
    for (HistoricDecisionInstance historicDecisionInstance : historicDecisionInstances) {
        historyService.deleteHistoricDecisionInstanceByInstanceId(historicDecisionInstance.getId());
    }
    List<HistoricCaseInstance> historicCaseInstances = historyService.createHistoricCaseInstanceQuery().list();
    for (HistoricCaseInstance historicCaseInstance : historicCaseInstances) {
        historyService.deleteHistoricCaseInstance(historicCaseInstance.getId());
    }
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) HistoricDecisionInstance(org.camunda.bpm.engine.history.HistoricDecisionInstance) JobEntity(org.camunda.bpm.engine.impl.persistence.entity.JobEntity) HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) HistoricIncidentEntity(org.camunda.bpm.engine.impl.persistence.entity.HistoricIncidentEntity) HistoricCaseInstance(org.camunda.bpm.engine.history.HistoricCaseInstance) ArrayList(java.util.ArrayList) List(java.util.List)

Example 7 with HistoricIncident

use of org.camunda.bpm.engine.history.HistoricIncident in project camunda-bpm-platform by camunda.

the class ManagementServiceTest method deleteJobAndIncidents.

protected void deleteJobAndIncidents(final Job job) {
    final List<HistoricIncident> incidents = historyService.createHistoricIncidentQuery().incidentType(Incident.FAILED_JOB_HANDLER_TYPE).list();
    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
    commandExecutor.execute(new Command<Void>() {

        @Override
        public Void execute(CommandContext commandContext) {
            ((JobEntity) job).delete();
            HistoricIncidentManager historicIncidentManager = commandContext.getHistoricIncidentManager();
            for (HistoricIncident incident : incidents) {
                HistoricIncidentEntity incidentEntity = (HistoricIncidentEntity) incident;
                historicIncidentManager.delete(incidentEntity);
            }
            commandContext.getHistoricJobLogManager().deleteHistoricJobLogByJobId(job.getId());
            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) HistoricIncidentManager(org.camunda.bpm.engine.impl.persistence.entity.HistoricIncidentManager) CommandExecutor(org.camunda.bpm.engine.impl.interceptor.CommandExecutor)

Example 8 with HistoricIncident

use of org.camunda.bpm.engine.history.HistoricIncident in project camunda-bpm-platform by camunda.

the class JobQueryTest method deleteJobInDatabase.

private void deleteJobInDatabase() {
    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
    commandExecutor.execute(new Command<Void>() {

        public Void execute(CommandContext commandContext) {
            timerEntity.delete();
            commandContext.getHistoricJobLogManager().deleteHistoricJobLogByJobId(timerEntity.getId());
            List<HistoricIncident> historicIncidents = Context.getProcessEngineConfiguration().getHistoryService().createHistoricIncidentQuery().list();
            for (HistoricIncident historicIncident : historicIncidents) {
                commandContext.getDbEntityManager().delete((DbEntity) historicIncident);
            }
            return null;
        }
    });
}
Also used : HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) DbEntity(org.camunda.bpm.engine.impl.db.DbEntity) CommandExecutor(org.camunda.bpm.engine.impl.interceptor.CommandExecutor) List(java.util.List)

Example 9 with HistoricIncident

use of org.camunda.bpm.engine.history.HistoricIncident in project camunda-bpm-platform by camunda.

the class HistoryCleanupBatchWindowTest method clearDatabase.

@After
public void clearDatabase() {
    // reset configuration changes
    processEngineConfiguration.setHistoryCleanupBatchWindowStartTime(defaultStartTime);
    processEngineConfiguration.setHistoryCleanupBatchWindowEndTime(defaultEndTime);
    processEngineConfiguration.setHistoryCleanupBatchSize(defaultBatchSize);
    processEngineConfiguration.getCommandExecutorTxRequired().execute(new Command<Void>() {

        public Void execute(CommandContext commandContext) {
            List<Job> jobs = managementService.createJobQuery().list();
            if (jobs.size() > 0) {
                assertEquals(1, jobs.size());
                String jobId = jobs.get(0).getId();
                commandContext.getJobManager().deleteJob((JobEntity) jobs.get(0));
                commandContext.getHistoricJobLogManager().deleteHistoricJobLogByJobId(jobId);
            }
            List<HistoricIncident> historicIncidents = historyService.createHistoricIncidentQuery().list();
            for (HistoricIncident historicIncident : historicIncidents) {
                commandContext.getDbEntityManager().delete((HistoricIncidentEntity) historicIncident);
            }
            commandContext.getMeterLogManager().deleteAll();
            return null;
        }
    });
    List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().list();
    for (HistoricProcessInstance historicProcessInstance : historicProcessInstances) {
        historyService.deleteHistoricProcessInstance(historicProcessInstance.getId());
    }
    List<HistoricDecisionInstance> historicDecisionInstances = historyService.createHistoricDecisionInstanceQuery().list();
    for (HistoricDecisionInstance historicDecisionInstance : historicDecisionInstances) {
        historyService.deleteHistoricDecisionInstanceByInstanceId(historicDecisionInstance.getId());
    }
    List<HistoricCaseInstance> historicCaseInstances = historyService.createHistoricCaseInstanceQuery().list();
    for (HistoricCaseInstance historicCaseInstance : historicCaseInstances) {
        historyService.deleteHistoricCaseInstance(historicCaseInstance.getId());
    }
    clearMetrics();
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) HistoricDecisionInstance(org.camunda.bpm.engine.history.HistoricDecisionInstance) JobEntity(org.camunda.bpm.engine.impl.persistence.entity.JobEntity) HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) HistoricIncidentEntity(org.camunda.bpm.engine.impl.persistence.entity.HistoricIncidentEntity) HistoricCaseInstance(org.camunda.bpm.engine.history.HistoricCaseInstance) List(java.util.List) After(org.junit.After)

Example 10 with HistoricIncident

use of org.camunda.bpm.engine.history.HistoricIncident in project camunda-bpm-platform by camunda.

the class HistoryCleanupTest method clearDatabase.

@After
public void clearDatabase() {
    // reset configuration changes
    processEngineConfiguration.setHistoryCleanupBatchWindowStartTime(defaultStartTime);
    processEngineConfiguration.setHistoryCleanupBatchWindowEndTime(defaultEndTime);
    processEngineConfiguration.setHistoryCleanupBatchSize(defaultBatchSize);
    processEngineConfiguration.getCommandExecutorTxRequired().execute(new Command<Void>() {

        public Void execute(CommandContext commandContext) {
            List<Job> jobs = managementService.createJobQuery().list();
            if (jobs.size() > 0) {
                assertEquals(1, jobs.size());
                String jobId = jobs.get(0).getId();
                commandContext.getJobManager().deleteJob((JobEntity) jobs.get(0));
                commandContext.getHistoricJobLogManager().deleteHistoricJobLogByJobId(jobId);
            }
            List<HistoricIncident> historicIncidents = historyService.createHistoricIncidentQuery().list();
            for (HistoricIncident historicIncident : historicIncidents) {
                commandContext.getDbEntityManager().delete((HistoricIncidentEntity) historicIncident);
            }
            commandContext.getMeterLogManager().deleteAll();
            return null;
        }
    });
    List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().list();
    for (HistoricProcessInstance historicProcessInstance : historicProcessInstances) {
        historyService.deleteHistoricProcessInstance(historicProcessInstance.getId());
    }
    List<HistoricDecisionInstance> historicDecisionInstances = historyService.createHistoricDecisionInstanceQuery().list();
    for (HistoricDecisionInstance historicDecisionInstance : historicDecisionInstances) {
        historyService.deleteHistoricDecisionInstanceByInstanceId(historicDecisionInstance.getId());
    }
    List<HistoricCaseInstance> historicCaseInstances = historyService.createHistoricCaseInstanceQuery().list();
    for (HistoricCaseInstance historicCaseInstance : historicCaseInstances) {
        historyService.deleteHistoricCaseInstance(historicCaseInstance.getId());
    }
    clearMetrics();
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) HistoricDecisionInstance(org.camunda.bpm.engine.history.HistoricDecisionInstance) JobEntity(org.camunda.bpm.engine.impl.persistence.entity.JobEntity) HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) HistoricIncidentEntity(org.camunda.bpm.engine.impl.persistence.entity.HistoricIncidentEntity) HistoricCaseInstance(org.camunda.bpm.engine.history.HistoricCaseInstance) List(java.util.List) ArrayList(java.util.ArrayList) After(org.junit.After)

Aggregations

HistoricIncident (org.camunda.bpm.engine.history.HistoricIncident)25 Deployment (org.camunda.bpm.engine.test.Deployment)12 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)8 List (java.util.List)7 HistoricIncidentEntity (org.camunda.bpm.engine.impl.persistence.entity.HistoricIncidentEntity)7 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)7 HistoricIncidentQuery (org.camunda.bpm.engine.history.HistoricIncidentQuery)6 CommandExecutor (org.camunda.bpm.engine.impl.interceptor.CommandExecutor)5 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)4 ArrayList (java.util.ArrayList)3 HistoricCaseInstance (org.camunda.bpm.engine.history.HistoricCaseInstance)3 HistoricDecisionInstance (org.camunda.bpm.engine.history.HistoricDecisionInstance)3 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)3 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)3 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)3 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)3 Incident (org.camunda.bpm.engine.runtime.Incident)3 Test (org.junit.Test)3 LockedExternalTask (org.camunda.bpm.engine.externaltask.LockedExternalTask)2 Job (org.camunda.bpm.engine.runtime.Job)2