diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/DefaultCmmnHistoryManager.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/DefaultCmmnHistoryManager.java index 61843495baa..d4e9e2e867e 100644 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/DefaultCmmnHistoryManager.java +++ b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/DefaultCmmnHistoryManager.java @@ -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 diff --git a/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/history/HistoryLevelServiceTest.java b/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/history/HistoryLevelServiceTest.java index a7c0fcc2e86..3f3e80fbd83 100644 --- a/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/history/HistoryLevelServiceTest.java +++ b/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/history/HistoryLevelServiceTest.java @@ -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() { diff --git a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/history/testOneSimpleHumanTaskWithHistoryLevelNone.cmmn b/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/history/testOneSimpleHumanTaskWithHistoryLevelNone.cmmn new file mode 100644 index 00000000000..3ec4b463ecc --- /dev/null +++ b/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/history/testOneSimpleHumanTaskWithHistoryLevelNone.cmmn @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/DefaultHistoryManager.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/DefaultHistoryManager.java index da18dedd7b2..02f531d5e32 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/DefaultHistoryManager.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/DefaultHistoryManager.java @@ -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 diff --git a/modules/flowable-engine/src/test/java/org/flowable/engine/test/api/history/HistoryLevelServiceTest.java b/modules/flowable-engine/src/test/java/org/flowable/engine/test/api/history/HistoryLevelServiceTest.java index 27f5fcbd971..5ed57b0e930 100644 --- a/modules/flowable-engine/src/test/java/org/flowable/engine/test/api/history/HistoryLevelServiceTest.java +++ b/modules/flowable-engine/src/test/java/org/flowable/engine/test/api/history/HistoryLevelServiceTest.java @@ -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"); @@ -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" }) @@ -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(); @@ -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" }) @@ -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" }) @@ -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" }) @@ -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" }) @@ -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" }) @@ -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" }) @@ -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" })