Java Code Examples for org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity#getKey()

The following examples show how to use org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity#getKey() . 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: CompensationEventCoverageHandler.java    From camunda-bpm-process-test-coverage with Apache License 2.0 6 votes vote down vote up
private void addCompensationEventCoverage(EventSubscriptionEntity eventSubscription) {
  if (Api.Camunda.supportsCompensationEventCoverage()) {

      final ActivityImpl activity = eventSubscription.getActivity();

      // Get process definition key
      final ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) activity.getProcessDefinition();
      final String processDefinitionKey = processDefinition.getKey();

      // Get compensation boundary event ID
      final ActivityImpl sourceEvent = (ActivityImpl) activity.getProperty(
          BpmnProperties.COMPENSATION_BOUNDARY_EVENT.getName());

      if (sourceEvent != null) {

          final String sourceEventId = sourceEvent.getActivityId();

          // Register covered element
          final CoveredFlowNode compensationBoundaryEvent = new CoveredFlowNode(processDefinitionKey, sourceEventId);
          compensationBoundaryEvent.setEnded(true);
          coverageTestRunState.addCoveredElement(compensationBoundaryEvent);

      }

  }
}
 
Example 2
Source File: DeleteProcessDefinitionsByIdsCmd.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected Set<ProcessDefinitionGroup> groupByKeyAndTenant(List<ProcessDefinition> processDefinitions) {
  Set<ProcessDefinitionGroup> groups = new HashSet<ProcessDefinitionGroup>();
  Map<ProcessDefinitionGroup, List<ProcessDefinitionEntity>> map = new HashMap<ProcessDefinitionGroup, List<ProcessDefinitionEntity>>();

  for (ProcessDefinition current : processDefinitions) {
    ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) current;

    ProcessDefinitionGroup group = new ProcessDefinitionGroup();
    group.key = processDefinition.getKey();
    group.tenant = processDefinition.getTenantId();

    List<ProcessDefinitionEntity> definitions = group.processDefinitions;
    if (map.containsKey(group)) {
      definitions = map.get(group);
    }
    else {
      groups.add(group);
      map.put(group, definitions);
    }

    definitions.add(processDefinition);
  }

  return groups;
}
 
Example 3
Source File: DeleteProcessDefinitionsByIdsCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected boolean isLatestProcessDefinition(ProcessDefinitionEntity processDefinition) {
  ProcessDefinitionManager processDefinitionManager = Context.getCommandContext().getProcessDefinitionManager();
  String key = processDefinition.getKey();
  String tenantId = processDefinition.getTenantId();
  ProcessDefinitionEntity latestProcessDefinition = processDefinitionManager.findLatestDefinitionByKeyAndTenantId(key, tenantId);
  return processDefinition.getId().equals(latestProcessDefinition.getId());
}
 
Example 4
Source File: SetProcessDefinitionVersionCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void validateAndSwitchVersionOfExecution(CommandContext commandContext, ExecutionEntity execution, ProcessDefinitionEntity newProcessDefinition) {
  // check that the new process definition version contains the current activity
  if (execution.getActivity() != null) {
    String activityId = execution.getActivity().getId();
    PvmActivity newActivity = newProcessDefinition.findActivity(activityId);

    if (newActivity == null) {
      throw new ProcessEngineException(
        "The new process definition " +
        "(key = '" + newProcessDefinition.getKey() + "') " +
        "does not contain the current activity " +
        "(id = '" + activityId + "') " +
        "of the process instance " +
        "(id = '" + processInstanceId + "').");
      }

      // clear cached activity so that outgoing transitions are refreshed
      execution.setActivity(newActivity);
    }

  // switch the process instance to the new process definition version
  execution.setProcessDefinition(newProcessDefinition);

  // and change possible existing tasks (as the process definition id is stored there too)
  List<TaskEntity> tasks = commandContext.getTaskManager().findTasksByExecutionId(execution.getId());
  for (TaskEntity taskEntity : tasks) {
    taskEntity.setProcessDefinitionId(newProcessDefinition.getId());
  }
}
 
Example 5
Source File: DefaultDmnHistoryEventProducer.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected String getProcessDefinitionKey(ExecutionEntity execution) {
  ProcessDefinitionEntity definition = execution.getProcessDefinition();
  if (definition != null) {
    return definition.getKey();
  } else {
    return null;
  }
}
 
