Skip to content

Commit

Permalink
Do not create historic task log entries when history level is NONE (f…
Browse files Browse the repository at this point in the history
  • Loading branch information
WelschChristopher authored May 17, 2024
1 parent c572788 commit 270753a
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,9 @@ public void updateCaseDefinitionIdInHistory(CaseDefinition caseDefinition, CaseI

@Override
public void recordHistoricUserTaskLogEntry(HistoricTaskLogEntryBuilder taskLogEntryBuilder) {
cmmnEngineConfiguration.getTaskServiceConfiguration().getHistoricTaskService().createHistoricTaskLogEntry(taskLogEntryBuilder);
if (getHistoryConfigurationSettings().isHistoryEnabled(taskLogEntryBuilder.getScopeDefinitionId())) {
cmmnEngineConfiguration.getTaskServiceConfiguration().getHistoricTaskService().createHistoricTaskLogEntry(taskLogEntryBuilder);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,30 @@ public void testTaskLevelTwoTasks() {
assertThat(cmmnHistoryService.createHistoricMilestoneInstanceQuery().count()).isZero();
assertThat(cmmnHistoryService.createHistoricVariableInstanceQuery().count()).isZero();
}


@Test
@CmmnDeployment(resources = "org/flowable/cmmn/test/history/testOneSimpleHumanTaskWithHistoryLevelNone.cmmn")
public void testNoneHistoryLevel() {
CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder()
.caseDefinitionKey("myCase")
.variable("var1", "test")
.variable("var2", 10)
.start();

Task task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult();
cmmnTaskService.complete(task.getId());

CmmnHistoryTestHelper.waitForJobExecutorToProcessAllHistoryJobs(cmmnEngineConfiguration, cmmnManagementService, 10000, 200);

assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().count()).isZero();
assertThat(cmmnHistoryService.createHistoricTaskInstanceQuery().count()).isZero();
assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().count()).isZero();
assertThat(cmmnHistoryService.createHistoricMilestoneInstanceQuery().count()).isZero();
assertThat(cmmnHistoryService.createHistoricVariableInstanceQuery().count()).isZero();
assertThat(cmmnHistoryService.createHistoricTaskLogEntryQuery().count()).isZero();

}

@Test
@CmmnDeployment(resources = "org/flowable/cmmn/test/history/testTwoTaskCaseTaskLevelPlanItems.cmmn")
public void testTaskLevelTwoTasksWithCustomPlanItems() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/CMMN/20151109/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:flowable="http://flowable.org/cmmn" xmlns:cmmndi="http://www.omg.org/spec/CMMN/20151109/CMMNDI" xmlns:dc="http://www.omg.org/spec/CMMN/20151109/DC" xmlns:di="http://www.omg.org/spec/CMMN/20151109/DI" xmlns:design="http://flowable.org/design" targetNamespace="http://flowable.org/cmmn" design:palette="flowable-work-case-palette">
<case id="myCase" name="Test" flowable:initiatorVariableName="initiator" flowable:candidateStarterGroups="flowableUser">
<casePlanModel id="onecaseplanmodel1" name="Case plan model" flowable:formFieldValidation="false">
<extensionElements>
<flowable:default-menu-navigation-size><![CDATA[expanded]]></flowable:default-menu-navigation-size>
<flowable:historyLevel><![CDATA[none]]></flowable:historyLevel>
<flowable:work-form-field-validation><![CDATA[false]]></flowable:work-form-field-validation>
<design:stencilid><![CDATA[CasePlanModel]]></design:stencilid>
</extensionElements>
<planItem id="planItemcmmnTask_1" name="Human task" definitionRef="cmmnTask_1"></planItem>
<humanTask id="cmmnTask_1" name="Human task" flowable:assignee="${initiator}" flowable:formFieldValidation="false">
<extensionElements>
<flowable:task-candidates-type><![CDATA[all]]></flowable:task-candidates-type>
<design:stencilid><![CDATA[HumanTask]]></design:stencilid>
<design:stencilsuperid><![CDATA[Task]]></design:stencilsuperid>
</extensionElements>
</humanTask>
</casePlanModel>
</case>
</definitions>
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,9 @@ public void updateHistoricActivityInstance(ActivityInstance activityInstance) {

@Override
public void recordHistoricUserTaskLogEntry(HistoricTaskLogEntryBuilder taskLogEntryBuilder) {
processEngineConfiguration.getTaskServiceConfiguration().getHistoricTaskService().createHistoricTaskLogEntry(taskLogEntryBuilder);
if (isHistoryEnabled(taskLogEntryBuilder.getProcessDefinitionId())) {
processEngineConfiguration.getTaskServiceConfiguration().getHistoricTaskService().createHistoricTaskLogEntry(taskLogEntryBuilder);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public void testNoneHistoryLevel() {

// Complete the task and check if the size is count 1
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
assertThat(historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).count()).isZero();
assertThat(task).isNotNull();
taskService.claim(task.getId(), "test");
taskService.setOwner(task.getId(), "test");
Expand All @@ -66,6 +67,7 @@ public void testNoneHistoryLevel() {
assertThat(historyService.createHistoricTaskInstanceQuery().processInstanceId(processInstance.getId()).count()).isZero();
assertThat(historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstance.getId()).count()).isZero();
assertThat(historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).count()).isZero();
assertThat(historyService.createHistoricTaskLogEntryQuery().processInstanceId(processInstance.getId()).count()).isZero();
}

@Deployment(resources = { "org/flowable/engine/test/api/history/oneTaskHistoryLevelInstanceProcess.bpmn20.xml" })
Expand All @@ -79,7 +81,7 @@ public void testInstanceHistoryLevel() {
assertThat(historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId()).count()).isEqualTo(1);
assertThat(historyService.createHistoricTaskInstanceQuery().processInstanceId(processInstance.getId()).count()).isZero();
assertThat(historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstance.getId()).count()).isZero();

assertThat(historyService.createHistoricTaskLogEntryQuery().processInstanceId(processInstance.getId()).count()).isEqualTo(1);
// Complete the task and check if the size is count 1
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
assertThat(task).isNotNull();
Expand All @@ -103,6 +105,8 @@ public void testInstanceHistoryLevel() {
assertThat(historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstance.getId()).count()).isZero();
assertThat(historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).count()).isZero();
assertThat(historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).count()).isZero();
assertThat(historyService.createHistoricTaskLogEntryQuery().processInstanceId(processInstance.getId()).count()).isEqualTo(7);

}

