本文整理汇总了Java中org.activiti.engine.history.HistoricActivityInstance类的典型用法代码示例。如果您正苦于以下问题:Java HistoricActivityInstance类的具体用法?Java HistoricActivityInstance怎么用?Java HistoricActivityInstance使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HistoricActivityInstance类属于org.activiti.engine.history包,在下文中一共展示了HistoricActivityInstance类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStartVariables
import org.activiti.engine.history.HistoricActivityInstance; //导入依赖的package包/类
/**
* @param historicProcessInstance HistoricProcessInstance
* @return Map
*/
public Map<String, Object> getStartVariables(HistoricProcessInstance historicProcessInstance)
{
if (historicProcessInstance.getStartActivityId() == null)
{
return Collections.emptyMap();
}
// Get historic variable values for start-event
HistoricActivityInstance startEvent = activitiUtil.getHistoryService()
.createHistoricActivityInstanceQuery()
.processInstanceId(historicProcessInstance.getId())
.activityId(historicProcessInstance.getStartActivityId())
.singleResult();
Map<String, Object> variables = getHistoricActivityVariables(startEvent.getId());
return variables;
}
示例2: getHighLightedFlows
import org.activiti.engine.history.HistoricActivityInstance; //导入依赖的package包/类
private List<String> getHighLightedFlows(
ProcessDefinitionEntity processDefinition, String processInstanceId) {
List<HistoricActivityInstance> historicActivityInstances = historyService
.createHistoricActivityInstanceQuery()
.processInstanceId(processInstanceId)
.orderByHistoricActivityInstanceStartTime().asc() /* .orderByActivityId().asc() */
.list();
for (HistoricActivityInstance hai : historicActivityInstances) {
historicActivityInstanceList.add(hai.getActivityId());
}
// add current activities to list
highLightedActivities = runtimeService
.getActiveActivityIds(processInstanceId);
historicActivityInstanceList.addAll(highLightedActivities);
// activities and their sequence-flows
getHighlightedFlows(processDefinition.getActivities());
return highLightedFlows;
}
示例3: getApproveMap
import org.activiti.engine.history.HistoricActivityInstance; //导入依赖的package包/类
/**
* 获取历史审批结果和审批意见
*
* @param activityInstance 历史任务节点
* @return
*/
public Map<String, String> getApproveMap(HistoricActivityInstance activityInstance) {
//审批结果和审批意见为Local变量
Map<String, String> map = new HashMap<>();
if (StrUtil.isEmpty(activityInstance.getTaskId()))
return map;
List<HistoricVariableInstance> variableInstances = historyService.createHistoricVariableInstanceQuery()
.processInstanceId(activityInstance.getProcessInstanceId()).taskId(activityInstance.getTaskId()).list();
for (HistoricVariableInstance variableInstance : variableInstances) {
if (variableInstance.getVariableName().equals(Constants.APPROVE_RESULT)) {
map.put(Constants.APPROVE_RESULT, variableInstance.getValue().toString());
} else {
map.put(Constants.APPROVE_SUGGESTION, variableInstance.getValue().toString());
}
}
return map;
}
示例4: testGetHistoricActivityInstancesByProcessInstanceId
import org.activiti.engine.history.HistoricActivityInstance; //导入依赖的package包/类
@Test
public void testGetHistoricActivityInstancesByProcessInstanceId()
{
String processInstanceId = "processInstanceId";
HistoricActivityInstanceQuery historicActivityInstanceQuery = mock(HistoricActivityInstanceQuery.class);
when(activitiHistoryService.createHistoricActivityInstanceQuery()).thenReturn(historicActivityInstanceQuery);
when(historicActivityInstanceQuery.processInstanceId(processInstanceId)).thenReturn(historicActivityInstanceQuery);
when(historicActivityInstanceQuery.orderByHistoricActivityInstanceStartTime()).thenReturn(historicActivityInstanceQuery);
when(historicActivityInstanceQuery.asc()).thenReturn(historicActivityInstanceQuery);
when(historicActivityInstanceQuery.orderByHistoricActivityInstanceEndTime()).thenReturn(historicActivityInstanceQuery);
when(historicActivityInstanceQuery.asc()).thenReturn(historicActivityInstanceQuery);
List<HistoricActivityInstance> expectedHistoricActivityInstances = new ArrayList<>();
when(historicActivityInstanceQuery.list()).thenReturn(expectedHistoricActivityInstances);
List<HistoricActivityInstance> actualHistoricActivityInstances = activitiService.getHistoricActivityInstancesByProcessInstanceId(processInstanceId);
assertSame(expectedHistoricActivityInstances, actualHistoricActivityInstances);
InOrder inOrder = inOrder(historicActivityInstanceQuery);
inOrder.verify(historicActivityInstanceQuery).processInstanceId(processInstanceId);
inOrder.verify(historicActivityInstanceQuery).orderByHistoricActivityInstanceStartTime();
inOrder.verify(historicActivityInstanceQuery).asc();
inOrder.verify(historicActivityInstanceQuery).orderByHistoricActivityInstanceEndTime();
inOrder.verify(historicActivityInstanceQuery).asc();
inOrder.verify(historicActivityInstanceQuery).list();
inOrder.verifyNoMoreInteractions();
}
示例5: testSequentialScriptTasksHistory
import org.activiti.engine.history.HistoricActivityInstance; //导入依赖的package包/类
@Deployment(resources = {"org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.testSequentialScriptTasks.bpmn20.xml"})
public void testSequentialScriptTasksHistory() {
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("sum", 0);
vars.put("nrOfLoops", 7);
runtimeService.startProcessInstanceByKey("miSequentialScriptTask", vars);
// Validate history
if (processEngineConfiguration.getHistoryLevel() > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) {
List<HistoricActivityInstance> historicInstances = historyService.createHistoricActivityInstanceQuery().activityType("scriptTask").orderByActivityId().asc().list();
assertEquals(7, historicInstances.size());
for (int i=0; i<7; i++) {
HistoricActivityInstance hai = historicInstances.get(i);
assertEquals("scriptTask", hai.getActivityType());
assertNotNull(hai.getStartTime());
assertNotNull(hai.getEndTime());
}
}
}
示例6: testParallelScriptTasksHistory
import org.activiti.engine.history.HistoricActivityInstance; //导入依赖的package包/类
@Deployment(resources = {"org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.testParallelScriptTasks.bpmn20.xml"})
public void testParallelScriptTasksHistory() {
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("sum", 0);
vars.put("nrOfLoops", 4);
runtimeService.startProcessInstanceByKey("miParallelScriptTask", vars);
if (processEngineConfiguration.getHistoryLevel() > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) {
List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().activityType("scriptTask").list();
assertEquals(4, historicActivityInstances.size());
for (HistoricActivityInstance hai : historicActivityInstances) {
assertNotNull(hai.getStartTime());
assertNotNull(hai.getStartTime());
}
}
}
示例7: testParallelSubProcessHistory
import org.activiti.engine.history.HistoricActivityInstance; //导入依赖的package包/类
@Deployment(resources = {"org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.testParallelSubProcess.bpmn20.xml"})
public void testParallelSubProcessHistory() {
runtimeService.startProcessInstanceByKey("miParallelSubprocess");
for (Task task : taskService.createTaskQuery().list()) {
taskService.complete(task.getId());
}
// Validate history
if (processEngineConfiguration.getHistoryLevel() > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) {
List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().activityId("miSubProcess").list();
assertEquals(2, historicActivityInstances.size());
for (HistoricActivityInstance hai : historicActivityInstances) {
assertNotNull(hai.getStartTime());
assertNotNull(hai.getEndTime());
}
}
}
示例8: testHistoricActivityInstanceNoop
import org.activiti.engine.history.HistoricActivityInstance; //导入依赖的package包/类
@Deployment
public void testHistoricActivityInstanceNoop() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("noopProcess");
HistoricActivityInstance historicActivityInstance = historyService
.createHistoricActivityInstanceQuery()
.activityId("noop")
.singleResult();
assertEquals("noop", historicActivityInstance.getActivityId());
assertEquals("serviceTask", historicActivityInstance.getActivityType());
assertNotNull(historicActivityInstance.getProcessDefinitionId());
assertEquals(processInstance.getId(), historicActivityInstance.getProcessInstanceId());
assertEquals(processInstance.getId(), historicActivityInstance.getExecutionId());
assertNotNull(historicActivityInstance.getStartTime());
assertNotNull(historicActivityInstance.getEndTime());
assertTrue(historicActivityInstance.getDurationInMillis() >= 0);
}
示例9: findHistoricUserTask
import org.activiti.engine.history.HistoricActivityInstance; //导入依赖的package包/类
/**
* 查询指定任务节点的最新记录
*
* @param processInstance
* 流程实例
* @param activityId
* @return
*/
private static HistoricActivityInstance findHistoricUserTask(
ProcessInstance processInstance, String activityId) {
HistoricActivityInstance rtnVal = null;
// 查询当前流程实例审批结束的历史节点
List<HistoricActivityInstance> historicActivityInstances = historyService
.createHistoricActivityInstanceQuery().activityType("userTask")
.processInstanceId(processInstance.getId()).activityId(
activityId).finished()
.orderByHistoricActivityInstanceEndTime().desc().list();
if (historicActivityInstances.size() > 0) {
rtnVal = historicActivityInstances.get(0);
}
return rtnVal;
}
示例10: findHistoricUserTask
import org.activiti.engine.history.HistoricActivityInstance; //导入依赖的package包/类
/**
* 查询指定任务节点的最新记录
* @param processInstance 流程实例
* @param activityId
* @return
*/
private HistoricActivityInstance findHistoricUserTask(ProcessInstance processInstance,
String activityId){
HistoricActivityInstance rtnVal = null;
//查询当前流程实例审批结束的历史节点
List<HistoricActivityInstance> historicActivityInstances =historyService
.createHistoricActivityInstanceQuery().activityType("userTask")
.processInstanceId(processInstance.getId()).activityId(activityId)
.finished().orderByHistoricActivityInstanceEndTime().desc().list();
if(historicActivityInstances.size()>0){
rtnVal = historicActivityInstances.get(0);
}
return rtnVal;
}
示例11: printActivityInstanceInfo
import org.activiti.engine.history.HistoricActivityInstance; //导入依赖的package包/类
protected void printActivityInstanceInfo(HistoricActivityInstance actInst) {
LinkedHashMap<String, String> nvMap = new LinkedHashMap<String, String>();
nvMap.put("Activity ID", actInst.getActivityId());
if (!this.isQuiet()) {
nvMap.put("Activity Type", actInst.getActivityType());
}
nvMap.put("Activity Name", actInst.getActivityName());
if (!this.isQuiet()) {
nvMap.put("Execution ID", actInst.getExecutionId());
}
nvMap.put("Start Time", Commands.UTIL.formatDate(actInst.getStartTime()));
nvMap.put("End Time", Commands.UTIL.formatDate(actInst.getEndTime()));
if (!this.isQuiet()) {
nvMap.put("Duration", Commands.UTIL.formatDuration(actInst.getDurationInMillis()));
}
PrintWriter out = new PrintWriter(out(), true);
Commands.UTIL.printNameValues(out, nvMap);
// print activity vars
this.getPrintHandler().printActivityData(out, this.isVerbose(), this.isQuiet(), actInst);
out().println("-------------");
}
示例12: printActivityData
import org.activiti.engine.history.HistoricActivityInstance; //导入依赖的package包/类
@Override
public void printActivityData(PrintWriter out, boolean verbose, boolean quite,
HistoricActivityInstance actInst) {
this.setVerbose(verbose);
this.setQuiet(quite);
if (quite) {
// don't print activity variable update per activity
return;
}
List<HistoricDetail> varList = null;
try {
varList = this.processEngine.getHistoryService().createHistoricDetailQuery()
.variableUpdates().activityInstanceId(actInst.getId()).orderByTime().desc().list();
} catch (ActivitiException ex) {
//silent about the error. and log it.
LOG.log(Level.INFO, "Error in getting process variables. " + ex.getMessage(), ex);
}
if (varList != null && varList.size() > 0) {
out.println("-------- Task Variables");
printVariables(out, varList);
} else {
LOG.info("------ No Task Variables! for " + actInst.getActivityId());
}
}
示例13: testSequentialScriptTasksHistory
import org.activiti.engine.history.HistoricActivityInstance; //导入依赖的package包/类
@Deployment(resources = {"org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.testSequentialScriptTasks.bpmn20.xml"})
public void testSequentialScriptTasksHistory() {
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("sum", 0);
vars.put("nrOfLoops", 7);
runtimeService.startProcessInstanceByKey("miSequentialScriptTask", vars);
// Validate history
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
List<HistoricActivityInstance> historicInstances = historyService.createHistoricActivityInstanceQuery().activityType("scriptTask").orderByActivityId().asc().list();
assertEquals(7, historicInstances.size());
for (int i=0; i<7; i++) {
HistoricActivityInstance hai = historicInstances.get(i);
assertEquals("scriptTask", hai.getActivityType());
assertNotNull(hai.getStartTime());
assertNotNull(hai.getEndTime());
}
}
}
示例14: testParallelScriptTasksHistory
import org.activiti.engine.history.HistoricActivityInstance; //导入依赖的package包/类
@Deployment(resources = {"org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.testParallelScriptTasks.bpmn20.xml"})
public void testParallelScriptTasksHistory() {
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("sum", 0);
vars.put("nrOfLoops", 4);
runtimeService.startProcessInstanceByKey("miParallelScriptTask", vars);
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().activityType("scriptTask").list();
assertEquals(4, historicActivityInstances.size());
for (HistoricActivityInstance hai : historicActivityInstances) {
assertNotNull(hai.getStartTime());
assertNotNull(hai.getStartTime());
}
}
}
示例15: testParallelSubProcessHistory
import org.activiti.engine.history.HistoricActivityInstance; //导入依赖的package包/类
@Deployment(resources = {"org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.testParallelSubProcess.bpmn20.xml"})
public void testParallelSubProcessHistory() {
runtimeService.startProcessInstanceByKey("miParallelSubprocess");
for (Task task : taskService.createTaskQuery().list()) {
taskService.complete(task.getId());
}
// Validate history
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().activityId("miSubProcess").list();
assertEquals(2, historicActivityInstances.size());
for (HistoricActivityInstance hai : historicActivityInstances) {
assertNotNull(hai.getStartTime());
assertNotNull(hai.getEndTime());
}
}
}