org.camunda.bpm.engine.runtime.Execution.getProcessInstanceId()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(11.7k)|赞(0)|评价(0)|浏览(97)

本文整理了Java中org.camunda.bpm.engine.runtime.Execution.getProcessInstanceId()方法的一些代码示例,展示了Execution.getProcessInstanceId()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Execution.getProcessInstanceId()方法的具体详情如下:
包路径:org.camunda.bpm.engine.runtime.Execution
类名称:Execution
方法名:getProcessInstanceId

Execution.getProcessInstanceId介绍

[英]Id of the root of the execution tree representing the process instance. It is the same as #getId() if this execution is the process instance.
[中]表示流程实例的执行树根的Id。如果此执行是流程实例,则与#getId()相同。

代码示例

代码示例来源:origin: camunda/camunda-bpm-platform

@Override
 public String getProperty(Execution obj) {
  return obj.getProcessInstanceId();
 }
});

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Returns the id of the currently associated process instance or 'null'
 */
public String getProcessInstanceId() {
 Execution execution = associationManager.getExecution();
 return execution != null ? execution.getProcessInstanceId() : null;
}

代码示例来源:origin: camunda/camunda-bpm-platform

public String getProcessInstanceId() {
 return wrappedExecution.getProcessInstanceId();
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Returns the {@link ProcessInstance} currently associated or 'null'
 *
 * @throws ProcessEngineCdiException
 *           if no {@link Execution} is associated. Use
 *           {@link #isAssociated()} to check whether an association exists.
 */
public ProcessInstance getProcessInstance() {
 Execution execution = getExecution();
 if(execution != null && !(execution.getProcessInstanceId().equals(execution.getId()))){
  return processEngine
     .getRuntimeService()
     .createProcessInstanceQuery()
     .processInstanceId(execution.getProcessInstanceId())
     .singleResult();
 }
 return (ProcessInstance) execution;
}

代码示例来源:origin: camunda/camunda-bpm-platform

public static Execution createMockExecution(String tenantId) {
 Execution mock = mock(Execution.class);
 when(mock.getId()).thenReturn(EXAMPLE_EXECUTION_ID);
 when(mock.getProcessInstanceId()).thenReturn(EXAMPLE_PROCESS_INSTANCE_ID);
 when(mock.isEnded()).thenReturn(EXAMPLE_EXECUTION_IS_ENDED);
 when(mock.getTenantId()).thenReturn(tenantId);
 return mock;
}

代码示例来源:origin: camunda/camunda-bpm-platform

public static ExecutionDto fromExecution(Execution execution) {
 ExecutionDto dto = new ExecutionDto();
 dto.id = execution.getId();
 dto.processInstanceId = execution.getProcessInstanceId();
 dto.ended = execution.isEnded();
 dto.tenantId = execution.getTenantId();
 return dto;
}

代码示例来源:origin: camunda/camunda-bpm-platform

public static ExecutionDto fromExecution(Execution execution) {
 ExecutionDto dto = new ExecutionDto();
 dto.id = execution.getId();
 dto.processInstanceId = execution.getProcessInstanceId();
 dto.ended = execution.isEnded();
 dto.tenantId = execution.getTenantId();
 return dto;
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Deployment(resources={"org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml",
  "org/camunda/bpm/engine/test/api/runtime/oneMessageCatchProcess.bpmn20.xml"})
public void testQueryForExecutionsWithMessageEventSubscriptions() {
 runtimeService.startProcessInstanceByKey("oneTaskProcess");
 runtimeService.startProcessInstanceByKey("oneTaskProcess");
 ProcessInstance instance1 = runtimeService.startProcessInstanceByKey("oneMessageCatchProcess");
 ProcessInstance instance2 = runtimeService.startProcessInstanceByKey("oneMessageCatchProcess");
 List<Execution> executions = runtimeService.createExecutionQuery()
   .messageEventSubscription().orderByProcessInstanceId().asc().list();
 assertEquals(2, executions.size());
 if (instance1.getId().compareTo(instance2.getId()) < 0) {
  assertEquals(instance1.getId(), executions.get(0).getProcessInstanceId());
  assertEquals(instance2.getId(), executions.get(1).getProcessInstanceId());
 } else {
  assertEquals(instance2.getId(), executions.get(0).getProcessInstanceId());
  assertEquals(instance1.getId(), executions.get(1).getProcessInstanceId());
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Deployment(resources={
 "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"})
 public void testClashingValues() throws Exception {
  Map<String, Object> vars = new HashMap<String, Object>();
  vars.put("var", 1234L);

  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);

  Map<String, Object> vars2 = new HashMap<String, Object>();
  vars2.put("var", 1234);

  ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars2);

  List<Execution> executions = runtimeService.createExecutionQuery()
  .processDefinitionKey("oneTaskProcess")
  .variableValueEquals("var", 1234L)
  .list();

  assertEquals(1, executions.size());
  assertEquals(processInstance.getId(), executions.get(0).getProcessInstanceId());

  runtimeService.deleteProcessInstance(processInstance.getId(), "test");
  runtimeService.deleteProcessInstance(processInstance2.getId(), "test");
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Override
 public String getProperty(Execution obj) {
  ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
    .processInstanceId(obj.getProcessInstanceId()).singleResult();
  ProcessDefinition processDefinition = repositoryService.getProcessDefinition(processInstance.getProcessDefinitionId());
  return processDefinition.getKey();
 }
});

代码示例来源:origin: camunda/camunda-bpm-platform

@Deployment(resources={"org/camunda/bpm/engine/test/api/runtime/concurrentExecution.bpmn20.xml"})
public void testExecutionQueryForSuspendedExecutions() {
 List<Execution> suspendedExecutions = runtimeService.createExecutionQuery().suspended().list();
 assertEquals(suspendedExecutions.size(), 0);
 for (String instanceId : concurrentProcessInstanceIds) {
  runtimeService.suspendProcessInstanceById(instanceId);
 }
 suspendedExecutions = runtimeService.createExecutionQuery().suspended().list();
 assertEquals(12, suspendedExecutions.size());
 List<Execution> activeExecutions = runtimeService.createExecutionQuery().active().list();
 assertEquals(1, activeExecutions.size());
 for (Execution activeExecution : activeExecutions) {
  assertEquals(activeExecution.getProcessInstanceId(), sequentialProcessInstanceIds.get(0));
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Deployment(resources = "org/camunda/bpm/engine/test/api/runtime/MessageCorrelationTest.testCatchingMessageEventCorrelation.bpmn20.xml")
@Test
public void testMessageCorrelateAllResultListWithResultTypeExecution() {
 //given
 ProcessInstance procInstance1 = runtimeService.startProcessInstanceByKey("process");
 ProcessInstance procInstance2 = runtimeService.startProcessInstanceByKey("process");
 //when correlated all with result
 List<MessageCorrelationResult> resultList = runtimeService.createMessageCorrelation("newInvoiceMessage")
                              .correlateAllWithResult();
 assertEquals(2, resultList.size());
 //then result should contains executions on which messages was correlated
 for (MessageCorrelationResult result : resultList) {
  assertNotNull(result);
  assertEquals(MessageCorrelationResultType.Execution, result.getResultType());
  assertTrue(procInstance1.getId().equalsIgnoreCase(result.getExecution().getProcessInstanceId())
       || procInstance2.getId().equalsIgnoreCase(result.getExecution().getProcessInstanceId())
  );
  ExecutionEntity entity = (ExecutionEntity) result.getExecution();
  assertEquals("messageCatch", entity.getActivityId());
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testSimpleQueryWithReadPermissionOnProcessInstance() {
 // given
 String processInstanceId = startProcessInstanceByKey(ONE_TASK_PROCESS_KEY).getId();
 createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, READ);
 // when
 ExecutionQuery query = runtimeService.createExecutionQuery();
 // then
 verifyQueryResults(query, 1);
 Execution execution = query.singleResult();
 assertNotNull(execution);
 assertEquals(processInstanceId, execution.getProcessInstanceId());
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testSimpleQueryWithReadInstancesPermissionOnOneTaskProcess() {
 // given
 String processInstanceId = startProcessInstanceByKey(ONE_TASK_PROCESS_KEY).getId();
 createGrantAuthorization(PROCESS_DEFINITION, ONE_TASK_PROCESS_KEY, userId, READ_INSTANCE);
 // when
 ExecutionQuery query = runtimeService.createExecutionQuery();
 // then
 verifyQueryResults(query, 1);
 Execution execution = query.singleResult();
 assertNotNull(execution);
 assertEquals(processInstanceId, execution.getProcessInstanceId());
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testSimpleQueryWithReadPermissionOnAnyProcessInstance() {
 // given
 String processInstanceId = startProcessInstanceByKey(ONE_TASK_PROCESS_KEY).getId();
 createGrantAuthorization(PROCESS_INSTANCE, ANY, userId, READ);
 // when
 ExecutionQuery query = runtimeService.createExecutionQuery();
 // then
 verifyQueryResults(query, 1);
 Execution execution = query.singleResult();
 assertNotNull(execution);
 assertEquals(processInstanceId, execution.getProcessInstanceId());
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testSimpleQueryWithReadInstancesPermissionOnAnyProcessDefinition() {
 // given
 String processInstanceId = startProcessInstanceByKey(ONE_TASK_PROCESS_KEY).getId();
 createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_INSTANCE);
 // when
 ExecutionQuery query = runtimeService.createExecutionQuery();
 // then
 verifyQueryResults(query, 1);
 Execution execution = query.singleResult();
 assertNotNull(execution);
 assertEquals(processInstanceId, execution.getProcessInstanceId());
}

代码示例来源:origin: camunda/camunda-bpm-platform

protected void checkExecutionMessageCorrelationResult(MessageCorrelationResult result, ProcessInstance processInstance, String activityId) {
 assertNotNull(result);
 assertEquals(MessageCorrelationResultType.Execution, result.getResultType());
 assertEquals(processInstance.getId(), result.getExecution().getProcessInstanceId());
 ExecutionEntity entity = (ExecutionEntity) result.getExecution();
 assertEquals(activityId, entity.getActivityId());
}

代码示例来源:origin: camunda/camunda-bpm-platform

protected void checkExecutionMessageCorrelationResult(MessageCorrelationResult result, ProcessInstance processInstance, String activityId) {
 assertNotNull(result);
 assertEquals(MessageCorrelationResultType.Execution, result.getResultType());
 assertEquals(processInstance.getId(), result.getExecution().getProcessInstanceId());
 ExecutionEntity entity = (ExecutionEntity) result.getExecution();
 assertEquals(activityId, entity.getActivityId());
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Deployment(resources="org/camunda/bpm/engine/test/api/runtime/oneMessageCatchProcess.bpmn20.xml")
public void testQueryForExecutionsWithMessageEventSubscriptionsOverlappingFilters() {
 ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneMessageCatchProcess");
 Execution execution = runtimeService
  .createExecutionQuery()
  .messageEventSubscriptionName("newInvoiceMessage")
  .messageEventSubscription()
  .singleResult();
 assertNotNull(execution);
 assertEquals(instance.getId(), execution.getProcessInstanceId());
 runtimeService
  .createExecutionQuery()
  .messageEventSubscription()
  .messageEventSubscriptionName("newInvoiceMessage")
  .list();
 assertNotNull(execution);
 assertEquals(instance.getId(), execution.getProcessInstanceId());
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testQueryWithReadPermissionOnProcessInstance() {
 // given
 startProcessInstanceByKey(ONE_TASK_PROCESS_KEY);
 startProcessInstanceByKey(ONE_TASK_PROCESS_KEY);
 String processInstanceId = startProcessInstanceByKey(ONE_TASK_PROCESS_KEY).getId();
 startProcessInstanceByKey(MESSAGE_BOUNDARY_PROCESS_KEY);
 startProcessInstanceByKey(MESSAGE_BOUNDARY_PROCESS_KEY);
 startProcessInstanceByKey(MESSAGE_BOUNDARY_PROCESS_KEY);
 startProcessInstanceByKey(MESSAGE_BOUNDARY_PROCESS_KEY);
 createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, READ);
 // when
 ExecutionQuery query = runtimeService.createExecutionQuery();
 // then
 verifyQueryResults(query, 1);
 Execution execution = query.singleResult();
 assertNotNull(execution);
 assertEquals(processInstanceId, execution.getProcessInstanceId());
}

相关文章