Search in sources :

Example 16 with HistoricIncident

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

the class HistoricIncidentRestServiceImpl method getHistoricIncidents.

@Override
public List<HistoricIncidentDto> getHistoricIncidents(UriInfo uriInfo, Integer firstResult, Integer maxResults) {
    HistoricIncidentQueryDto queryDto = new HistoricIncidentQueryDto(objectMapper, uriInfo.getQueryParameters());
    HistoricIncidentQuery query = queryDto.toQuery(processEngine);
    List<HistoricIncident> queryResult;
    if (firstResult != null || maxResults != null) {
        queryResult = executePaginatedQuery(query, firstResult, maxResults);
    } else {
        queryResult = query.list();
    }
    List<HistoricIncidentDto> result = new ArrayList<HistoricIncidentDto>();
    for (HistoricIncident historicIncident : queryResult) {
        HistoricIncidentDto dto = HistoricIncidentDto.fromHistoricIncident(historicIncident);
        result.add(dto);
    }
    return result;
}
Also used : HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) HistoricIncidentQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricIncidentQueryDto) ArrayList(java.util.ArrayList) HistoricIncidentDto(org.camunda.bpm.engine.rest.dto.history.HistoricIncidentDto) HistoricIncidentQuery(org.camunda.bpm.engine.history.HistoricIncidentQuery)

Example 17 with HistoricIncident

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

the class MigrationIncidentTest method historicIncidentRemainsOpenAfterMigration.

@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/migration/calledProcess.bpmn", "org/camunda/bpm/engine/test/api/runtime/migration/calledProcess_v2.bpmn" })
public void historicIncidentRemainsOpenAfterMigration() {
    // Given we create a new process instance
    ProcessDefinition process1 = engineRule.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey("calledProcess").singleResult();
    ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceById(process1.getId());
    LockedExternalTask task = engineRule.getExternalTaskService().fetchAndLock(1, "foo").topic("foo", 1000L).execute().get(0);
    engineRule.getExternalTaskService().handleFailure(task.getId(), "foo", "error", 0, 1000L);
    Incident incidentInProcess = engineRule.getRuntimeService().createIncidentQuery().processDefinitionId(process1.getId()).singleResult();
    // when
    ProcessDefinition process2 = engineRule.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey("calledProcessV2").singleResult();
    MigrationPlan migrationPlan = engineRule.getRuntimeService().createMigrationPlan(process1.getId(), process2.getId()).mapEqualActivities().mapActivities("ServiceTask_1p58ywb", "ServiceTask_V2").build();
    engineRule.getRuntimeService().newMigration(migrationPlan).processInstanceIds(processInstance.getId()).execute();
    // then
    HistoricIncident historicIncidentAfterMigration = engineRule.getHistoryService().createHistoricIncidentQuery().singleResult();
    assertNotNull(historicIncidentAfterMigration);
    assertNull(historicIncidentAfterMigration.getEndTime());
    assertTrue(historicIncidentAfterMigration.isOpen());
    HistoricProcessInstance historicProcessInstanceAfterMigration = engineRule.getHistoryService().createHistoricProcessInstanceQuery().withIncidents().incidentStatus("open").singleResult();
    assertNotNull(historicProcessInstanceAfterMigration);
    Incident incidentAfterMigration = engineRule.getRuntimeService().createIncidentQuery().incidentId(incidentInProcess.getId()).singleResult();
    assertEquals(process2.getId(), incidentAfterMigration.getProcessDefinitionId());
    assertEquals("ServiceTask_V2", incidentAfterMigration.getActivityId());
}
Also used : HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) Incident(org.camunda.bpm.engine.runtime.Incident) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Example 18 with HistoricIncident

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

the class UserOperationLogAuthorizationTest 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)

Example 19 with HistoricIncident

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

the class HistoricIncidentTest method testSetHistoricIncidentToResolved.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneFailingServiceProcess.bpmn20.xml" })
public void testSetHistoricIncidentToResolved() {
    startProcessInstance(PROCESS_DEFINITION_KEY);
    String jobId = managementService.createJobQuery().singleResult().getId();
    managementService.setJobRetries(jobId, 1);
    HistoricIncident historicIncident = historyService.createHistoricIncidentQuery().singleResult();
    assertNotNull(historicIncident);
    assertNotNull(historicIncident.getEndTime());
    assertFalse(historicIncident.isOpen());
    assertFalse(historicIncident.isDeleted());
    assertTrue(historicIncident.isResolved());
}
Also used : HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 20 with HistoricIncident

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

the class HistoricIncidentTest method testSetHistoricIncidentToDeleted.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneFailingServiceProcess.bpmn20.xml" })
public void testSetHistoricIncidentToDeleted() {
    startProcessInstance(PROCESS_DEFINITION_KEY);
    String processInstanceId = runtimeService.createProcessInstanceQuery().singleResult().getId();
    runtimeService.deleteProcessInstance(processInstanceId, null);
    HistoricIncident historicIncident = historyService.createHistoricIncidentQuery().singleResult();
    assertNotNull(historicIncident);
    assertNotNull(historicIncident.getEndTime());
    assertFalse(historicIncident.isOpen());
    assertTrue(historicIncident.isDeleted());
    assertFalse(historicIncident.isResolved());
}
Also used : HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) Deployment(org.camunda.bpm.engine.test.Deployment)

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