activiti有五個關(guān)于歷史的實體類:
- HistoricProcessInstance
- HistoricVariableInstance
- HistoricActivityInstance
- HistoricTaskInstance
- HistoricDetail
11.1 Querying history
HistoryService類暴露了五個相關(guān)方法提供歷史查詢:
createHistoricProcessInstanceQuery()
createHistoricVariableInstanceQuery()
createHistoricActivityInstanceQuery()
createHistoricDetailQuery()
createHistoricTaskInstanceQuery()
- HistoricProcessInstanceQuery
historyService.createHistoricProcessInstanceQuery()
.finished()
.processDefinitionId("XXX")
.orderByProcessInstanceDuration().desc()
.listPage(0, 10);
- HistoricVariableInstanceQuery
historyService.createHistoricVariableInstanceQuery()
.processInstanceId("XXX")
.orderByVariableName.desc()
.list();
- HistoricActivityInstanceQuery
查詢已經(jīng)結(jié)束的task;
historyService.createHistoricActivityInstanceQuery()
.activityType("serviceTask")
.processDefinitionId("XXX")
.finished()
.orderByHistoricActivityInstanceEndTime().desc()
.listPage(0, 1);
HistoricDetailQuery
// TODOHistoricTaskInstanceQuery
historyService.createHistoricTaskInstanceQuery()
.finished()
.orderByHistoricTaskInstanceDuration().desc()
.listPage(0, 10);
historyService.createHistoricTaskInstanceQuery()
.finished()
.taskDeleteReasonLike("%invalid%")
.taskAssignee("kermit")
.listPage(0, 10);
11.2 History configuration
對于歷史數(shù)據(jù)啡邑,保存到何種粒度趋翻,Activiti提供了history-level屬性對其進行配置硕淑。history-level屬性有點像log4j的日志輸出級別,該屬性有以下四個值:
none:不保存任何的歷史數(shù)據(jù)滥酥,因此结啼,在流程執(zhí)行過程中坎缭,這是最高效的白群。
activity:級別高于none,保存流程實例與流程行為硬霍,其他數(shù)據(jù)不保存帜慢。
audit:除activity級別會保存的數(shù)據(jù)外,還會保存全部的流程任務(wù)及其屬性。audit為history的默認(rèn)值粱玲。
full:保存歷史數(shù)據(jù)的最高級別躬柬,除了會保存audit級別的數(shù)據(jù)外,還會保存其他全部流程相關(guān)的細(xì)節(jié)數(shù)據(jù)抽减,包括一些流程參數(shù)等允青。
配置方法:
ProcessEngine processEngine = ProcessEngineConfiguration
.createProcessEngineConfigurationFromResourceDefault()
.setHistory(HistoryLevel.AUDIT.getKey())
.buildProcessEngine();
11.3 History for audit purposes
// TODO