Skip to content

Commit

Permalink
Go through the HistoryManager for deleting historic case instances
Browse files Browse the repository at this point in the history
  • Loading branch information
jbarrez committed Jul 14, 2023
1 parent 4c7c894 commit 5834cee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static void deleteHistoricCaseInstance(CmmnEngineConfiguration cmmnEngine

// Also delete any sub cases that may be active
historicCaseInstanceEntityManager.createHistoricCaseInstanceQuery().caseInstanceParentId(caseInstanceId).list()
.forEach(c -> deleteHistoricCaseInstance(cmmnEngineConfiguration, c.getId()));
.forEach(c -> cmmnEngineConfiguration.getCmmnHistoryManager().recordHistoricCaseInstanceDeleted(c.getId(), c.getTenantId()));
}

public static void bulkDeleteHistoricCaseInstances(Collection<String> caseInstanceIds, CmmnEngineConfiguration cmmnEngineConfiguration) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.flowable.cmmn.engine.impl.repository.CaseDefinitionQueryImpl;
import org.flowable.cmmn.engine.impl.runtime.CaseInstanceQueryImpl;
import org.flowable.cmmn.engine.impl.task.TaskHelper;
import org.flowable.cmmn.engine.impl.util.CommandContextUtil;
import org.flowable.common.engine.api.scope.ScopeTypes;
import org.flowable.common.engine.impl.context.Context;
import org.flowable.common.engine.impl.interceptor.CommandContext;
Expand Down Expand Up @@ -131,7 +132,8 @@ public void deleteCaseDefinitionAndRelatedData(String caseDefinitionId, boolean
List<HistoricCaseInstance> historicCaseInstanceEntities = historicCaseInstanceEntityManager
.findByCriteria(new HistoricCaseInstanceQueryImpl().caseDefinitionId(caseDefinitionId));
for (HistoricCaseInstance historicCaseInstanceEntity : historicCaseInstanceEntities) {
CmmnHistoryHelper.deleteHistoricCaseInstance(engineConfiguration, historicCaseInstanceEntity.getId());
CommandContextUtil.getCmmnHistoryManager(commandContext).recordHistoricCaseInstanceDeleted(historicCaseInstanceEntity.getId(),
historicCaseInstanceEntity.getTenantId());
}
}

Expand Down

0 comments on commit 5834cee

Please sign in to comment.