@Override public List<HistoricTaskInstance> executeList(CommandContext commandContext, Page page) { ensureVariablesInitialized(); checkQueryOk(); if (includeTaskLocalVariables || includeProcessVariables) { return commandContext .getHistoricTaskInstanceEntityManager() .findHistoricTaskInstancesAndVariablesByQueryCriteria(this); } else { return commandContext .getHistoricTaskInstanceEntityManager() .findHistoricTaskInstancesByQueryCriteria(this); } }
@Override public long executeCount(CommandContext commandContext) { ensureVariablesInitialized(); checkQueryOk(); return commandContext .getHistoricTaskInstanceEntityManager() .findHistoricTaskInstanceCountByQueryCriteria(this); }
@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); // Also delete any sub-processes that may be active (ACT-821) HistoricProcessInstanceQueryImpl subProcessesQueryImpl = new HistoricProcessInstanceQueryImpl(); subProcessesQueryImpl.superProcessInstanceId(historicProcessInstanceId); List<HistoricProcessInstance> selectList = getDbSqlSession() .selectList("selectHistoricProcessInstancesByQueryCriteria", subProcessesQueryImpl); for (HistoricProcessInstance child : selectList) { deleteHistoricProcessInstanceById(child.getId()); } } }