Skip to content

Commit

Permalink
added new method to check if isHistoryEnabledForVariables
Browse files Browse the repository at this point in the history
  • Loading branch information
WelschChristopher committed Jan 24, 2024
1 parent 8980e9c commit c2b094e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.flowable.common.engine.impl.history.HistoryLevel;
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;
Expand Down Expand Up @@ -281,6 +282,11 @@ public boolean isHistoryEnabledForVariableInstance(String processDefinitionId, V
return isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, processDefinitionId);
}

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

@Override
public boolean isHistoryEnabledForIdentityLink(IdentityLinkEntity identityLink) {
String processDefinitionId = getProcessDefinitionId(identityLink);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void recordProcessInstanceDeleted(String processInstanceId, String proces
HistoricProcessInstanceEntity historicProcessInstance = getHistoricProcessInstanceEntityManager().findById(processInstanceId);

getHistoricDetailEntityManager().deleteHistoricDetailsByProcessInstanceId(processInstanceId);
if (processEngineConfiguration.getHistoryManager().isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) {
if (getHistoryConfigurationSettings().isHistoryEnabledForVariables(historicProcessInstance)) {
processEngineConfiguration.getVariableServiceConfiguration().getHistoricVariableService().deleteHistoricVariableInstancesByProcessInstanceId(processInstanceId);
}
getHistoricActivityInstanceEntityManager().deleteHistoricActivityInstancesByProcessInstanceId(processInstanceId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import org.flowable.common.engine.impl.history.HistoryLevel;
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;
Expand Down Expand Up @@ -81,6 +82,11 @@ public interface HistoryConfigurationSettings {
*/
boolean isHistoryEnabledForVariableInstance(String processDefinitionId, VariableInstanceEntity variableInstanceEntity);

/**
* Returns whether history is enabled for variables for the provided historic process instance.
*/
boolean isHistoryEnabledForVariables(HistoricProcessInstanceEntity historicProcessInstance);

/**
* Returns whether history is enabled for the provided identity link.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,7 @@ protected void deleteHistoricData(String processInstanceId, String taskId) {
@Override
public Void execute(CommandContext commandContext) {
processEngineConfiguration.getHistoricDetailEntityManager().deleteHistoricDetailsByProcessInstanceId(processInstanceId);

if (processEngineConfiguration.getHistoryManager().isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) {
processEngineConfiguration.getVariableServiceConfiguration().getHistoricVariableService().deleteHistoricVariableInstancesByProcessInstanceId(processInstanceId);
}
processEngineConfiguration.getVariableServiceConfiguration().getHistoricVariableService().deleteHistoricVariableInstancesByProcessInstanceId(processInstanceId);
processEngineConfiguration.getIdentityLinkServiceConfiguration().getHistoricIdentityLinkService().deleteHistoricIdentityLinksByProcessInstanceId(processInstanceId);

if (taskId != null) {
Expand Down

0 comments on commit c2b094e

Please sign in to comment.