Skip to content

Commit

Permalink
added method to check history level of historic task instances
Browse files Browse the repository at this point in the history
  • Loading branch information
WelschChristopher committed Jan 24, 2024
1 parent c2b094e commit 5e069d2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@
import org.flowable.bpmn.model.Process;
import org.flowable.common.engine.api.scope.ScopeTypes;
import org.flowable.common.engine.impl.history.HistoryLevel;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.impl.persistence.entity.ExecutionEntity;
import org.flowable.engine.impl.persistence.entity.HistoricProcessInstanceEntity;
import org.flowable.engine.impl.util.ProcessDefinitionUtil;
import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.engine.runtime.ActivityInstance;
import org.flowable.entitylink.service.impl.persistence.entity.EntityLinkEntity;
import org.flowable.identitylink.service.impl.persistence.entity.IdentityLinkEntity;
import org.flowable.task.api.TaskInfo;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.task.service.impl.persistence.entity.TaskEntity;
import org.flowable.variable.service.impl.persistence.entity.VariableInstanceEntity;
import org.slf4j.Logger;
Expand Down Expand Up @@ -283,7 +284,7 @@ public boolean isHistoryEnabledForVariableInstance(String processDefinitionId, V
}

@Override
public boolean isHistoryEnabledForVariables(HistoricProcessInstanceEntity historicProcessInstance) {
public boolean isHistoryEnabledForVariables(HistoricProcessInstance historicProcessInstance) {
return processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY);
}

Expand Down Expand Up @@ -315,6 +316,11 @@ public boolean isHistoryEnabledForEntityLink(EntityLinkEntity entityLink) {
return isHistoryLevelAtLeast(HistoryLevel.AUDIT, processDefinitionId);
}

@Override
public boolean isHistoryEnabledForVariables(HistoricTaskInstance historicTaskInstance) {
return processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY);
}

protected String getProcessDefinitionId(EntityLinkEntity entityLink) {
String processDefinitionId = null;
if (ScopeTypes.BPMN.equals(entityLink.getScopeType()) && entityLink.getScopeId() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
package org.flowable.engine.impl.history;

import org.flowable.common.engine.impl.history.HistoryLevel;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.impl.persistence.entity.ExecutionEntity;
import org.flowable.engine.impl.persistence.entity.HistoricProcessInstanceEntity;
import org.flowable.engine.runtime.ActivityInstance;
import org.flowable.entitylink.service.impl.persistence.entity.EntityLinkEntity;
import org.flowable.identitylink.service.impl.persistence.entity.IdentityLinkEntity;
import org.flowable.task.api.TaskInfo;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.task.service.impl.persistence.entity.TaskEntity;
import org.flowable.variable.service.impl.persistence.entity.VariableInstanceEntity;

Expand Down Expand Up @@ -85,7 +86,12 @@ public interface HistoryConfigurationSettings {
/**
* Returns whether history is enabled for variables for the provided historic process instance.
*/
boolean isHistoryEnabledForVariables(HistoricProcessInstanceEntity historicProcessInstance);
boolean isHistoryEnabledForVariables(HistoricProcessInstance historicProcessInstance);

/**
* Returns whether variable history is enabled for the provided historic task instance.
*/
boolean isHistoryEnabledForVariables(HistoricTaskInstance historicTaskInstance);

/**
* Returns whether history is enabled for the provided identity link.
Expand All @@ -96,5 +102,4 @@ public interface HistoryConfigurationSettings {
* Returns whether history is enabled for the provided entity link.
*/
boolean isHistoryEnabledForEntityLink(EntityLinkEntity entityLink);

}
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ public static void deleteHistoricTask(String taskId) {
}

processEngineConfiguration.getHistoricDetailEntityManager().deleteHistoricDetailsByTaskId(taskId);
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
if (processEngineConfiguration.getHistoryConfigurationSettings().isHistoryEnabledForVariables(historicTaskInstance)) {
processEngineConfiguration.getVariableServiceConfiguration().getHistoricVariableService().deleteHistoricVariableInstancesByTaskId(taskId);
}
processEngineConfiguration.getIdentityLinkServiceConfiguration().getHistoricIdentityLinkService().deleteHistoricIdentityLinksByTaskId(taskId);
Expand Down

0 comments on commit 5e069d2

Please sign in to comment.