Java Code Examples for org.camunda.bpm.engine.history.HistoricProcessInstance#getId()

The following examples show how to use org.camunda.bpm.engine.history.HistoricProcessInstance#getId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RestartProcessInstancesCmd.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected HistoricActivityInstance resolveStartActivityInstance(
    HistoricProcessInstance processInstance) {
  HistoryService historyService = Context.getProcessEngineConfiguration().getHistoryService();

  String processInstanceId = processInstance.getId();
  String startActivityId = processInstance.getStartActivityId();

  ensureNotNull("startActivityId", startActivityId);

  List<HistoricActivityInstance> historicActivityInstances = historyService
      .createHistoricActivityInstanceQuery()
      .processInstanceId(processInstanceId)
      .activityId(startActivityId)
      .orderPartiallyByOccurrence()
      .asc()
      .list();

  ensureNotEmpty("historicActivityInstances", historicActivityInstances);

  HistoricActivityInstance startActivityInstance = historicActivityInstances.get(0);
  return startActivityInstance;
}
 
Example 2
Source File: HistoricProcessInstanceDto.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public static HistoricProcessInstanceDto fromHistoricProcessInstance(HistoricProcessInstance historicProcessInstance) {

    HistoricProcessInstanceDto dto = new HistoricProcessInstanceDto();

    dto.id = historicProcessInstance.getId();
    dto.businessKey = historicProcessInstance.getBusinessKey();
    dto.processDefinitionId = historicProcessInstance.getProcessDefinitionId();
    dto.processDefinitionKey = historicProcessInstance.getProcessDefinitionKey();
    dto.processDefinitionName = historicProcessInstance.getProcessDefinitionName();
    dto.processDefinitionVersion = historicProcessInstance.getProcessDefinitionVersion();
    dto.startTime = historicProcessInstance.getStartTime();
    dto.endTime = historicProcessInstance.getEndTime();
    dto.removalTime = historicProcessInstance.getRemovalTime();
    dto.durationInMillis = historicProcessInstance.getDurationInMillis();
    dto.startUserId = historicProcessInstance.getStartUserId();
    dto.startActivityId = historicProcessInstance.getStartActivityId();
    dto.deleteReason = historicProcessInstance.getDeleteReason();
    dto.rootProcessInstanceId = historicProcessInstance.getRootProcessInstanceId();
    dto.superProcessInstanceId = historicProcessInstance.getSuperProcessInstanceId();
    dto.superCaseInstanceId = historicProcessInstance.getSuperCaseInstanceId();
    dto.caseInstanceId = historicProcessInstance.getCaseInstanceId();
    dto.tenantId = historicProcessInstance.getTenantId();
    dto.state = historicProcessInstance.getState();

    return dto;
  }
 
Example 3
Source File: InstanceList.java    From camunda-bpm-platform-osgi with Apache License 2.0 5 votes vote down vote up
public void printProcessInfo(String id) {

    List<HistoricProcessInstance> executions = engine.getHistoryService().createHistoricProcessInstanceQuery().processDefinitionId(id).list();
    String[][] data = new String[executions.size()][HEADER.length];
    int i = 0;
    for (HistoricProcessInstance instance : executions) {
      data[i++] = new String[]{
          instance.getId(),
          instance.getDurationInMillis() + " ms",
          instance.getBusinessKey(),
          instance.getStartUserId()
      };
    }
    ASCIITable.getInstance().printTable(HEADER, data);
  }
 
Example 4
Source File: HistoricInstancePermissionsAuthorizationTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldSkipAuthorizationChecksForOperationLogQuery() {
  // given
  engineConfiguration.setEnableHistoricInstancePermissions(true);

  Authorization auth = authorizationService.createNewAuthorization(Authorization.AUTH_TYPE_GRANT);
  auth.setUserId(USER_ID);
  auth.setPermissions(new HistoricProcessInstancePermissions[] {
      HistoricProcessInstancePermissions.READ });
  auth.setResource(Resources.HISTORIC_PROCESS_INSTANCE);

  HistoricProcessInstance historicProcessInstance =
      historyService.createHistoricProcessInstanceQuery()
          .processInstanceBusinessKey(BUSINESS_KEY + "0")
          .singleResult();

  String processInstanceId = historicProcessInstance.getId();

  auth.setResourceId(processInstanceId);

  authorizationService.saveAuthorization(auth);

  engineConfiguration.setAuthorizationEnabled(true);

  // when
  String processDefinitionId = historicProcessInstance.getProcessDefinitionId();

  UserOperationLogQuery query = historyService.createUserOperationLogQuery()
      .processDefinitionId(processDefinitionId);

  // then
  assertThat(query.list())
      .extracting("processDefinitionId")
      .containsExactly(
          processDefinitionId,
          processDefinitionId,
          processDefinitionId,
          processDefinitionId,
          processDefinitionId
      );
}
 
Example 5
Source File: HistoricInstancePermissionsAuthorizationTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldSkipAuthorizationChecksForHistoricProcessInstanceQuery() {
  // given
  engineConfiguration.setEnableHistoricInstancePermissions(true);

  Authorization auth = authorizationService.createNewAuthorization(Authorization.AUTH_TYPE_GRANT);
  auth.setUserId(USER_ID);
  auth.setPermissions(new HistoricProcessInstancePermissions[] {
      HistoricProcessInstancePermissions.READ });
  auth.setResource(Resources.HISTORIC_PROCESS_INSTANCE);

  HistoricProcessInstance historicProcessInstance =
      historyService.createHistoricProcessInstanceQuery()
          .processInstanceBusinessKey(BUSINESS_KEY + "0")
          .singleResult();

  String processInstanceId = historicProcessInstance.getId();

  auth.setResourceId(processInstanceId);

  authorizationService.saveAuthorization(auth);

  engineConfiguration.setAuthorizationEnabled(true);

  // when
  String processDefinitionId = historicProcessInstance.getProcessDefinitionId();

  HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery()
      .processDefinitionId(processDefinitionId);

  // then
  assertThat(query.list())
      .extracting("businessKey")
      .containsExactly(
          BUSINESS_KEY + "0",
          BUSINESS_KEY + "1",
          BUSINESS_KEY + "2",
          BUSINESS_KEY + "3",
          BUSINESS_KEY + "4"
      );
}