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

The following examples show how to use org.camunda.bpm.engine.impl.pvm.process.ActivityImpl#findCompensationHandler() . 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: CompensationInstanceHandler.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected MigratingProcessElementInstance createMigratingEventSubscriptionInstance(MigratingInstanceParseContext parseContext,
    EventSubscriptionEntity element) {
  ActivityImpl compensationHandler = parseContext.getSourceProcessDefinition().findActivity(element.getActivityId());

  MigrationInstruction migrationInstruction = getMigrationInstruction(parseContext, compensationHandler);

  ActivityImpl targetScope = null;
  if (migrationInstruction != null) {
    ActivityImpl targetEventScope = (ActivityImpl) parseContext.getTargetActivity(migrationInstruction).getEventScope();
    targetScope = targetEventScope.findCompensationHandler();
  }

  MigratingCompensationEventSubscriptionInstance migratingCompensationInstance =
      parseContext.getMigratingProcessInstance().addCompensationSubscriptionInstance(
          migrationInstruction,
          element,
          compensationHandler,
          targetScope);

  parseContext.consume(element);

  return migratingCompensationInstance;
}
 
Example 2
Source File: CompensationUtil.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
private static String getSubscriptionActivityId(ActivityExecution execution, String activityRef) {
  ActivityImpl activityToCompensate = ((ExecutionEntity) execution).getProcessDefinition().findActivity(activityRef);

  if (activityToCompensate.isMultiInstance()) {

    ActivityImpl flowScope = (ActivityImpl) activityToCompensate.getFlowScope();
    return flowScope.getActivityId();
  } else {

    ActivityImpl compensationHandler = activityToCompensate.findCompensationHandler();
    if (compensationHandler != null) {
      return compensationHandler.getActivityId();
    } else {
      // if activityRef = subprocess and subprocess has no compensation handler
      return activityRef;
    }
  }
}
 
Example 3
Source File: CompensationUtil.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
/**
 * In the context when an event scope execution is created (i.e. a scope such as a subprocess has completed),
 * this method returns the compensation handler activity that is going to be executed when by the event scope execution.
 *
 * This method is not relevant when the scope has a boundary compensation handler.
 */
protected static ActivityImpl getEventScopeCompensationHandler(ExecutionEntity execution) {
  ActivityImpl activity = execution.getActivity();

  ActivityImpl compensationHandler = activity.findCompensationHandler();
  if (compensationHandler != null && compensationHandler.isSubProcessScope()) {
    // subprocess with inner compensation event subprocess
    return compensationHandler;
  } else {
    // subprocess without compensation handler or
    // multi instance activity
    return activity;
  }
}
 
Example 4
Source File: CompensationInstanceHandler.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected MigratingProcessElementInstance createMigratingEventScopeInstance(MigratingInstanceParseContext parseContext,
    EventSubscriptionEntity element) {

  ActivityImpl compensatingActivity = parseContext.getSourceProcessDefinition().findActivity(element.getActivityId());

  MigrationInstruction migrationInstruction = getMigrationInstruction(parseContext, compensatingActivity);

  ActivityImpl eventSubscriptionTargetScope = null;

  if (migrationInstruction != null) {
    if (compensatingActivity.isCompensationHandler()) {
      ActivityImpl targetEventScope = (ActivityImpl) parseContext.getTargetActivity(migrationInstruction).getEventScope();
      eventSubscriptionTargetScope = targetEventScope.findCompensationHandler();
    }
    else {
      eventSubscriptionTargetScope = parseContext.getTargetActivity(migrationInstruction);
    }
  }

  ExecutionEntity eventScopeExecution = CompensationUtil.getCompensatingExecution(element);
  MigrationInstruction eventScopeInstruction = parseContext.findSingleMigrationInstruction(eventScopeExecution.getActivityId());
  ActivityImpl targetScope = parseContext.getTargetActivity(eventScopeInstruction);

  MigratingEventScopeInstance migratingCompensationInstance =
      parseContext.getMigratingProcessInstance().addEventScopeInstance(
        eventScopeInstruction,
        eventScopeExecution,
        eventScopeExecution.getActivity(),
        targetScope,
        migrationInstruction,
        element,
        compensatingActivity,
        eventSubscriptionTargetScope);

  parseContext.consume(element);
  parseContext.submit(migratingCompensationInstance);

  parseDependentEntities(parseContext, migratingCompensationInstance);

  return migratingCompensationInstance;
}
 
Example 5
Source File: CompensationUtil.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected static boolean hasCompensationEventSubprocess(ActivityImpl activity) {
  ActivityImpl compensationHandler = activity.findCompensationHandler();

  return compensationHandler != null && compensationHandler.isSubProcessScope() && compensationHandler.isTriggeredByEvent();
}