Ejemplo n.º 1
0
  @Test
  public void BGC_transfer() throws Exception {
    fakeSparService.add(OTHER_PERSONAL_IDENTIFIER, ADDRESS);

    Map<String, Object> properties = new HashMap<>();
    properties.put("personalIdentifier", OTHER_PERSONAL_IDENTIFIER);
    String ocr = "5450897";
    properties.put("ocr", ocr);

    runtimeService.startProcessInstanceByMessage("create-insurance", ocr, properties);

    when_all_jobs_within_X_days_are_executed(10);

    Execution execution =
        runtimeService
            .createExecutionQuery()
            .messageEventSubscriptionName("bgc")
            .processVariableValueEquals("ocr", ocr)
            .singleResult();

    assertThat(execution, notNullValue());

    Map<String, Object> eventProperties = new HashMap<String, Object>();
    properties.put("amount", 56000);
    runtimeService.messageEventReceived("bgc", execution.getId(), eventProperties);
  }
 protected Execution getExecutionFromRequest(String executionId) {
   RuntimeService runtimeService = BPMNOSGIService.getRumtimeService();
   Execution execution =
       runtimeService.createExecutionQuery().executionId(executionId).singleResult();
   if (execution == null) {
     throw new ActivitiObjectNotFoundException(
         "Could not find an execution with id '" + executionId + "'.", Execution.class);
   }
   return execution;
 }
Ejemplo n.º 3
0
 @Test
 public void testExecutionQuery() {
   // Given
   RuntimeService runtimeService = mock(RuntimeService.class);
   ExecutionQuery executionQuery = mock(ExecutionQuery.class);
   when(processEngine.getRuntimeService()).thenReturn(runtimeService);
   when(runtimeService.createExecutionQuery()).thenReturn(executionQuery);
   // When
   ExecutionQuery createdQuery = executionQuery();
   // Then
   assertThat(createdQuery).isNotNull().isSameAs(executionQuery);
   verify(runtimeService, times(1)).createExecutionQuery();
   verifyNoMoreInteractions(runtimeService);
 }
Ejemplo n.º 4
0
  /**
   * 流程跟踪图
   *
   * @param processInstanceId 流程实例ID
   * @return 封装了各种节点信息
   */
  public List<Map<String, Object>> traceProcess(String processInstanceId) throws Exception {
    Execution execution =
        runtimeService.createExecutionQuery().executionId(processInstanceId).singleResult(); // 执行实例
    Object property = PropertyUtils.getProperty(execution, "activityId");
    String activityId = "";
    if (property != null) {
      activityId = property.toString();
    }
    ProcessInstance processInstance =
        runtimeService
            .createProcessInstanceQuery()
            .processInstanceId(processInstanceId)
            .singleResult();
    ProcessDefinitionEntity processDefinition =
        (ProcessDefinitionEntity)
            ((RepositoryServiceImpl) repositoryService)
                .getDeployedProcessDefinition(processInstance.getProcessDefinitionId());
    List<ActivityImpl> activitiList = processDefinition.getActivities(); // 获得当前任务的所有节点

    List<Map<String, Object>> activityInfos = new ArrayList<Map<String, Object>>();
    for (ActivityImpl activity : activitiList) {

      boolean currentActiviti = false;
      String id = activity.getId();

      // 当前节点
      if (id.equals(activityId)) {
        currentActiviti = true;
      }

      Map<String, Object> activityImageInfo =
          packageSingleActivitiInfo(activity, processInstance, currentActiviti);

      activityInfos.add(activityImageInfo);
    }

    return activityInfos;
  }
  protected DataResponse getQueryResponse(
      ExecutionQueryRequest queryRequest, Map<String, String> requestParams, UriInfo uriInfo) {

    RuntimeService runtimeService = BPMNOSGIService.getRumtimeService();
    ExecutionQuery query = runtimeService.createExecutionQuery();

    // Populate query based on request
    if (queryRequest.getId() != null) {
      query.executionId(queryRequest.getId());
      requestParams.put("id", queryRequest.getId());
    }
    if (queryRequest.getProcessInstanceId() != null) {
      query.processInstanceId(queryRequest.getProcessInstanceId());
      requestParams.put("processInstanceId", queryRequest.getProcessInstanceId());
    }
    if (queryRequest.getProcessDefinitionKey() != null) {
      query.processDefinitionKey(queryRequest.getProcessDefinitionKey());
      requestParams.put("processDefinitionKey", queryRequest.getProcessDefinitionKey());
    }
    if (queryRequest.getProcessDefinitionId() != null) {
      query.processDefinitionId(queryRequest.getProcessDefinitionId());
      requestParams.put("processDefinitionId", queryRequest.getProcessDefinitionId());
    }
    if (queryRequest.getProcessBusinessKey() != null) {
      query.processInstanceBusinessKey(queryRequest.getProcessBusinessKey());
      requestParams.put("processInstanceBusinessKey", queryRequest.getProcessBusinessKey());
    }
    if (queryRequest.getActivityId() != null) {
      query.activityId(queryRequest.getActivityId());
      requestParams.put("activityId", queryRequest.getActivityId());
    }
    if (queryRequest.getParentId() != null) {
      query.parentId(queryRequest.getParentId());
      requestParams.put("parentId", queryRequest.getParentId());
    }
    if (queryRequest.getMessageEventSubscriptionName() != null) {
      query.messageEventSubscriptionName(queryRequest.getMessageEventSubscriptionName());
      requestParams.put(
          "messageEventSubscriptionName", queryRequest.getMessageEventSubscriptionName());
    }
    if (queryRequest.getSignalEventSubscriptionName() != null) {
      query.signalEventSubscriptionName(queryRequest.getSignalEventSubscriptionName());
      requestParams.put(
          "signalEventSubscriptionName", queryRequest.getSignalEventSubscriptionName());
    }

    if (queryRequest.getVariables() != null) {
      addVariables(query, queryRequest.getVariables(), false);
    }

    if (queryRequest.getProcessInstanceVariables() != null) {
      addVariables(query, queryRequest.getProcessInstanceVariables(), true);
    }

    if (queryRequest.getTenantId() != null) {
      query.executionTenantId(queryRequest.getTenantId());
      requestParams.put("tenantId", queryRequest.getTenantId());
    }

    if (queryRequest.getTenantIdLike() != null) {
      query.executionTenantIdLike(queryRequest.getTenantIdLike());
      requestParams.put("tenantIdLike", queryRequest.getTenantIdLike());
    }

    if (Boolean.TRUE.equals(queryRequest.getWithoutTenantId())) {
      query.executionWithoutTenantId();
      requestParams.put("withoutTenantId", queryRequest.getWithoutTenantId().toString());
    }

    DataResponse dataResponse =
        new ExecutionPaginateList(new RestResponseFactory(), uriInfo)
            .paginateList(
                requestParams, queryRequest, query, "processInstanceId", allowedSortProperties);
    return dataResponse;
  }