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

The following examples show how to use org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity#getParent() . 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: DefaultHistoryEventProducer.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void initActivityInstanceEvent(HistoricActivityInstanceEventEntity evt, ExecutionEntity execution, HistoryEventType eventType) {
  PvmScope eventSource = execution.getActivity();
  if (eventSource == null) {
    eventSource = (PvmScope) execution.getEventSource();
  }
  String activityInstanceId = execution.getActivityInstanceId();

  String parentActivityInstanceId = null;
  ExecutionEntity parentExecution = execution.getParent();

  if (parentExecution != null && CompensationBehavior.isCompensationThrowing(parentExecution) && execution.getActivity() != null) {
    parentActivityInstanceId = CompensationBehavior.getParentActivityInstanceId(execution);
  } else {
    parentActivityInstanceId = execution.getParentActivityInstanceId();
  }

  initActivityInstanceEvent(evt,
      execution,
      eventSource,
      activityInstanceId,
      parentActivityInstanceId,
      eventType);
}
 
Example 2
Source File: VariableInstanceHandler.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void handle(MigratingInstanceParseContext parseContext, MigratingProcessElementInstance owningInstance, List<VariableInstanceEntity> variables) {

  ExecutionEntity representativeExecution = owningInstance.resolveRepresentativeExecution();

  for (VariableInstanceEntity variable : variables) {
    parseContext.consume(variable);
    boolean isConcurrentLocalInParentScope =
         (variable.getExecution() == representativeExecution.getParent() && variable.isConcurrentLocal())
      || representativeExecution.isConcurrent();
    owningInstance.addMigratingDependentInstance(new MigratingVariableInstance(variable, isConcurrentLocalInParentScope));
  }
}
 
Example 3
Source File: ActivityInstanceHandler.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected List<VariableInstanceEntity> collectActivityInstanceVariables(MigratingActivityInstance instance) {
  List<VariableInstanceEntity> variables = new ArrayList<VariableInstanceEntity>();
  ExecutionEntity representativeExecution = instance.resolveRepresentativeExecution();
  ExecutionEntity parentExecution = representativeExecution.getParent();

  // decide for representative execution and parent execution whether to none/all/concurrentLocal variables
  // belong to this activity instance
  boolean addAllRepresentativeExecutionVariables = instance.getSourceScope().isScope()
      || representativeExecution.isConcurrent();

  if (addAllRepresentativeExecutionVariables) {
    variables.addAll(representativeExecution.getVariablesInternal());
  }
  else {
    variables.addAll(getConcurrentLocalVariables(representativeExecution));
  }

  boolean addAnyParentExecutionVariables = parentExecution != null && instance.getSourceScope().isScope();
  if (addAnyParentExecutionVariables) {
    boolean addAllParentExecutionVariables = parentExecution.isConcurrent();

    if (addAllParentExecutionVariables) {
      variables.addAll(parentExecution.getVariablesInternal());
    }
    else {
      variables.addAll(getConcurrentLocalVariables(parentExecution));
    }
  }

  return variables;
}
 
Example 4
Source File: MigratingVariableInstance.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void attachState(MigratingScopeInstance owningActivityInstance) {
  ExecutionEntity representativeExecution = owningActivityInstance.resolveRepresentativeExecution();
  ScopeImpl currentScope = owningActivityInstance.getCurrentScope();

  ExecutionEntity newOwningExecution = representativeExecution;

  if (currentScope.isScope() && isConcurrentLocalInParentScope) {
    newOwningExecution = representativeExecution.getParent();
  }

  newOwningExecution.addVariableInternal(variable);
}
 
Example 5
Source File: MigratingActivityInstance.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void detachState() {
  ExecutionEntity currentScopeExecution = resolveRepresentativeExecution();

  ExecutionEntity parentExecution = currentScopeExecution.getParent();
  currentScopeExecution.setParent(null);

  if (sourceScope.getActivityBehavior() instanceof CompositeActivityBehavior) {
    parentExecution.leaveActivityInstance();
  }

  getParent().destroyAttachableExecution(parentExecution);
}
 
Example 6
Source File: MigratingActivityInstance.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void migrateState() {
  ExecutionEntity currentScopeExecution = resolveRepresentativeExecution();
  currentScopeExecution.setProcessDefinition(targetScope.getProcessDefinition());

  ExecutionEntity parentExecution = currentScopeExecution.getParent();

  if (parentExecution != null && parentExecution.isConcurrent()) {
    parentExecution.setProcessDefinition(targetScope.getProcessDefinition());
  }

  currentScope = targetScope;

  if (!targetScope.isScope()) {
    becomeNonScope();
    currentScopeExecution = resolveRepresentativeExecution();
  }

  if (isLeafActivity(targetScope)) {
    currentScopeExecution.setActivity((PvmActivity) targetScope);
  }

  if (sourceScope.getActivityBehavior() instanceof MigrationObserverBehavior) {
    ((MigrationObserverBehavior) sourceScope.getActivityBehavior()).migrateScope(currentScopeExecution);
  }

  migrateHistory(currentScopeExecution);
}
 
Example 7
Source File: ModificationUtil.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static void handleChildRemovalInScope(ExecutionEntity removedExecution) {
  ActivityImpl activity = removedExecution.getActivity();
  if (activity == null) {
    if (removedExecution.getSuperExecution() != null) {
      removedExecution = removedExecution.getSuperExecution();
      activity = removedExecution.getActivity();
      if (activity == null) {
        return;
      }
    } else {
      return;
    }
  }
  ScopeImpl flowScope = activity.getFlowScope();

  PvmExecutionImpl scopeExecution = removedExecution.getParentScopeExecution(false);
  PvmExecutionImpl executionInParentScope = removedExecution.isConcurrent() ? removedExecution : removedExecution.getParent();

  if (flowScope.getActivityBehavior() != null && flowScope.getActivityBehavior() instanceof ModificationObserverBehavior) {
    // let child removal be handled by the scope itself
    ModificationObserverBehavior behavior = (ModificationObserverBehavior) flowScope.getActivityBehavior();
    behavior.destroyInnerInstance(executionInParentScope);
  }
  else {
    if (executionInParentScope.isConcurrent()) {
      executionInParentScope.remove();
      scopeExecution.tryPruneLastConcurrentChild();
      scopeExecution.forceUpdate();
    }
  }
}
 
Example 8
Source File: VariableListenerInvocationListener.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void addEventToScopeExecution(ExecutionEntity sourceScope, VariableEvent event) {

    // ignore events of variables that are not set in an execution
    ExecutionEntity sourceExecution = sourceScope;
    ExecutionEntity scopeExecution = sourceExecution.isScope() ? sourceExecution : sourceExecution.getParent();
    scopeExecution.delayEvent((ExecutionEntity) targetScope, event);

  }
 
Example 9
Source File: MigratingActivityInstance.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isDetached() {
  ExecutionEntity representativeExecution = resolveRepresentativeExecution();
  return representativeExecution != representativeExecution.getProcessInstance()
    && representativeExecution.getParent() == null;
}