Skip to content

Commit f516af4

Browse files
Changes after review
1 parent 3e098a5 commit f516af4

6 files changed

Lines changed: 32 additions & 38 deletions

File tree

modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/CmmnHistoryConfigurationSettings.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,14 @@ public interface CmmnHistoryConfigurationSettings {
6060
boolean isHistoryEnabledForPlanItemInstance(PlanItemInstanceEntity planItemInstanceEntity);
6161

6262
/**
63-
* Returns whether history is enabled for the provided user task.
63+
* Returns whether history is enabled for the provided human task.
6464
*/
65-
boolean isHistoryEnabledForUserTask(TaskInfo taskInfo);
65+
boolean isHistoryEnabledForHumanTask(TaskInfo taskInfo);
66+
67+
/**
68+
* Returns whether task history is enabled for the provided case definition id.
69+
*/
70+
boolean isHistoryEnabledForHumanTask(String caseDefinitionId);
6671

6772
/**
6873
* Returns whether history is enabled for the provided variable instance.

modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/DefaultCmmnHistoryConfigurationSettings.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
import org.apache.commons.lang3.StringUtils;
1616
import org.flowable.cmmn.api.repository.CaseDefinition;
1717
import org.flowable.cmmn.engine.CmmnEngineConfiguration;
18-
import org.flowable.cmmn.engine.impl.process.ProcessInstanceService;
1918
import org.flowable.cmmn.engine.impl.persistence.entity.CaseInstanceEntity;
2019
import org.flowable.cmmn.engine.impl.persistence.entity.MilestoneInstanceEntity;
2120
import org.flowable.cmmn.engine.impl.persistence.entity.PlanItemInstanceEntity;
21+
import org.flowable.cmmn.engine.impl.process.ProcessInstanceService;
2222
import org.flowable.cmmn.engine.impl.repository.CaseDefinitionUtil;
2323
import org.flowable.cmmn.model.Case;
2424
import org.flowable.cmmn.model.CmmnModel;
@@ -170,11 +170,16 @@ public boolean isHistoryEnabledForPlanItemInstance(PlanItemInstanceEntity planIt
170170
}
171171

172172
@Override
173-
public boolean isHistoryEnabledForUserTask(TaskInfo taskInfo) {
173+
public boolean isHistoryEnabledForHumanTask(TaskInfo taskInfo) {
174174
String scopeDefinitionId = taskInfo.getScopeDefinitionId();
175+
return isHistoryEnabledForHumanTask(scopeDefinitionId);
176+
}
177+
178+
@Override
179+
public boolean isHistoryEnabledForHumanTask(String caseDefinitionId) {
175180
HistoryLevel engineHistoryLevel = cmmnEngineConfiguration.getHistoryLevel();
176-
if (isEnableCaseDefinitionHistoryLevel() && scopeDefinitionId != null) {
177-
HistoryLevel caseDefinitionLevel = getCaseDefinitionHistoryLevel(scopeDefinitionId);
181+
if (isEnableCaseDefinitionHistoryLevel() && caseDefinitionId != null) {
182+
HistoryLevel caseDefinitionLevel = getCaseDefinitionHistoryLevel(caseDefinitionId);
178183
if (caseDefinitionLevel != null) {
179184
if (LOGGER.isDebugEnabled()) {
180185
LOGGER.debug("Current history level: {}, level required: {}", caseDefinitionLevel, HistoryLevel.TASK);
@@ -223,7 +228,7 @@ public boolean isHistoryEnabledForVariableInstance(VariableInstanceEntity variab
223228
public boolean isHistoryEnabledForIdentityLink(IdentityLinkEntity identityLinkEntity) {
224229
String caseDefinitionId = getCaseDefinitionId(identityLinkEntity);
225230
if (identityLinkEntity.getTaskId() != null) {
226-
return isHistoryLevelAtLeast(HistoryLevel.TASK, caseDefinitionId);
231+
return isHistoryEnabledForHumanTask(caseDefinitionId);
227232
}
228233
return isHistoryLevelAtLeast(HistoryLevel.INSTANCE, caseDefinitionId);
229234
}

modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/DefaultCmmnHistoryManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,14 +259,14 @@ public void recordVariableRemoved(VariableInstanceEntity variableInstanceEntity)
259259

260260
@Override
261261
public void recordTaskCreated(TaskEntity task) {
262-
if (getHistoryConfigurationSettings().isHistoryEnabledForUserTask(task)) {
262+
if (getHistoryConfigurationSettings().isHistoryEnabledForHumanTask(task)) {
263263
cmmnEngineConfiguration.getTaskServiceConfiguration().getHistoricTaskService().recordTaskCreated(task);
264264
}
265265
}
266266

267267
@Override
268268
public void recordTaskEnd(TaskEntity task, String userId, String deleteReason, Date endTime) {
269-
if (getHistoryConfigurationSettings().isHistoryEnabledForUserTask(task)) {
269+
if (getHistoryConfigurationSettings().isHistoryEnabledForHumanTask(task)) {
270270
HistoricTaskInstanceEntity historicTaskInstance = cmmnEngineConfiguration.getTaskServiceConfiguration().getHistoricTaskService().recordTaskEnd(task, deleteReason, endTime);
271271
if (historicTaskInstance != null) {
272272
historicTaskInstance.setState(Task.COMPLETED);
@@ -278,14 +278,14 @@ public void recordTaskEnd(TaskEntity task, String userId, String deleteReason, D
278278

279279
@Override
280280
public void recordTaskInfoChange(TaskEntity task, Date changeTime) {
281-
if (getHistoryConfigurationSettings().isHistoryEnabledForUserTask(task)) {
281+
if (getHistoryConfigurationSettings().isHistoryEnabledForHumanTask(task)) {
282282
cmmnEngineConfiguration.getTaskServiceConfiguration().getHistoricTaskService().recordTaskInfoChange(task, changeTime, cmmnEngineConfiguration);
283283
}
284284
}
285285

286286
@Override
287287
public void recordHistoricTaskDeleted(HistoricTaskInstance task) {
288-
if (task != null && getHistoryConfigurationSettings().isHistoryEnabledForUserTask(task)) {
288+
if (task != null && getHistoryConfigurationSettings().isHistoryEnabledForHumanTask(task)) {
289289
TaskHelper.deleteHistoricTask(task.getId(), cmmnEngineConfiguration);
290290
}
291291
}

modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/history/HistoryLevelIdentityLinkTest.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
import org.flowable.common.engine.impl.identity.Authentication;
2424
import org.flowable.identitylink.api.IdentityLinkType;
2525
import org.flowable.identitylink.api.history.HistoricIdentityLink;
26-
import org.flowable.identitylink.service.HistoricIdentityLinkService;
2726
import org.flowable.identitylink.service.impl.persistence.entity.HistoricIdentityLinkEntity;
2827
import org.flowable.task.api.Task;
28+
import org.flowable.task.api.history.HistoricTaskInstance;
2929
import org.junit.jupiter.api.AfterEach;
3030
import org.junit.jupiter.api.Test;
3131

@@ -143,6 +143,9 @@ public void testActivityHistoryLevelStoresCaseInstanceAndTaskIdentityLinks() {
143143
// Case instance links: starter + participant + participant from candidate user interceptor
144144
List<HistoricIdentityLink> caseIdentityLinks = cmmnHistoryService.getHistoricIdentityLinksForCaseInstance(caseInstance.getId());
145145
assertThat(caseIdentityLinks).hasSize(3);
146+
147+
HistoricTaskInstance historyTaskInstance = cmmnHistoryService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult();
148+
assertThat(historyTaskInstance).isNull();
146149

147150
// Task identity links: candidate user + candidate group
148151
// At activity level, historic tasks are not stored, so we query via the service directly
@@ -151,22 +154,11 @@ public void testActivityHistoryLevelStoresCaseInstanceAndTaskIdentityLinks() {
151154
.getHistoricIdentityLinkService()
152155
.findHistoricIdentityLinksByTaskId(task.getId());
153156
});
154-
assertThat(taskLinks).hasSize(2);
157+
assertThat(taskLinks).hasSize(0);
155158

156159
cmmnTaskService.complete(task.getId());
157160

158161
CmmnHistoryTestHelper.waitForJobExecutorToProcessAllHistoryJobs(cmmnEngineConfiguration, cmmnManagementService, 7000, 200);
159-
160-
// Clean up task identity links that are not associated with a case instance
161-
// (at activity level, no historic task exists so these are not cascade-deleted)
162-
cmmnEngineConfiguration.getCommandExecutor().execute(commandContext -> {
163-
HistoricIdentityLinkService historicIdentityLinkService = cmmnEngineConfiguration.getIdentityLinkServiceConfiguration()
164-
.getHistoricIdentityLinkService();
165-
for (HistoricIdentityLinkEntity link : taskLinks) {
166-
historicIdentityLinkService.deleteHistoricIdentityLink(link.getId());
167-
}
168-
return null;
169-
});
170162
}
171163

172164
@Test

modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/DefaultHistoryConfigurationSettings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ public boolean isHistoryEnabledForVariables(String processDefinitionId) {
292292
public boolean isHistoryEnabledForIdentityLink(IdentityLinkEntity identityLink) {
293293
String processDefinitionId = getProcessDefinitionId(identityLink);
294294
if (identityLink.getTaskId() != null) {
295-
return isHistoryLevelAtLeast(HistoryLevel.TASK, processDefinitionId);
295+
return isHistoryEnabledForUserTask(processDefinitionId);
296296
}
297297
return isHistoryLevelAtLeast(HistoryLevel.INSTANCE, processDefinitionId);
298298
}

modules/flowable-engine/src/test/java/org/flowable/engine/test/api/history/HistoryLevelIdentityLinkTest.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
import org.flowable.engine.test.Deployment;
2424
import org.flowable.identitylink.api.IdentityLinkType;
2525
import org.flowable.identitylink.api.history.HistoricIdentityLink;
26-
import org.flowable.identitylink.service.HistoricIdentityLinkService;
2726
import org.flowable.identitylink.service.impl.persistence.entity.HistoricIdentityLinkEntity;
2827
import org.flowable.task.api.Task;
28+
import org.flowable.task.api.history.HistoricTaskInstance;
2929
import org.junit.jupiter.api.Test;
3030

3131
public class HistoryLevelIdentityLinkTest extends PluggableFlowableTestCase {
@@ -129,6 +129,9 @@ public void testActivityHistoryLevelStoresProcessInstanceAndTaskIdentityLinks()
129129
// Process instance links: starter + participant + participant from candidate user interceptor
130130
List<HistoricIdentityLink> processIdentityLinks = historyService.getHistoricIdentityLinksForProcessInstance(processInstance.getId());
131131
assertThat(processIdentityLinks).hasSize(3);
132+
133+
HistoricTaskInstance historyTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult();
134+
assertThat(historyTaskInstance).isNull();
132135

133136
// Task identity links: candidate user + candidate group
134137
// At activity level, historic tasks are not stored, so we query via the service directly
@@ -137,22 +140,11 @@ public void testActivityHistoryLevelStoresProcessInstanceAndTaskIdentityLinks()
137140
.getHistoricIdentityLinkService()
138141
.findHistoricIdentityLinksByTaskId(task.getId());
139142
});
140-
assertThat(taskLinks).hasSize(2);
143+
assertThat(taskLinks).hasSize(0);
141144

142145
taskService.complete(task.getId());
143146

144147
HistoryTestHelper.waitForJobExecutorToProcessAllHistoryJobs(processEngineConfiguration, managementService, 7000, 200);
145-
146-
// Clean up task identity links that are not associated with a process instance
147-
// (at activity level, no historic task exists so these are not cascade-deleted)
148-
managementService.executeCommand(commandContext -> {
149-
HistoricIdentityLinkService historicIdentityLinkService = processEngineConfiguration.getIdentityLinkServiceConfiguration()
150-
.getHistoricIdentityLinkService();
151-
for (HistoricIdentityLinkEntity link : taskLinks) {
152-
historicIdentityLinkService.deleteHistoricIdentityLink(link.getId());
153-
}
154-
return null;
155-
});
156148
}
157149

158150
@Deployment(resources = { "org/flowable/engine/test/api/history/oneTaskHistoryLevelNoneProcess.bpmn20.xml" })

0 commit comments

Comments
 (0)