本文整理汇总了Java中org.activiti.engine.runtime.ProcessInstanceQuery类的典型用法代码示例。如果您正苦于以下问题:Java ProcessInstanceQuery类的具体用法?Java ProcessInstanceQuery怎么用?Java ProcessInstanceQuery使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProcessInstanceQuery类属于org.activiti.engine.runtime包,在下文中一共展示了ProcessInstanceQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.activiti.engine.runtime.ProcessInstanceQuery; //导入依赖的package包/类
@BeforeTest
public void setUp(){
RuntimeService rts = mock(RuntimeService.class);
List<ProcessInstance> processList = new ArrayList<ProcessInstance>();
ExecutionEntity executionEntity = new ExecutionEntity();
executionEntity.setActive(false);
processList.add(executionEntity);
ProcessInstanceQuery pQuery = mock(ProcessInstanceQuery.class);
when(pQuery.active()).thenReturn(pQuery);
when(pQuery.list()).thenReturn(processList);
when(rts.createProcessInstanceQuery()).thenReturn(pQuery);
this.servlet.setRuntimeService(rts);
this.servlet.setWoDispatcher(mock(WoDispatcher.class));
this.servlet.init();
}
示例2: runningList
import org.activiti.engine.runtime.ProcessInstanceQuery; //导入依赖的package包/类
/**
* 流程定义列表
*/
public Page<ProcessInstance> runningList(Page<ProcessInstance> page, String procInsId, String procDefKey) {
ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery();
if (StringUtils.isNotBlank(procInsId)){
processInstanceQuery.processInstanceId(procInsId);
}
if (StringUtils.isNotBlank(procDefKey)){
processInstanceQuery.processDefinitionKey(procDefKey);
}
page.setCount(processInstanceQuery.count());
page.setList(processInstanceQuery.listPage(page.getFirstResult(), page.getMaxResults()));
return page;
}
示例3: testGetProcessInstanceById
import org.activiti.engine.runtime.ProcessInstanceQuery; //导入依赖的package包/类
@Test
public void testGetProcessInstanceById()
{
String processInstanceId = "processInstanceId";
ProcessInstanceQuery processInstanceQuery = mock(ProcessInstanceQuery.class);
when(activitiRuntimeService.createProcessInstanceQuery()).thenReturn(processInstanceQuery);
when(processInstanceQuery.processInstanceId(processInstanceId)).thenReturn(processInstanceQuery);
when(processInstanceQuery.includeProcessVariables()).thenReturn(processInstanceQuery);
ProcessInstance expectedProcessInstance = mock(ProcessInstance.class);
when(processInstanceQuery.singleResult()).thenReturn(expectedProcessInstance);
ProcessInstance actualProcessInstance = activitiService.getProcessInstanceById(processInstanceId);
assertSame(expectedProcessInstance, actualProcessInstance);
InOrder inOrder = inOrder(processInstanceQuery);
inOrder.verify(processInstanceQuery).processInstanceId(processInstanceId);
inOrder.verify(processInstanceQuery).includeProcessVariables();
inOrder.verify(processInstanceQuery).singleResult();
inOrder.verifyNoMoreInteractions();
}
示例4: testQueryByProcessInstanceIds
import org.activiti.engine.runtime.ProcessInstanceQuery; //导入依赖的package包/类
public void testQueryByProcessInstanceIds() {
Set<String> processInstanceIds = new HashSet<String>(this.processInstanceIds);
// start an instance that will not be part of the query
runtimeService.startProcessInstanceByKey("oneTaskProcess2", "2");
ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceIds(processInstanceIds);
assertEquals(5, processInstanceQuery.count());
List<ProcessInstance> processInstances = processInstanceQuery.list();
assertNotNull(processInstances);
assertEquals(5, processInstances.size());
for (ProcessInstance processInstance : processInstances) {
assertTrue(processInstanceIds.contains(processInstance.getId()));
}
}
示例5: testCycleDateStartTimerEvent
import org.activiti.engine.runtime.ProcessInstanceQuery; //导入依赖的package包/类
@Deployment
public void testCycleDateStartTimerEvent() throws Exception {
ClockUtil.setCurrentTime(new Date());
// After process start, there should be timer created
JobQuery jobQuery = managementService.createJobQuery();
assertEquals(1, jobQuery.count());
moveByMinutes(5);
ProcessInstanceQuery piq = runtimeService.createProcessInstanceQuery().processDefinitionKey("startTimerEventExample");
assertEquals(1, piq.count());
assertEquals(1, jobQuery.count());
moveByMinutes(5);
assertEquals(2, piq.count());
assertEquals(1, jobQuery.count());
//have to manually delete pending timer
cleanDB();
}
示例6: testCycleWithLimitStartTimerEvent
import org.activiti.engine.runtime.ProcessInstanceQuery; //导入依赖的package包/类
@Deployment
public void testCycleWithLimitStartTimerEvent() throws Exception {
ClockUtil.setCurrentTime(new Date());
// After process start, there should be timer created
JobQuery jobQuery = managementService.createJobQuery();
assertEquals(1, jobQuery.count());
moveByMinutes(5);
ProcessInstanceQuery piq = runtimeService.createProcessInstanceQuery().processDefinitionKey("startTimerEventExampleCycle");
assertEquals(1, piq.count());
assertEquals(1, jobQuery.count());
moveByMinutes(5);
assertEquals(2, piq.count());
assertEquals(0, jobQuery.count());
}
示例7: getPaginatedInstances
import org.activiti.engine.runtime.ProcessInstanceQuery; //导入依赖的package包/类
/**
* Get paginated instances
*
* @param start
* @param size
* @return list of BPMNInstances
* @throws BPSFault
*/
public BPMNInstance[] getPaginatedInstances(int start, int size) throws BPSFault {
List<BPMNInstance> bpmnInstanceList = new ArrayList<>();
Integer tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
ProcessEngine engine = BPMNServerHolder.getInstance().getEngine();
RuntimeService runtimeService = engine.getRuntimeService();
ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().processInstanceTenantId(tenantId.toString());
HistoricProcessInstanceQuery historicQuery = BPMNServerHolder.getInstance().getEngine().getHistoryService()
.createHistoricProcessInstanceQuery().processInstanceTenantId(tenantId.toString());
processInstanceCount = (int) query.count();
List<ProcessInstance> instances = query.includeProcessVariables().listPage(start, size);
for (ProcessInstance instance: instances) {
BPMNInstance bpmnInstance = new BPMNInstance();
bpmnInstance.setInstanceId(instance.getId());
bpmnInstance.setProcessId(instance.getProcessDefinitionId());
bpmnInstance.setSuspended(instance.isSuspended());
bpmnInstance.setStartTime(historicQuery.processInstanceId(instance.getId()).singleResult().getStartTime());
bpmnInstance.setVariables(formatVariables(instance.getProcessVariables()));
bpmnInstanceList.add(bpmnInstance);
}
return bpmnInstanceList.toArray(new BPMNInstance[bpmnInstanceList.size()]);
}
示例8: getPiStatusByBizKey
import org.activiti.engine.runtime.ProcessInstanceQuery; //导入依赖的package包/类
@Override
public PiStatus getPiStatusByBizKey(String bizKey) {
ProcessInstanceQuery query = runtimeService
.createProcessInstanceQuery();
long count = query.processInstanceBusinessKey(bizKey).count();
if (count > 0) {
// 流程正在运行中
return PiStatus.Running;
} else {
count = historyService.createHistoricProcessInstanceQuery()
.finished().processInstanceBusinessKey(bizKey).count();
if (count > 0) {
// 流程已经结束
return PiStatus.Finished;
} else {
// 没有流程信息
return PiStatus.NotFound;
}
}
}
示例9: getPiStatusByPiId
import org.activiti.engine.runtime.ProcessInstanceQuery; //导入依赖的package包/类
@Override
public PiStatus getPiStatusByPiId(String piId) {
ProcessInstanceQuery query = runtimeService
.createProcessInstanceQuery();
long count = query.processInstanceId(piId).count();
if (count > 0) {
// 流程正在运行中
return PiStatus.Running;
} else {
count = historyService.createHistoricProcessInstanceQuery()
.finished().processInstanceId(piId).count();
if (count > 0) {
// 流程已经结束
return PiStatus.Finished;
} else {
// 没有流程信息
return PiStatus.NotFound;
}
}
}
示例10: mockProcessEngine
import org.activiti.engine.runtime.ProcessInstanceQuery; //导入依赖的package包/类
public ProcessEngine mockProcessEngine(String processInstanceId, String businessKey, String providerId) {
ProcessInstance instance = mock(ProcessInstance.class);
when(instance.getId()).thenReturn(processInstanceId);
ProcessInstanceQuery query = mock(ProcessInstanceQuery.class);
when(query.singleResult()).thenReturn(instance);
when(query.processInstanceBusinessKey(eq(businessKey))).thenReturn(query);
RuntimeService runtimeService = mock(RuntimeService.class);
when(runtimeService.createProcessInstanceQuery()).thenReturn(query);
when(runtimeService.getVariable(eq(processInstanceId), eq(CoreProcessVariables.PROVIDER)))
.thenReturn(providerId);
ProcessEngine processEngine = mock(ProcessEngine.class);
when(processEngine.getRuntimeService()).thenReturn(runtimeService);
return processEngine;
}
示例11: newMockProcessEngine
import org.activiti.engine.runtime.ProcessInstanceQuery; //导入依赖的package包/类
private ProcessEngine newMockProcessEngine() {
final ProcessEngine engine = mock(ProcessEngine.class);
final List<ProcessInstance> processes = ImmutableList.of(
newProcessInstanceMock("p1", BUSINESS_KEY, true),
newProcessInstanceMock("p2", BUSINESS_KEY, false),
newProcessInstanceMock("p3", BUSINESS_KEY, true)
);
final RuntimeService runtimeService = mock(RuntimeService.class);
final ProcessInstanceQuery processInstanceQuery = mock(ProcessInstanceQuery.class);
when(engine.getRuntimeService()).thenReturn(runtimeService);
when(runtimeService.createProcessInstanceQuery()).thenReturn(processInstanceQuery);
when(processInstanceQuery.variableValueEquals(CoreProcessVariables.POOL_BUSINESS_KEY, BUSINESS_KEY))
.thenReturn(processInstanceQuery);
when(processInstanceQuery.orderByProcessInstanceId()).thenReturn(processInstanceQuery);
when(processInstanceQuery.desc()).thenReturn(processInstanceQuery);
when(processInstanceQuery.list()).thenReturn(processes);
return engine;
}
示例12: mockRuntimeService
import org.activiti.engine.runtime.ProcessInstanceQuery; //导入依赖的package包/类
protected RuntimeService mockRuntimeService(Map<String, ProcessInstance> instances,
String... notFoundProcessInstanceIds) {
RuntimeService runtimeService = mock(RuntimeService.class);
ProcessInstanceQuery generalQuery = mock(ProcessInstanceQuery.class);
for (Map.Entry<String, ProcessInstance> entry : instances.entrySet()) {
ProcessInstanceQuery specificQuery = mock(ProcessInstanceQuery.class);
when(specificQuery.singleResult()).thenReturn(entry.getValue());
when(generalQuery.processInstanceId(eq(entry.getKey()))).thenReturn(specificQuery);
}
for (String notFound : notFoundProcessInstanceIds) {
/* create a mock that returns null for all method calls (default) */
when(generalQuery.processInstanceId(eq(notFound))).thenReturn(mock(ProcessInstanceQuery.class));
}
when(runtimeService.createProcessInstanceQuery()).thenReturn(generalQuery);
return runtimeService;
}
示例13: running
import org.activiti.engine.runtime.ProcessInstanceQuery; //导入依赖的package包/类
@RequestMapping(value = "running")
public ModelAndView running(Model model, HttpServletRequest request) {
ModelAndView mav = new ModelAndView("/workflow/running-manage");
// Page<ProcessInstance> page = new Page<ProcessInstance>(PageUtil.PAGE_SIZE);
// int[] pageParams = PageUtil.init(page, request);
ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery();
List<ProcessInstance> list = processInstanceQuery.listPage(1, 10);
// page.setResult(list);
// page.setTotalCount(processInstanceQuery.count());
mav.addObject("page", list);
return mav;
}
示例14: processInstanceBusinessKey
import org.activiti.engine.runtime.ProcessInstanceQuery; //导入依赖的package包/类
@Override
public ProcessInstanceQuery processInstanceBusinessKey(String businessKey) {
if (businessKey == null) {
throw new ActivitiIllegalArgumentException("Business key is null");
}
if (inOrStatement) {
this.currentOrQueryObject.businessKey = businessKey;
} else {
this.businessKey = businessKey;
}
return this;
}
示例15: processInstanceTenantId
import org.activiti.engine.runtime.ProcessInstanceQuery; //导入依赖的package包/类
@Override
public ProcessInstanceQuery processInstanceTenantId(String tenantId) {
if (tenantId == null) {
throw new ActivitiIllegalArgumentException("process instance tenant id is null");
}
if (inOrStatement) {
this.currentOrQueryObject.tenantId = tenantId;
} else {
this.tenantId = tenantId;
}
return this;
}