コード例 #1
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;
  }
コード例 #2
0
 private static void addActivities(
     Set<TransitionTarget> visited,
     List<TransitionTarget> targets,
     IActivityInstance ai,
     TransitionOptions options,
     boolean forward,
     Stack<TransitionStep> steps) {
   if (ai != null) {
     steps.push(TransitionTargetFactory.createTransitionStep(ai));
     // add activities from current process definition
     addActivities(visited, targets, ai.getActivity(), options, forward, steps);
     // step up into the calling process - starting activity cannot be a relocation target
     if (options.isTransitionOutOfSubprocessesAllowed()) {
       addActivities(
           visited,
           targets,
           ai.getProcessInstance().getStartingActivityInstance(),
           options,
           forward,
           steps);
     }
     steps.pop();
   }
 }