@Deployment(resources = { "org/flowable/engine/test/api/history/oneTaskHistoryLevelTaskProcess.bpmn20.xml" })
Expand Down Expand Up @@ -140,6 +144,7 @@ public void testTaskHistoryLevel() {
assertThat(historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstance.getId()).count()).isZero();
assertThat(historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).count()).isZero();
assertThat(historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).count()).isZero();
assertThat(historyService.createHistoricTaskLogEntryQuery().processInstanceId(processInstance.getId()).count()).isEqualTo(7);
}

@Deployment(resources = { "org/flowable/engine/test/api/history/oneTaskHistoryLevelInstanceIncludeTaskProcess.bpmn20.xml" })
Expand Down Expand Up @@ -186,6 +191,7 @@ public void testInstanceWithIncludeTaskHistoryLevel() {

assertThat(historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).count()).isZero();
assertThat(historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).count()).isZero();
assertThat(historyService.createHistoricTaskLogEntryQuery().processInstanceId(processInstance.getId()).count()).isEqualTo(7);
}

@Deployment(resources = { "org/flowable/engine/test/api/history/oneTaskHistoryLevelActivityProcess.bpmn20.xml" })
Expand Down Expand Up @@ -235,6 +241,7 @@ public void testActivityHistoryLevel() {
);

assertThat(historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).count()).isZero();
assertThat(historyService.createHistoricTaskLogEntryQuery().processInstanceId(processInstance.getId()).count()).isEqualTo(7);
}

@Deployment(resources = { "org/flowable/engine/test/api/history/oneTaskHistoryLevelAuditProcess.bpmn20.xml" })
Expand Down Expand Up @@ -292,6 +299,7 @@ public void testAuditHistoryLevel() {
);

assertThat(historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).count()).isZero();
assertThat(historyService.createHistoricTaskLogEntryQuery().processInstanceId(processInstance.getId()).count()).isEqualTo(7);
}

@Deployment(resources = { "org/flowable/engine/test/api/history/oneTaskHistoryLevelFullProcess.bpmn20.xml" })
Expand Down Expand Up @@ -349,6 +357,7 @@ public void testFullHistoryLevel() {
);

assertThat(historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).count()).isEqualTo(2);
assertThat(historyService.createHistoricTaskLogEntryQuery().processInstanceId(processInstance.getId()).count()).isEqualTo(7);
}

@Deployment(resources = { "org/flowable/engine/test/api/history/multipleParallelSubProcessesInstanceLevel.bpmn20.xml" })
Expand Down Expand Up @@ -396,6 +405,7 @@ public void testMultipleParallelSubProcessWithInstanceLevelHistory() {

task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).taskDefinitionKey("taskAfter").singleResult();
taskService.complete(task.getId());
assertThat(historyService.createHistoricTaskLogEntryQuery().processInstanceId(processInstance.getId()).count()).isEqualTo(14);
}

@Deployment(resources = { "org/flowable/engine/test/api/history/multipleParallelSubProcessesTaskLevel.bpmn20.xml" })
Expand Down

0 comments on commit 270753a

Please sign in to comment.