Example 6
Source File: DefaultHistoryEventProducer.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void initProcessInstanceEvent(HistoricProcessInstanceEventEntity evt, ExecutionEntity execution, HistoryEventType eventType) {

    String processDefinitionId = execution.getProcessDefinitionId();
    String processInstanceId = execution.getProcessInstanceId();
    String executionId = execution.getId();
    // the given execution is the process instance!
    String caseInstanceId = execution.getCaseInstanceId();
    String tenantId = execution.getTenantId();

    ProcessDefinitionEntity definition = execution.getProcessDefinition();
    String processDefinitionKey = null;
    if (definition != null) {
      processDefinitionKey = definition.getKey();
    }

    evt.setId(processInstanceId);
    evt.setEventType(eventType.getEventName());
    evt.setProcessDefinitionKey(processDefinitionKey);
    evt.setProcessDefinitionId(processDefinitionId);
    evt.setProcessInstanceId(processInstanceId);
    evt.setExecutionId(executionId);
    evt.setBusinessKey(execution.getProcessBusinessKey());
    evt.setCaseInstanceId(caseInstanceId);
    evt.setTenantId(tenantId);
    evt.setRootProcessInstanceId(execution.getRootProcessInstanceId());

    if (execution.getSuperCaseExecution() != null) {
      evt.setSuperCaseInstanceId(execution.getSuperCaseExecution().getCaseInstanceId());
    }
    if (execution.getSuperExecution() != null) {
      evt.setSuperProcessInstanceId(execution.getSuperExecution().getProcessInstanceId());
    }
  }
 
Example 7
Source File: DefaultHistoryEventProducer.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected void initTaskInstanceEvent(HistoricTaskInstanceEventEntity evt, TaskEntity taskEntity, HistoryEventType eventType) {

    String processDefinitionKey = null;
    ProcessDefinitionEntity definition = taskEntity.getProcessDefinition();
    if (definition != null) {
      processDefinitionKey = definition.getKey();
    }

    String processDefinitionId = taskEntity.getProcessDefinitionId();
    String processInstanceId = taskEntity.getProcessInstanceId();
    String executionId = taskEntity.getExecutionId();

    String caseDefinitionKey = null;
    CaseDefinitionEntity caseDefinition = taskEntity.getCaseDefinition();
    if (caseDefinition != null) {
      caseDefinitionKey = caseDefinition.getKey();
    }

    String caseDefinitionId = taskEntity.getCaseDefinitionId();
    String caseExecutionId = taskEntity.getCaseExecutionId();
    String caseInstanceId = taskEntity.getCaseInstanceId();
    String tenantId = taskEntity.getTenantId();

    evt.setId(taskEntity.getId());
    evt.setEventType(eventType.getEventName());
    evt.setTaskId(taskEntity.getId());

    evt.setProcessDefinitionKey(processDefinitionKey);
    evt.setProcessDefinitionId(processDefinitionId);
    evt.setProcessInstanceId(processInstanceId);
    evt.setExecutionId(executionId);

    evt.setCaseDefinitionKey(caseDefinitionKey);
    evt.setCaseDefinitionId(caseDefinitionId);
    evt.setCaseExecutionId(caseExecutionId);
    evt.setCaseInstanceId(caseInstanceId);

    evt.setAssignee(taskEntity.getAssignee());
    evt.setDescription(taskEntity.getDescription());
    evt.setDueDate(taskEntity.getDueDate());
    evt.setFollowUpDate(taskEntity.getFollowUpDate());
    evt.setName(taskEntity.getName());
    evt.setOwner(taskEntity.getOwner());
    evt.setParentTaskId(taskEntity.getParentTaskId());
    evt.setPriority(taskEntity.getPriority());
    evt.setTaskDefinitionKey(taskEntity.getTaskDefinitionKey());
    evt.setTenantId(tenantId);

    ExecutionEntity execution = taskEntity.getExecution();
    if (execution != null) {
      evt.setActivityInstanceId(execution.getActivityInstanceId());
      evt.setRootProcessInstanceId(execution.getRootProcessInstanceId());

      if (isHistoryRemovalTimeStrategyStart()) {
        provideRemovalTime(evt);
      }
    }

  }