Java Code Examples for org.camunda.bpm.engine.impl.pvm.process.ActivityImpl#isScope()

The following examples show how to use org.camunda.bpm.engine.impl.pvm.process.ActivityImpl#isScope() . 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: CompensationBehavior.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
/**
 * Determines whether an execution is responsible for default compensation handling.
 *
 * This is the case if
 * <ul>
 *   <li>the execution has an activity
 *   <li>the execution is a scope
 *   <li>the activity is a scope
 *   <li>the execution has children
 *   <li>the execution does not throw compensation
 * </ul>
 */
public static boolean executesDefaultCompensationHandler(PvmExecutionImpl scopeExecution) {
  ActivityImpl currentActivity = scopeExecution.getActivity();

  if (currentActivity != null) {
    return scopeExecution.isScope()
        && currentActivity.isScope()
        && !scopeExecution.getNonEventScopeExecutions().isEmpty()
        && !isCompensationThrowing(scopeExecution);
  }
  else {
    return false;
  }
}
 
Example 2
Source File: CaseCallActivityBehavior.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void onParseMigratingInstance(MigratingInstanceParseContext parseContext, MigratingActivityInstance migratingInstance) {
  ActivityImpl callActivity = (ActivityImpl) migratingInstance.getSourceScope();

  // A call activity is typically scope and since we guarantee stability of scope executions during migration,
  // the superExecution link does not have to be maintained during migration.
  // There are some exceptions, though: A multi-instance call activity is not scope and therefore
  // does not have a dedicated scope execution. In this case, the link to the super execution
  // must be maintained throughout migration
  if (!callActivity.isScope()) {
    ExecutionEntity callActivityExecution = migratingInstance.resolveRepresentativeExecution();
    CaseExecutionEntity calledCaseInstance = callActivityExecution.getSubCaseInstance();
    migratingInstance.addMigratingDependentInstance(new MigratingCalledCaseInstance(calledCaseInstance));
  }
}
 
Example 3
Source File: CallActivityBehavior.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void onParseMigratingInstance(MigratingInstanceParseContext parseContext, MigratingActivityInstance migratingInstance) {
  ActivityImpl callActivity = (ActivityImpl) migratingInstance.getSourceScope();

  // A call activity is typically scope and since we guarantee stability of scope executions during migration,
  // the superExecution link does not have to be maintained during migration.
  // There are some exceptions, though: A multi-instance call activity is not scope and therefore
  // does not have a dedicated scope execution. In this case, the link to the super execution
  // must be maintained throughout migration
  if (!callActivity.isScope()) {
    ExecutionEntity callActivityExecution = migratingInstance.resolveRepresentativeExecution();
    ExecutionEntity calledProcessInstance = callActivityExecution.getSubProcessInstance();
    migratingInstance.addMigratingDependentInstance(new MigratingCalledProcessInstance(calledProcessInstance));
  }
}
 
Example 4
Source File: SameEventScopeInstructionValidator.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected boolean isUserTaskWithTimeoutListener(ActivityImpl sourceActivity) {
  return ActivityTypes.TASK_USER_TASK.equals(sourceActivity.getProperties().get(BpmnProperties.TYPE)) &&
      sourceActivity.isScope() && sourceActivity.equals(sourceActivity.getEventScope()) &&
      sourceActivity.getProperties().get(BpmnProperties.TIMEOUT_LISTENER_DECLARATIONS) != null &&
      !sourceActivity.getProperties().get(BpmnProperties.TIMEOUT_LISTENER_DECLARATIONS).isEmpty();
}
 
Example 5
Source File: PvmAtomicOperationDeleteCascadeFireActivityEnd.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected boolean executesNonScopeActivity(PvmExecutionImpl execution) {
  ActivityImpl activity = execution.getActivity();
  return activity!=null && !activity.isScope();
}
 
Example 6
Source File: CompensationBehavior.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
/**
 * With compensation, we have a dedicated scope execution for every handler, even if the handler is not
 * a scope activity; this must be respected when invoking end listeners, etc.
 */
public static boolean executesNonScopeCompensationHandler(PvmExecutionImpl execution) {
  ActivityImpl activity = execution.getActivity();

  return execution.isScope() && activity != null && activity.isCompensationHandler() && !activity.isScope();
}
 
Example 7
Source File: CompensationEventHandler.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Override
public void handleEvent(EventSubscriptionEntity eventSubscription, Object payload, Object localPayload, String businessKey, CommandContext commandContext) {
  eventSubscription.delete();

  String configuration = eventSubscription.getConfiguration();
  ensureNotNull("Compensating execution not set for compensate event subscription with id " + eventSubscription.getId(), "configuration", configuration);

  ExecutionEntity compensatingExecution = commandContext.getExecutionManager().findExecutionById(configuration);

  ActivityImpl compensationHandler = eventSubscription.getActivity();

  // activate execution
  compensatingExecution.setActive(true);

  if (compensatingExecution.getActivity().getActivityBehavior() instanceof CompositeActivityBehavior) {
    compensatingExecution.getParent().setActivityInstanceId(compensatingExecution.getActivityInstanceId());
  }

  if (compensationHandler.isScope() && !compensationHandler.isCompensationHandler()) {
    // descend into scope:
    List<EventSubscriptionEntity> eventsForThisScope = compensatingExecution.getCompensateEventSubscriptions();
    CompensationUtil.throwCompensationEvent(eventsForThisScope, compensatingExecution, false);

  } else {
    try {


      if (compensationHandler.isSubProcessScope() && compensationHandler.isTriggeredByEvent()) {
        compensatingExecution.executeActivity(compensationHandler);
      }
      else {
        // since we already have a scope execution, we don't need to create another one
        // for a simple scoped compensation handler
        compensatingExecution.setActivity(compensationHandler);
        compensatingExecution.performOperation(PvmAtomicOperation.ACTIVITY_START);
      }


    } catch (Exception e) {
      throw new ProcessEngineException("Error while handling compensation event " + eventSubscription, e);
    }
  }
}