}
@SuppressWarnings("unchecked")
public void deleteHistoricProcessInstanceById(String historicProcessInstanceId) {
if (getHistoryManager().isHistoryEnabled()) {
CommandContext commandContext = Context.getCommandContext();
HistoricProcessInstanceEntity historicProcessInstance = findHistoricProcessInstance(historicProcessInstanceId);
commandContext
.getHistoricDetailEntityManager()
.deleteHistoricDetailsByProcessInstanceId(historicProcessInstanceId);
commandContext
.getHistoricVariableInstanceEntityManager()
.deleteHistoricVariableInstanceByProcessInstanceId(historicProcessInstanceId);
commandContext
.getHistoricActivityInstanceEntityManager()
.deleteHistoricActivityInstancesByProcessInstanceId(historicProcessInstanceId);
commandContext
.getHistoricTaskInstanceEntityManager()
.deleteHistoricTaskInstancesByProcessInstanceId(historicProcessInstanceId);
commandContext
.getHistoricIdentityLinkEntityManager()
.deleteHistoricIdentityLinksByProcInstance(historicProcessInstanceId);
commandContext
.getCommentEntityManager()
.deleteCommentsByProcessInstanceId(historicProcessInstanceId);
getDbSqlSession().delete(historicProcessInstance);