Java Code Examples for org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity#getProcessDefinition()

The following examples show how to use org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity#getProcessDefinition() . 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: UserOperationLogContextEntryBuilder.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public UserOperationLogContextEntryBuilder inContextOf(ExecutionEntity processInstance, List<PropertyChange> propertyChanges) {

    if (propertyChanges == null || propertyChanges.isEmpty()) {
      if (OPERATION_TYPE_CREATE.equals(entry.getOperationType())) {
        propertyChanges = Arrays.asList(PropertyChange.EMPTY_CHANGE);
      }
    }
    entry.setPropertyChanges(propertyChanges);
    entry.setRootProcessInstanceId(processInstance.getRootProcessInstanceId());
    entry.setProcessInstanceId(processInstance.getProcessInstanceId());
    entry.setProcessDefinitionId(processInstance.getProcessDefinitionId());
    entry.setExecutionId(processInstance.getId());
    entry.setCaseInstanceId(processInstance.getCaseInstanceId());

    ProcessDefinitionEntity definition = processInstance.getProcessDefinition();
    if (definition != null) {
      entry.setProcessDefinitionKey(definition.getKey());
      entry.setDeploymentId(definition.getDeploymentId());
    }

    return this;
  }
 
Example 2
Source File: MigratingInstanceParseContext.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public MigratingInstanceParseContext(
    MigratingInstanceParser parser,
    MigrationPlan migrationPlan,
    ExecutionEntity processInstance,
    ProcessDefinitionEntity targetProcessDefinition) {
  this.parser = parser;
  this.sourceProcessDefinition = processInstance.getProcessDefinition();
  this.targetProcessDefinition = targetProcessDefinition;
  this.migratingProcessInstance = new MigratingProcessInstance(processInstance.getId(), sourceProcessDefinition, targetProcessDefinition);
  this.mapping = new ActivityExecutionTreeMapping(Context.getCommandContext(), processInstance.getId());
  this.instructionsBySourceScope = organizeInstructionsBySourceScope(migrationPlan);
}
 
Example 3
Source File: ActivityExecutionTreeMapping.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void initialize() {
  ExecutionEntity processInstance = commandContext.getExecutionManager().findExecutionById(processInstanceId);
  this.processDefinition = processInstance.getProcessDefinition();

  List<ExecutionEntity> executions = fetchExecutionsForProcessInstance(processInstance);
  executions.add(processInstance);

  List<ExecutionEntity> leaves = findLeaves(executions);

  assignExecutionsToActivities(leaves);
}
 
Example 4
Source File: UserOperationLogContextEntryBuilder.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public UserOperationLogContextEntryBuilder inContextOf(ExecutionEntity execution) {
  entry.setProcessInstanceId(execution.getProcessInstanceId());
  entry.setRootProcessInstanceId(execution.getRootProcessInstanceId());
  entry.setProcessDefinitionId(execution.getProcessDefinitionId());

  ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) execution.getProcessDefinition();
  entry.setProcessDefinitionKey(processDefinition.getKey());
  entry.setDeploymentId(processDefinition.getDeploymentId());

  return this;
}
 
Example 5
Source File: ActivityBeforeInstantiationCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public Void execute(CommandContext commandContext) {
  ExecutionEntity processInstance = commandContext.getExecutionManager().findExecutionById(processInstanceId);
  ProcessDefinitionImpl processDefinition = processInstance.getProcessDefinition();

  PvmActivity activity = processDefinition.findActivity(activityId);

  // forbid instantiation of compensation boundary events
  if (activity != null && "compensationBoundaryCatch".equals(activity.getProperty("type"))) {
    throw new ProcessEngineException("Cannot start before activity " + activityId + "; activity " +
      "is a compensation boundary event.");
  }

  return super.execute(commandContext);
}
 
Example 6
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 7
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 8
Source File: DefaultHistoryEventProducer.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public HistoryEvent createFormPropertyUpdateEvt(ExecutionEntity execution, String propertyId, String propertyValue, String taskId) {

    final IdGenerator idGenerator = Context.getProcessEngineConfiguration().getIdGenerator();

    HistoricFormPropertyEventEntity historicFormPropertyEntity = newHistoricFormPropertyEvent();

    historicFormPropertyEntity.setId(idGenerator.getNextId());
    historicFormPropertyEntity.setEventType(HistoryEventTypes.FORM_PROPERTY_UPDATE.getEventName());
    historicFormPropertyEntity.setTimestamp(ClockUtil.getCurrentTime());
    historicFormPropertyEntity.setActivityInstanceId(execution.getActivityInstanceId());
    historicFormPropertyEntity.setExecutionId(execution.getId());
    historicFormPropertyEntity.setProcessDefinitionId(execution.getProcessDefinitionId());
    historicFormPropertyEntity.setProcessInstanceId(execution.getProcessInstanceId());
    historicFormPropertyEntity.setPropertyId(propertyId);
    historicFormPropertyEntity.setPropertyValue(propertyValue);
    historicFormPropertyEntity.setTaskId(taskId);
    historicFormPropertyEntity.setTenantId(execution.getTenantId());
    historicFormPropertyEntity.setUserOperationId(Context.getCommandContext().getOperationId());
    historicFormPropertyEntity.setRootProcessInstanceId(execution.getRootProcessInstanceId());

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

    ProcessDefinitionEntity definition = execution.getProcessDefinition();
    if (definition != null) {
      historicFormPropertyEntity.setProcessDefinitionKey(definition.getKey());
    }

    // initialize sequence counter
    initSequenceCounter(execution, historicFormPropertyEntity);

    return historicFormPropertyEntity;
  }
 
Example 9
Source File: DefaultCallableElementTenantIdProvider.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected String getProcessDefinitionTenantId(ExecutionEntity execution) {
  ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) execution.getProcessDefinition();
  return processDefinition.getTenantId();
}
 
Example 10
Source File: DefaultHistoryEventProducer.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected void initActivityInstanceEvent(HistoricActivityInstanceEventEntity evt,
    ExecutionEntity execution,
    PvmScope eventSource,
    String activityInstanceId,
    String parentActivityInstanceId,
    HistoryEventType eventType) {

  evt.setId(activityInstanceId);
  evt.setEventType(eventType.getEventName());
  evt.setActivityInstanceId(activityInstanceId);
  evt.setParentActivityInstanceId(parentActivityInstanceId);
  evt.setProcessDefinitionId(execution.getProcessDefinitionId());
  evt.setProcessInstanceId(execution.getProcessInstanceId());
  evt.setExecutionId(execution.getId());
  evt.setTenantId(execution.getTenantId());
  evt.setRootProcessInstanceId(execution.getRootProcessInstanceId());

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

  ProcessDefinitionEntity definition = execution.getProcessDefinition();
  if (definition != null) {
    evt.setProcessDefinitionKey(definition.getKey());
  }

  evt.setActivityId(eventSource.getId());
  evt.setActivityName((String) eventSource.getProperty("name"));
  evt.setActivityType((String) eventSource.getProperty("type"));

  // update sub process reference
  ExecutionEntity subProcessInstance = execution.getSubProcessInstance();
  if (subProcessInstance != null) {
    evt.setCalledProcessInstanceId(subProcessInstance.getId());
  }

  // update sub case reference
  CaseExecutionEntity subCaseInstance = execution.getSubCaseInstance();
  if (subCaseInstance != null) {
    evt.setCalledCaseInstanceId(subCaseInstance.getId());
  }
}