コード例 #1
0
  public static void performTransition(
      ActivityInstanceBean activityInstance, TransitionTarget transitionTarget, boolean complete) {
    ExecutionPlan plan = new ExecutionPlan(transitionTarget);
    plan.assertNoOtherActiveActivities();

    ModelManager mm = ModelManagerFactory.getCurrent();
    IActivity target =
        mm.findActivity(transitionTarget.getModelOid(), transitionTarget.getActivityRuntimeOid());
    if (target == null) {
      throw new ObjectNotFoundException(
          BpmRuntimeError.MDL_UNKNOWN_ACTIVITY_IN_MODEL.raise(
              transitionTarget.getActivityRuntimeOid(), transitionTarget.getModelOid()));
    }

    BpmRuntimeEnvironment rtEnv = PropertyLayerProviderInterceptor.getCurrent();
    ExecutionPlan oldPlan = rtEnv.getExecutionPlan();
    try {
      rtEnv.setExecutionPlan(plan);
      if (complete) {
        ActivityInstanceUtils.complete(activityInstance, null, null, true);
      } else {
        long rootOid = plan.getRootActivityInstanceOid();
        if (rootOid != activityInstance.getOID()) {
          activityInstance = ActivityInstanceUtils.lock(rootOid);
        }
        ActivityInstanceUtils.abortActivityInstance(activityInstance);
      }
    } finally {
      rtEnv.setExecutionPlan(oldPlan);
    }
  }
コード例 #2
0
  public static List<TransitionTarget> getRelocateTargets(
      long activityInstanceOid, TransitionOptions options, ScanDirection direction) {
    IActivityInstance ai = ActivityInstanceBean.findByOID(activityInstanceOid);
    IActivity activity = ai.getActivity();

    if (!activity.getBooleanAttribute(PredefinedConstants.ACTIVITY_IS_RELOCATE_SOURCE_ATT)) {
      // activity is not a relocation source
      return Collections.emptyList();
    }

    Stack<TransitionStep> steps = new Stack();
    List<TransitionTarget> targets = CollectionUtils.newList();
    Set<TransitionTarget> visited = CollectionUtils.newSet();
    switch (direction) {
      case FORWARD:
        addActivities(
            visited,
            targets,
            ai,
            options == null ? TransitionOptions.DEFAULT : options,
            true,
            steps);
        break;
      case BACKWARD:
        addActivities(
            visited,
            targets,
            ai,
            options == null ? TransitionOptions.DEFAULT : options,
            false,
            steps);
        break;
      default:
        addActivities(
            visited,
            targets,
            ai,
            options == null ? TransitionOptions.DEFAULT : options,
            true,
            steps);
        addActivities(
            visited,
            targets,
            ai,
            options == null ? TransitionOptions.DEFAULT : options,
            false,
            steps);
    }
    return targets;
  }