Search in sources :

Example 11 with HistoricDecisionInstance

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

the class BulkHistoryDeleteTest method collectHistoricDecisionOutputIds.

private void collectHistoricDecisionOutputIds(List<HistoricDecisionInstance> historicDecisionInstances, List<String> historicDecisionOutputIds, List<String> outputByteArrayId) {
    for (HistoricDecisionInstance historicDecisionInstance : historicDecisionInstances) {
        for (HistoricDecisionOutputInstance outputInstanceEntity : historicDecisionInstance.getOutputs()) {
            historicDecisionOutputIds.add(outputInstanceEntity.getId());
            final String byteArrayValueId = ((HistoricDecisionOutputInstanceEntity) outputInstanceEntity).getByteArrayValueId();
            if (byteArrayValueId != null) {
                outputByteArrayId.add(byteArrayValueId);
            }
        }
    }
    assertEquals(PROCESS_INSTANCE_COUNT, historicDecisionOutputIds.size());
}
Also used : HistoricDecisionOutputInstanceEntity(org.camunda.bpm.engine.impl.history.event.HistoricDecisionOutputInstanceEntity) HistoricDecisionInstance(org.camunda.bpm.engine.history.HistoricDecisionInstance) HistoricDecisionOutputInstance(org.camunda.bpm.engine.history.HistoricDecisionOutputInstance)

Example 12 with HistoricDecisionInstance

use of org.camunda.bpm.engine.history.HistoricDecisionInstance 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 13 with HistoricDecisionInstance

use of org.camunda.bpm.engine.history.HistoricDecisionInstance 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)

Example 14 with HistoricDecisionInstance

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

the class HistoricDecisionInstanceTest method testManualActivationRuleEvaluatesDecision.

@Deployment(resources = { DECISION_CASE_WITH_DECISION_SERVICE_INSIDE_RULE, DECISION_RETURNS_TRUE })
public void testManualActivationRuleEvaluatesDecision() {
    CaseInstance caseInstance = caseService.withCaseDefinitionByKey("case").setVariable("input1", null).setVariable("myBean", new DecisionServiceDelegate()).create();
    CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().caseDefinitionId(caseInstance.getCaseDefinitionId()).singleResult();
    String decisionDefinitionId = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(DECISION_DEFINITION_KEY).singleResult().getId();
    String activityInstanceId = historyService.createHistoricCaseActivityInstanceQuery().caseActivityId("PI_HumanTask_1").singleResult().getId();
    HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery().singleResult();
    assertThat(historicDecisionInstance, is(notNullValue()));
    assertThat(historicDecisionInstance.getDecisionDefinitionId(), is(decisionDefinitionId));
    assertThat(historicDecisionInstance.getDecisionDefinitionKey(), is(DECISION_DEFINITION_KEY));
    assertThat(historicDecisionInstance.getDecisionDefinitionName(), is("sample decision"));
    // references to case instance should be set since the decision is evaluated while executing a case instance
    assertThat(historicDecisionInstance.getProcessDefinitionKey(), is(nullValue()));
    assertThat(historicDecisionInstance.getProcessDefinitionId(), is(nullValue()));
    assertThat(historicDecisionInstance.getProcessInstanceId(), is(nullValue()));
    assertThat(historicDecisionInstance.getCaseDefinitionKey(), is(caseDefinition.getKey()));
    assertThat(historicDecisionInstance.getCaseDefinitionId(), is(caseDefinition.getId()));
    assertThat(historicDecisionInstance.getCaseInstanceId(), is(caseInstance.getId()));
    assertThat(historicDecisionInstance.getActivityId(), is("PI_HumanTask_1"));
    assertThat(historicDecisionInstance.getActivityInstanceId(), is(activityInstanceId));
    assertThat(historicDecisionInstance.getEvaluationTime(), is(notNullValue()));
}
Also used : DecisionServiceDelegate(org.camunda.bpm.engine.test.history.DecisionServiceDelegate) CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) HistoricDecisionInstance(org.camunda.bpm.engine.history.HistoricDecisionInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 15 with HistoricDecisionInstance

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

the class HistoricDecisionInstanceTest method testMultipleDecisionInputInstances.

@Deployment(resources = { DECISION_PROCESS, DECISION_MULTIPLE_INPUT_DMN })
public void testMultipleDecisionInputInstances() {
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("input1", "a");
    variables.put("input2", 1);
    runtimeService.startProcessInstanceByKey("testProcess", variables);
    HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery().includeInputs().singleResult();
    List<HistoricDecisionInputInstance> inputs = historicDecisionInstance.getInputs();
    assertThat(inputs.size(), is(2));
    assertThat(inputs.get(0).getValue(), is((Object) "a"));
    assertThat(inputs.get(1).getValue(), is((Object) 1));
}
Also used : HistoricDecisionInputInstance(org.camunda.bpm.engine.history.HistoricDecisionInputInstance) HashMap(java.util.HashMap) HistoricDecisionInstance(org.camunda.bpm.engine.history.HistoricDecisionInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

HistoricDecisionInstance (org.camunda.bpm.engine.history.HistoricDecisionInstance)51 Deployment (org.camunda.bpm.engine.test.Deployment)23 HistoricDecisionOutputInstance (org.camunda.bpm.engine.history.HistoricDecisionOutputInstance)9 Test (org.junit.Test)9 HistoricDecisionInputInstance (org.camunda.bpm.engine.history.HistoricDecisionInputInstance)8 ArrayList (java.util.ArrayList)7 HistoricDecisionInstanceQuery (org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery)7 VariableMap (org.camunda.bpm.engine.variable.VariableMap)6 List (java.util.List)4 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)4 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)4 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)4 CaseDefinition (org.camunda.bpm.engine.repository.CaseDefinition)4 CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)4 HashMap (java.util.HashMap)3 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)3 HistoricCaseInstance (org.camunda.bpm.engine.history.HistoricCaseInstance)3 HistoricIncident (org.camunda.bpm.engine.history.HistoricIncident)3 HistoricIncidentEntity (org.camunda.bpm.engine.impl.persistence.entity.HistoricIncidentEntity)3 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)3