本文整理汇总了Java中org.activiti.engine.runtime.ExecutionQuery.singleResult方法的典型用法代码示例。如果您正苦于以下问题:Java ExecutionQuery.singleResult方法的具体用法?Java ExecutionQuery.singleResult怎么用?Java ExecutionQuery.singleResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.activiti.engine.runtime.ExecutionQuery
的用法示例。
在下文中一共展示了ExecutionQuery.singleResult方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testReceiveMessageManual
import org.activiti.engine.runtime.ExecutionQuery; //导入方法依赖的package包/类
/**
* 在审核文件节点抛出消息事件触发消息边界事件--cancelActivity='true'
*/
@Deployment(resources = "chapter11/boundaryEvent/signalBoundaryEvent.bpmn")
public void testReceiveMessageManual() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("signalBoundaryEvent");
assertNotNull(processInstance);
// 审核文件任务
Task task = taskService.createTaskQuery().taskName("审核文件").singleResult();
assertNotNull(task);
ExecutionQuery executionQuery = runtimeService.createExecutionQuery().signalEventSubscriptionName("S_协助处理");
Execution execution = executionQuery.singleResult();
runtimeService.signalEventReceived("S_协助处理", execution.getId());
// 任务到达“协助处理节点”
task = taskService.createTaskQuery().taskName("协助处理").singleResult();
assertNotNull(task);
taskService.complete(task.getId());
// 任务流转至审核文件节点
task = taskService.createTaskQuery().taskName("审核文件").singleResult();
assertNotNull(task);
// 验证流程实例运行结束
taskService.complete(task.getId());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().finished().count());
}
示例2: signal
import org.activiti.engine.runtime.ExecutionQuery; //导入方法依赖的package包/类
/**
* Signals a task by its process instance ID and the ID of the task to signal.
*
* @param processInstanceId The process instance ID of the waiting task.
* @param signalTaskId The ID of the task to signal.
*/
public void signal(String processInstanceId, String signalTaskId)
{
ExecutionQuery signalTaskQuery = runtimeService.createExecutionQuery().processInstanceId(processInstanceId).activityId(signalTaskId);
Execution execution = signalTaskQuery.singleResult();
runtimeService.signal(execution.getId());
}
示例3: testReceiveMessageManual
import org.activiti.engine.runtime.ExecutionQuery; //导入方法依赖的package包/类
/**
* 在审核文件节点抛出消息事件触发消息边界事件--cancelActivity='true'
*/
@Deployment(resources = "chapter11/boundaryEvent/messageBoundaryEvent.bpmn")
public void testReceiveMessageManual() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("messageBoundaryEvent");
assertNotNull(processInstance);
// System.out.println("11eid=" + processInstance.getId() + ", pid=" +
// processInstance.getProcessInstanceId());
// 审核文件任务
Task task = taskService.createTaskQuery().taskName("审核文件").singleResult();
assertNotNull(task);
ExecutionQuery executionQuery = runtimeService.createExecutionQuery().messageEventSubscriptionName("MSG_协助处理");
Execution execution = executionQuery.singleResult();
// System.out.println("22eid=" + execution.getId() + ", pid=" +
// execution.getProcessInstanceId());
/*
* TablePage listPage =
* managementService.createTablePageQuery().tableName("ACT_RU_EVENT_SUBSCR"
* ).listPage(0, 10); List<Map<String, Object>> rows = listPage.getRows();
* for (Map<String, Object> map : rows) { Set<Entry<String, Object>>
* entrySet = map.entrySet(); for (Entry<String, Object> entry : entrySet) {
* System.out.println(entry.getKey() + " = " + entry.getValue()); } }
*/
runtimeService.messageEventReceived("MSG_协助处理", execution.getId());
execution = runtimeService.createExecutionQuery().singleResult();
// System.out.println("33eid=" + execution.getId() + ", pid=" +
// execution.getProcessInstanceId());
// 任务到达“协助处理节点”
task = taskService.createTaskQuery().taskName("协助处理").singleResult();
assertNotNull(task);
taskService.complete(task.getId());
// 任务流转至审核文件节点
task = taskService.createTaskQuery().taskName("审核文件").singleResult();
assertNotNull(task);
// 验证流程实例运行结束
taskService.complete(task.getId());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().finished().count());
}
示例4: testQueryLongVariable
import org.activiti.engine.runtime.ExecutionQuery; //导入方法依赖的package包/类
@Deployment(resources={
"org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml"})
public void testQueryLongVariable() {
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("longVar", 12345L);
ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
vars = new HashMap<String, Object>();
vars.put("longVar", 12345L);
vars.put("longVar2", 67890L);
ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
vars = new HashMap<String, Object>();
vars.put("longVar", 55555L);
ProcessInstance processInstance3 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
// Query on single long variable, should result in 2 matches
ExecutionQuery query = runtimeService.createExecutionQuery().variableValueEquals("longVar", 12345L);
List<Execution> executions = query.list();
Assert.assertNotNull(executions);
Assert.assertEquals(2, executions.size());
// Query on two long variables, should result in single match
query = runtimeService.createExecutionQuery().variableValueEquals("longVar", 12345L).variableValueEquals("longVar2", 67890L);
Execution execution = query.singleResult();
Assert.assertNotNull(execution);
Assert.assertEquals(processInstance2.getId(), execution.getId());
// Query with unexisting variable value
execution = runtimeService.createExecutionQuery().variableValueEquals("longVar", 999L).singleResult();
Assert.assertNull(execution);
// Test NOT_EQUALS
execution = runtimeService.createExecutionQuery().variableValueNotEquals("longVar", 12345L).singleResult();
Assert.assertNotNull(execution);
Assert.assertEquals(processInstance3.getId(), execution.getId());
// Test GREATER_THAN
execution = runtimeService.createExecutionQuery().variableValueGreaterThan("longVar", 44444L).singleResult();
Assert.assertNotNull(execution);
Assert.assertEquals(processInstance3.getId(), execution.getId());
Assert.assertEquals(0, runtimeService.createExecutionQuery().variableValueGreaterThan("longVar", 55555L).count());
Assert.assertEquals(3, runtimeService.createExecutionQuery().variableValueGreaterThan("longVar",1L).count());
// Test GREATER_THAN_OR_EQUAL
execution = runtimeService.createExecutionQuery().variableValueGreaterThanOrEqual("longVar", 44444L).singleResult();
Assert.assertNotNull(execution);
Assert.assertEquals(processInstance3.getId(), execution.getId());
execution = runtimeService.createExecutionQuery().variableValueGreaterThanOrEqual("longVar", 55555L).singleResult();
Assert.assertNotNull(execution);
Assert.assertEquals(processInstance3.getId(), execution.getId());
Assert.assertEquals(3, runtimeService.createExecutionQuery().variableValueGreaterThanOrEqual("longVar",1L).count());
// Test LESS_THAN
executions = runtimeService.createExecutionQuery().variableValueLessThan("longVar", 55555L).list();
Assert.assertEquals(2, executions.size());
List<String> expecedIds = Arrays.asList(processInstance1.getId(), processInstance2.getId());
List<String> ids = new ArrayList<String>(Arrays.asList(executions.get(0).getId(), executions.get(1).getId()));
ids.removeAll(expecedIds);
assertTrue(ids.isEmpty());
Assert.assertEquals(0, runtimeService.createExecutionQuery().variableValueLessThan("longVar", 12345L).count());
Assert.assertEquals(3, runtimeService.createExecutionQuery().variableValueLessThan("longVar",66666L).count());
// Test LESS_THAN_OR_EQUAL
executions = runtimeService.createExecutionQuery().variableValueLessThanOrEqual("longVar", 55555L).list();
Assert.assertEquals(3, executions.size());
Assert.assertEquals(0, runtimeService.createExecutionQuery().variableValueLessThanOrEqual("longVar", 12344L).count());
runtimeService.deleteProcessInstance(processInstance1.getId(), "test");
runtimeService.deleteProcessInstance(processInstance2.getId(), "test");
runtimeService.deleteProcessInstance(processInstance3.getId(), "test");
}
示例5: testQueryDoubleVariable
import org.activiti.engine.runtime.ExecutionQuery; //导入方法依赖的package包/类
@Deployment(resources={
"org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml"})
public void testQueryDoubleVariable() {
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("doubleVar", 12345.6789);
ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
vars = new HashMap<String, Object>();
vars.put("doubleVar", 12345.6789);
vars.put("doubleVar2", 9876.54321);
ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
vars = new HashMap<String, Object>();
vars.put("doubleVar", 55555.5555);
ProcessInstance processInstance3 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
// Query on single double variable, should result in 2 matches
ExecutionQuery query = runtimeService.createExecutionQuery().variableValueEquals("doubleVar", 12345.6789);
List<Execution> executions = query.list();
Assert.assertNotNull(executions);
Assert.assertEquals(2, executions.size());
// Query on two double variables, should result in single value
query = runtimeService.createExecutionQuery().variableValueEquals("doubleVar", 12345.6789).variableValueEquals("doubleVar2", 9876.54321);
Execution execution = query.singleResult();
Assert.assertNotNull(execution);
Assert.assertEquals(processInstance2.getId(), execution.getId());
// Query with unexisting variable value
execution = runtimeService.createExecutionQuery().variableValueEquals("doubleVar", 9999.99).singleResult();
Assert.assertNull(execution);
// Test NOT_EQUALS
execution = runtimeService.createExecutionQuery().variableValueNotEquals("doubleVar", 12345.6789).singleResult();
Assert.assertNotNull(execution);
Assert.assertEquals(processInstance3.getId(), execution.getId());
// Test GREATER_THAN
execution = runtimeService.createExecutionQuery().variableValueGreaterThan("doubleVar", 44444.4444).singleResult();
Assert.assertNotNull(execution);
Assert.assertEquals(processInstance3.getId(), execution.getId());
Assert.assertEquals(0, runtimeService.createExecutionQuery().variableValueGreaterThan("doubleVar", 55555.5555).count());
Assert.assertEquals(3, runtimeService.createExecutionQuery().variableValueGreaterThan("doubleVar",1.234).count());
// Test GREATER_THAN_OR_EQUAL
execution = runtimeService.createExecutionQuery().variableValueGreaterThanOrEqual("doubleVar", 44444.4444).singleResult();
Assert.assertNotNull(execution);
Assert.assertEquals(processInstance3.getId(), execution.getId());
execution = runtimeService.createExecutionQuery().variableValueGreaterThanOrEqual("doubleVar", 55555.5555).singleResult();
Assert.assertNotNull(execution);
Assert.assertEquals(processInstance3.getId(), execution.getId());
Assert.assertEquals(3, runtimeService.createExecutionQuery().variableValueGreaterThanOrEqual("doubleVar",1.234).count());
// Test LESS_THAN
executions = runtimeService.createExecutionQuery().variableValueLessThan("doubleVar", 55555.5555).list();
Assert.assertEquals(2, executions.size());
List<String> expecedIds = Arrays.asList(processInstance1.getId(), processInstance2.getId());
List<String> ids = new ArrayList<String>(Arrays.asList(executions.get(0).getId(), executions.get(1).getId()));
ids.removeAll(expecedIds);
assertTrue(ids.isEmpty());
Assert.assertEquals(0, runtimeService.createExecutionQuery().variableValueLessThan("doubleVar", 12345.6789).count());
Assert.assertEquals(3, runtimeService.createExecutionQuery().variableValueLessThan("doubleVar",66666.6666).count());
// Test LESS_THAN_OR_EQUAL
executions = runtimeService.createExecutionQuery().variableValueLessThanOrEqual("doubleVar", 55555.5555).list();
Assert.assertEquals(3, executions.size());
Assert.assertEquals(0, runtimeService.createExecutionQuery().variableValueLessThanOrEqual("doubleVar", 12344.6789).count());
runtimeService.deleteProcessInstance(processInstance1.getId(), "test");
runtimeService.deleteProcessInstance(processInstance2.getId(), "test");
runtimeService.deleteProcessInstance(processInstance3.getId(), "test");
}
示例6: testQueryIntegerVariable
import org.activiti.engine.runtime.ExecutionQuery; //导入方法依赖的package包/类
@Deployment(resources={
"org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml"})
public void testQueryIntegerVariable() {
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("integerVar", 12345);
ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
vars = new HashMap<String, Object>();
vars.put("integerVar", 12345);
vars.put("integerVar2", 67890);
ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
vars = new HashMap<String, Object>();
vars.put("integerVar", 55555);
ProcessInstance processInstance3 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
// Query on single integer variable, should result in 2 matches
ExecutionQuery query = runtimeService.createExecutionQuery().variableValueEquals("integerVar", 12345);
List<Execution> executions = query.list();
Assert.assertNotNull(executions);
Assert.assertEquals(2, executions.size());
// Query on two integer variables, should result in single value
query = runtimeService.createExecutionQuery().variableValueEquals("integerVar", 12345).variableValueEquals("integerVar2", 67890);
Execution execution = query.singleResult();
Assert.assertNotNull(execution);
Assert.assertEquals(processInstance2.getId(), execution.getId());
// Query with unexisting variable value
execution = runtimeService.createExecutionQuery().variableValueEquals("integerVar", 9999).singleResult();
Assert.assertNull(execution);
// Test NOT_EQUALS
execution = runtimeService.createExecutionQuery().variableValueNotEquals("integerVar", 12345).singleResult();
Assert.assertNotNull(execution);
Assert.assertEquals(processInstance3.getId(), execution.getId());
// Test GREATER_THAN
execution = runtimeService.createExecutionQuery().variableValueGreaterThan("integerVar", 44444).singleResult();
Assert.assertNotNull(execution);
Assert.assertEquals(processInstance3.getId(), execution.getId());
Assert.assertEquals(0, runtimeService.createExecutionQuery().variableValueGreaterThan("integerVar", 55555).count());
Assert.assertEquals(3, runtimeService.createExecutionQuery().variableValueGreaterThan("integerVar",1).count());
// Test GREATER_THAN_OR_EQUAL
execution = runtimeService.createExecutionQuery().variableValueGreaterThanOrEqual("integerVar", 44444).singleResult();
Assert.assertNotNull(execution);
Assert.assertEquals(processInstance3.getId(), execution.getId());
execution = runtimeService.createExecutionQuery().variableValueGreaterThanOrEqual("integerVar", 55555).singleResult();
Assert.assertNotNull(execution);
Assert.assertEquals(processInstance3.getId(), execution.getId());
Assert.assertEquals(3, runtimeService.createExecutionQuery().variableValueGreaterThanOrEqual("integerVar",1).count());
// Test LESS_THAN
executions = runtimeService.createExecutionQuery().variableValueLessThan("integerVar", 55555).list();
Assert.assertEquals(2, executions.size());
List<String> expecedIds = Arrays.asList(processInstance1.getId(), processInstance2.getId());
List<String> ids = new ArrayList<String>(Arrays.asList(executions.get(0).getId(), executions.get(1).getId()));
ids.removeAll(expecedIds);
assertTrue(ids.isEmpty());
Assert.assertEquals(0, runtimeService.createExecutionQuery().variableValueLessThan("integerVar", 12345).count());
Assert.assertEquals(3, runtimeService.createExecutionQuery().variableValueLessThan("integerVar",66666).count());
// Test LESS_THAN_OR_EQUAL
executions = runtimeService.createExecutionQuery().variableValueLessThanOrEqual("integerVar", 55555).list();
Assert.assertEquals(3, executions.size());
Assert.assertEquals(0, runtimeService.createExecutionQuery().variableValueLessThanOrEqual("integerVar", 12344).count());
runtimeService.deleteProcessInstance(processInstance1.getId(), "test");
runtimeService.deleteProcessInstance(processInstance2.getId(), "test");
runtimeService.deleteProcessInstance(processInstance3.getId(), "test");
}
示例7: testQueryShortVariable
import org.activiti.engine.runtime.ExecutionQuery; //导入方法依赖的package包/类
@Deployment(resources={
"org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml"})
public void testQueryShortVariable() {
Map<String, Object> vars = new HashMap<String, Object>();
short shortVar = 1234;
vars.put("shortVar", shortVar);
ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
short shortVar2 = 6789;
vars = new HashMap<String, Object>();
vars.put("shortVar", shortVar);
vars.put("shortVar2", shortVar2);
ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
vars = new HashMap<String, Object>();
vars.put("shortVar", (short)5555);
ProcessInstance processInstance3 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
// Query on single short variable, should result in 2 matches
ExecutionQuery query = runtimeService.createExecutionQuery().variableValueEquals("shortVar", shortVar);
List<Execution> executions = query.list();
Assert.assertNotNull(executions);
Assert.assertEquals(2, executions.size());
// Query on two short variables, should result in single value
query = runtimeService.createExecutionQuery().variableValueEquals("shortVar", shortVar).variableValueEquals("shortVar2", shortVar2);
Execution execution = query.singleResult();
Assert.assertNotNull(execution);
Assert.assertEquals(processInstance2.getId(), execution.getId());
// Query with unexisting variable value
short unexistingValue = (short)9999;
execution = runtimeService.createExecutionQuery().variableValueEquals("shortVar", unexistingValue).singleResult();
Assert.assertNull(execution);
// Test NOT_EQUALS
execution = runtimeService.createExecutionQuery().variableValueNotEquals("shortVar", (short)1234).singleResult();
Assert.assertNotNull(execution);
Assert.assertEquals(processInstance3.getId(), execution.getId());
// Test GREATER_THAN
execution = runtimeService.createExecutionQuery().variableValueGreaterThan("shortVar", (short)4444).singleResult();
Assert.assertNotNull(execution);
Assert.assertEquals(processInstance3.getId(), execution.getId());
Assert.assertEquals(0, runtimeService.createExecutionQuery().variableValueGreaterThan("shortVar", (short)5555).count());
Assert.assertEquals(3, runtimeService.createExecutionQuery().variableValueGreaterThan("shortVar",(short)1).count());
// Test GREATER_THAN_OR_EQUAL
execution = runtimeService.createExecutionQuery().variableValueGreaterThanOrEqual("shortVar", (short)4444).singleResult();
Assert.assertNotNull(execution);
Assert.assertEquals(processInstance3.getId(), execution.getId());
execution = runtimeService.createExecutionQuery().variableValueGreaterThanOrEqual("shortVar", (short)5555).singleResult();
Assert.assertNotNull(execution);
Assert.assertEquals(processInstance3.getId(), execution.getId());
Assert.assertEquals(3, runtimeService.createExecutionQuery().variableValueGreaterThanOrEqual("shortVar",(short)1).count());
// Test LESS_THAN
executions = runtimeService.createExecutionQuery().variableValueLessThan("shortVar", (short)5555).list();
Assert.assertEquals(2, executions.size());
List<String> expecedIds = Arrays.asList(processInstance1.getId(), processInstance2.getId());
List<String> ids = new ArrayList<String>(Arrays.asList(executions.get(0).getId(), executions.get(1).getId()));
ids.removeAll(expecedIds);
assertTrue(ids.isEmpty());
Assert.assertEquals(0, runtimeService.createExecutionQuery().variableValueLessThan("shortVar", (short)1234).count());
Assert.assertEquals(3, runtimeService.createExecutionQuery().variableValueLessThan("shortVar",(short)6666).count());
// Test LESS_THAN_OR_EQUAL
executions = runtimeService.createExecutionQuery().variableValueLessThanOrEqual("shortVar", (short)5555).list();
Assert.assertEquals(3, executions.size());
Assert.assertEquals(0, runtimeService.createExecutionQuery().variableValueLessThanOrEqual("shortVar", (short)1233).count());
runtimeService.deleteProcessInstance(processInstance1.getId(), "test");
runtimeService.deleteProcessInstance(processInstance2.getId(), "test");
runtimeService.deleteProcessInstance(processInstance3.getId(), "test");
}
示例8: testQueryVariablesUpdatedToNullValue
import org.activiti.engine.runtime.ExecutionQuery; //导入方法依赖的package包/类
@Deployment(resources={
"org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml"})
public void testQueryVariablesUpdatedToNullValue() {
// Start process instance with different types of variables
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("longVar", 928374L);
variables.put("shortVar", (short) 123);
variables.put("integerVar", 1234);
variables.put("stringVar", "coca-cola");
variables.put("booleanVar", true);
variables.put("dateVar", new Date());
variables.put("nullVar", null);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", variables);
ExecutionQuery query = runtimeService.createExecutionQuery()
.variableValueEquals("longVar", null)
.variableValueEquals("shortVar", null)
.variableValueEquals("integerVar", null)
.variableValueEquals("stringVar", null)
.variableValueEquals("booleanVar", null)
.variableValueEquals("dateVar", null);
ExecutionQuery notQuery = runtimeService.createExecutionQuery()
.variableValueNotEquals("longVar", null)
.variableValueNotEquals("shortVar", null)
.variableValueNotEquals("integerVar", null)
.variableValueNotEquals("stringVar", null)
.variableValueNotEquals("booleanVar", null)
.variableValueNotEquals("dateVar", null);
assertNull(query.singleResult());
assertNotNull(notQuery.singleResult());
// Set all existing variables values to null
runtimeService.setVariable(processInstance.getId(), "longVar", null);
runtimeService.setVariable(processInstance.getId(), "shortVar", null);
runtimeService.setVariable(processInstance.getId(), "integerVar", null);
runtimeService.setVariable(processInstance.getId(), "stringVar", null);
runtimeService.setVariable(processInstance.getId(), "booleanVar", null);
runtimeService.setVariable(processInstance.getId(), "dateVar", null);
runtimeService.setVariable(processInstance.getId(), "nullVar", null);
Execution queryResult = query.singleResult();
assertNotNull(queryResult);
assertEquals(processInstance.getId(), queryResult.getId());
assertNull(notQuery.singleResult());
}