Java Code Examples for org.camunda.bpm.engine.impl.pvm.process.ScopeImpl#getActivityBehavior()

The following examples show how to use org.camunda.bpm.engine.impl.pvm.process.ScopeImpl#getActivityBehavior() . 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: LegacyBehavior.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
/**
 * Returns true if the given execution is in a compensation-throwing activity but there is no dedicated scope execution
 * in the given mapping.
 */
public static boolean isCompensationThrowing(PvmExecutionImpl execution, Map<ScopeImpl, PvmExecutionImpl> activityExecutionMapping) {
  if (CompensationBehavior.isCompensationThrowing(execution)) {
    ScopeImpl compensationThrowingActivity = execution.getActivity();

    if (compensationThrowingActivity.isScope()) {
      return activityExecutionMapping.get(compensationThrowingActivity) ==
          activityExecutionMapping.get(compensationThrowingActivity.getFlowScope());
    }
    else {
      // for transaction sub processes with cancel end events, the compensation throwing execution waits in the boundary event, not in the end
      // event; cancel boundary events are currently not scope
      return compensationThrowingActivity.getActivityBehavior() instanceof CancelBoundaryEventActivityBehavior;
    }
  }
  else {
    return false;
  }
}
 
Example 2
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 3
Source File: CannotAddMultiInstanceBodyValidator.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected boolean isMiBody(ScopeImpl scope) {
  return scope.getActivityBehavior() instanceof MultiInstanceActivityBehavior;
}
 
Example 4
Source File: CannotRemoveMultiInstanceInnerActivityValidator.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected boolean isMultiInstance(ScopeImpl flowScope) {
  return flowScope.getActivityBehavior() instanceof MultiInstanceActivityBehavior;
}
 
Example 5
Source File: CannotAddMultiInstanceInnerActivityValidator.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected boolean isMultiInstance(ScopeImpl scope) {
  return scope.getActivityBehavior() instanceof MultiInstanceActivityBehavior;
}
 
Example 6
Source File: ActivityInstanceHandler.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Override
public void handle(MigratingInstanceParseContext parseContext, ActivityInstance element) {
  MigratingActivityInstance migratingInstance = null;

  MigrationInstruction applyingInstruction = parseContext.getInstructionFor(element.getActivityId());
  ScopeImpl sourceScope = null;
  ScopeImpl targetScope = null;
  ExecutionEntity representativeExecution = parseContext.getMapping().getExecution(element);

  if (element.getId().equals(element.getProcessInstanceId())) {
    sourceScope = parseContext.getSourceProcessDefinition();
    targetScope = parseContext.getTargetProcessDefinition();
  }
  else {
    sourceScope = parseContext.getSourceProcessDefinition().findActivity(element.getActivityId());

    if (applyingInstruction != null) {
      String activityId = applyingInstruction.getTargetActivityId();
      targetScope = parseContext.getTargetProcessDefinition().findActivity(activityId);
    }
  }

  migratingInstance = parseContext.getMigratingProcessInstance()
      .addActivityInstance(
        applyingInstruction,
        element,
        sourceScope,
        targetScope,
        representativeExecution);

  MigratingActivityInstance parentInstance = parseContext.getMigratingActivityInstanceById(element.getParentActivityInstanceId());

  if (parentInstance != null) {
    migratingInstance.setParent(parentInstance);
  }

  CoreActivityBehavior<?> sourceActivityBehavior = sourceScope.getActivityBehavior();
  if (sourceActivityBehavior instanceof MigrationObserverBehavior) {
    ((MigrationObserverBehavior) sourceActivityBehavior).onParseMigratingInstance(parseContext, migratingInstance);
  }

  parseContext.submit(migratingInstance);

  parseTransitionInstances(parseContext, migratingInstance);

  parseDependentInstances(parseContext, migratingInstance);
}
 
Example 7
Source File: AbstractInstantiationCmd.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
/**
 * Cannot create more than inner instance in a sequential MI construct
 */
protected boolean supportsConcurrentChildInstantiation(ScopeImpl flowScope) {
  CoreActivityBehavior<?> behavior = flowScope.getActivityBehavior();
  return behavior == null || !(behavior instanceof SequentialMultiInstanceActivityBehavior);
}