Package org.activiti.engine.history

Examples of org.activiti.engine.history.HistoricProcessInstance


        String processInstanceId = processInstance.getId();

        LOG.info("Started process instance id " + processInstanceId);
        runtimeService.createProcessInstanceQuery().count();

        HistoricProcessInstance historicProcessInstance = processEngine
            .getHistoryService().createHistoricProcessInstanceQuery()
            .processInstanceId(processInstanceId).singleResult();

        if (historicProcessInstance != null) {
            LOG.info("Finished " + processKey + "Instance. took "
                + historicProcessInstance.getDurationInMillis() + " millis");
        }
        return processInstance;
    }
View Full Code Here


    variableMap.put("initiator", "henryyan");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("initiator", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());
   
    HistoricProcessInstance singleResult = activitiRule.getHistoryService().createHistoricProcessInstanceQuery().singleResult();
    System.out.println(singleResult.getStartUserId());
  }
View Full Code Here

  @Get
  public ObjectNode getProcessInstance() {
    if(authenticate() == false) return null;
   
    String processInstanceId = (String) getRequest().getAttributes().get("processInstanceId");
    HistoricProcessInstance instance = ActivitiUtil.getHistoryService()
        .createHistoricProcessInstanceQuery()
        .processInstanceId(processInstanceId)
        .singleResult();
   
    if(instance == null) {
      throw new ActivitiException("Process instance not found for id " + processInstanceId);
    }
   
    ObjectNode responseJSON = new ObjectMapper().createObjectNode();
    responseJSON.put("processInstanceId", instance.getId());
    if (instance.getBusinessKey() != null) {
      responseJSON.put("businessKey", instance.getBusinessKey());
    } else {
      responseJSON.putNull("businessKey");
    }
    responseJSON.put("processDefinitionId", instance.getProcessDefinitionId());
    responseJSON.put("startTime", RequestUtil.dateToString(instance.getStartTime()));
    responseJSON.put("startActivityId", instance.getStartActivityId());
    if (instance.getStartUserId() != null) {
      responseJSON.put("startUserId", instance.getStartUserId());
    } else {
      responseJSON.putNull("startUserId");
    }
   
    if(instance.getEndTime() == null) {
      responseJSON.put("completed", false);
    } else {
      responseJSON.put("completed", true);
      responseJSON.put("endTime", RequestUtil.dateToString(instance.getEndTime()));
      responseJSON.put("endActivityId", instance.getEndActivityId());
      responseJSON.put("duration", instance.getDurationInMillis());
    }
   
    addTaskList(processInstanceId, responseJSON);
    addActivityList(processInstanceId, responseJSON);
    addVariableList(processInstanceId, responseJSON);
View Full Code Here

  public Object execute(CommandContext commandContext) {
    if (processInstanceId == null) {
      throw new ActivitiException("processInstanceId is null");
    }
    // Check if process instance is still running
    HistoricProcessInstance instance = commandContext
      .getHistoricProcessInstanceManager()
      .findHistoricProcessInstance(processInstanceId);
   
    if(instance == null) {
      throw new ActivitiException("No historic process instance found with id: " + processInstanceId);
    }
    if(instance.getEndTime() == null) {
      throw new ActivitiException("Process instance is still running, cannot delete historic process instance: " + processInstanceId);
    }
   
    commandContext
      .getHistoricProcessInstanceManager()
View Full Code Here

    ProcessEngines.destroy();
  }

  private void checkStatus(ProcessEngine processEngine) {
    HistoryService historyService = processEngine.getHistoryService();
    final HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().
                                                            finished().
                                                            includeProcessVariables().
                                                            singleResult();
    assertNotNull(historicProcessInstance);
    RepositoryService repositoryService = processEngine.getRepositoryService();
    final ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().
                                                processDefinitionId(historicProcessInstance.getProcessDefinitionId()).
                                                singleResult();
    assertEquals(SIMPLEST_PROCESS, processDefinition.getKey());

    assertEquals(1, historicProcessInstance.getProcessVariables().size());
    assertEquals(TEST_VALUE, historicProcessInstance.getProcessVariables().get(TEST_VARIABLE));
    assertEquals(BUSINESS_KEY, historicProcessInstance.getBusinessKey());
  }
View Full Code Here

      .eventHandlers(getHandlers());
    return builder.build();
  }

  private void checkStatus(HistoryService historyService) {
    final HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().
      finished().
      singleResult();
    assertNotNull(historicProcessInstance);
    assertEquals("oneTaskProcessBusinessKey", historicProcessInstance.getBusinessKey());
    HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskDefinitionKey("userTask").singleResult();
    assertEquals("user1", historicTaskInstance.getAssignee());
  }
View Full Code Here

    processEngine.getRuntimeService().startProcessInstanceByKey(SIMPLEST_PROCESS, BUSINESS_KEY, variables);
  }

 
  public void demoCheckStatus() {
    final HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().
      finished().
      includeProcessVariables().
      singleResult();
    assertNotNull(historicProcessInstance);
    RepositoryService repositoryService = processEngine.getRepositoryService();
    final ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().
      processDefinitionId(historicProcessInstance.getProcessDefinitionId()).
      singleResult();
    assertEquals(SIMPLEST_PROCESS, processDefinition.getKey());

    assertEquals(1, historicProcessInstance.getProcessVariables().size());
    assertEquals(TEST_VALUE, historicProcessInstance.getProcessVariables().get(TEST_VARIABLE));
    assertEquals(BUSINESS_KEY, historicProcessInstance.getBusinessKey());
  }
View Full Code Here

    runtimeService.startProcessInstanceByMessage("startProcessMessage");
  }

 
  public void messageProcessStartCheckStatus() {
    final HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().
      finished().
      singleResult();
    assertNotNull(historicProcessInstance);
    assertTrue(startsWith(historicProcessInstance.getProcessDefinitionId(), "messageStartEventProcess"));
  }
View Full Code Here

    taskService.complete(task.getId());
  }

 
  public void userTaskCheckStatus() {
    final HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().
      finished().
      singleResult();
    assertNotNull(historicProcessInstance);
    assertEquals("oneTaskProcessBusinessKey", historicProcessInstance.getBusinessKey());
    HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskDefinitionKey("userTask").singleResult();
    assertEquals("user1", historicTaskInstance.getAssignee());
  }
View Full Code Here

              .processInstanceId(processInstance.getId())
              .singleResult();
     
      assertEquals(deleteReason, historicTaskInstance.getDeleteReason());
     
      HistoricProcessInstance historicInstance = historyService.createHistoricProcessInstanceQuery()
          .processInstanceId(processInstance.getId())
          .singleResult();
     
      assertNotNull(historicInstance);
      assertEquals(deleteReason, historicInstance.getDeleteReason());
      assertNotNull(historicInstance.getEndTime());
    }   
  }
View Full Code Here

TOP

Related Classes of org.activiti.engine.history.HistoricProcessInstance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.