/**
   * Removes transitions to or from a missing activity, probably due to the activity not being imported.
   */
private void removeDanglingTransitions(AbstractWorkflow workflow) {
    if (workflow.getTransitions() == null || workflow.getTransitions().isEmpty()) {
      return;
    }
    Set<String> activityIds = new HashSet<>();
    for (Activity activity : workflow.getActivities()) {
      activityIds.add(activity.getId());
      // Transitions from Boundary event timers should be included as well
      // todo: make generic
      List<Timer> activityTimers = activity.getTimers();
      if (activityTimers != null) {
        for (Timer timer : activityTimers) {
          if (timer instanceof BoundaryEventTimer) {
            BoundaryEvent boundaryEvent = ((BoundaryEventTimer) timer).boundaryEvent;
            activityIds.add(boundaryEvent.getBoundaryId());
            activityIds.addAll(boundaryEvent.getToTransitionIds());
          }
        }
      }
    }
    ListIterator<Transition> transitionIterator = workflow.getTransitions().listIterator();
    while(transitionIterator.hasNext()){
      Transition transition = transitionIterator.next();
      if (!activityIds.contains(transition.getFromId()) || !activityIds.contains(transition.getToId())) {
        transitionIterator.remove();
      }
    }
  }
private void removeDanglingTransitions(AbstractWorkflow workflow) {
if (workflow.getTransitions() == null || workflow.getTransitions().isEmpty()) {
return;
}
Set<String> activityIds = new HashSet<>();
for (Activity activity : workflow.getActivities()) {
activityIds.add(activity.getId());
// Transitions from Boundary event timers should be included as well
// todo: make generic
List<Timer> activityTimers = activity.getTimers();
if (activityTimers != null) {
for (Timer timer : activityTimers) {
if (timer instanceof BoundaryEventTimer) {
BoundaryEvent boundaryEvent = ((BoundaryEventTimer) timer).boundaryEvent;
activityIds.add(boundaryEvent.getBoundaryId());
activityIds.addAll(boundaryEvent.getToTransitionIds());
}
}
}
}
ListIterator<Transition> transitionIterator = workflow.getTransitions().listIterator();
while(transitionIterator.hasNext()){
Transition transition = transitionIterator.next();
if (!activityIds.contains(transition.getFromId()) || !activityIds.contains(transition.getToId())) {
transitionIterator.remove();
}
}
}
private void removeDanglingTransitions(AbstractWorkflow workflow) {
if (workflow.getTransitions() == null || workflow.getTransitions().isEmpty()) {
return;
}
Set<String> activityIds = new HashSet<>();
for (Activity activity : workflow.getActivities()) {
activityIds.add(activity.getId());
// Transitions from Boundary event timers should be included as well
// todo: make generic
List<Timer> activityTimers = activity.getTimers();
if (activityTimers != null) {
for (Timer timer : activityTimers) {
if (timer instanceof BoundaryEventTimer) {
BoundaryEvent boundaryEvent = ((BoundaryEventTimer) timer).boundaryEvent;
activityIds.add(boundaryEvent.getBoundaryId());
activityIds.addAll(boundaryEvent.getToTransitionIds());
}
}
}
}
ListIterator<Transition> transitionIterator = workflow.getTransitions().listIterator();
while(transitionIterator.hasNext()){
Transition transition = transitionIterator.next();
if (!activityIds.contains(transition.getFromId()) || !activityIds.contains(transition.getToId())) {
transitionIterator.remove();
}
}
}
private void removeDanglingTransitions(AbstractWorkflow workflow) {
if (workflow.getTransitions() == null || workflow.getTransitions().isEmpty()) {
return;
}
Set<String> activityIds = new HashSet<>();
for (Activity activity : workflow.getActivities()) {
activityIds.add(activity.getId());
// Transitions from Boundary event timers should be included as well
// todo: make generic
List<Timer> activityTimers = activity.getTimers();
if (activityTimers != null) {
for (Timer timer : activityTimers) {
if (timer instanceof BoundaryEventTimer) {
BoundaryEvent boundaryEvent = ((BoundaryEventTimer) timer).boundaryEvent;
activityIds.add(boundaryEvent.getBoundaryId());
activityIds.addAll(boundaryEvent.getToTransitionIds());
}
}
}
}
ListIterator<Transition> transitionIterator = workflow.getTransitions().listIterator();
while(transitionIterator.hasNext()){
Transition transition = transitionIterator.next();
if (!activityIds.contains(transition.getFromId()) || !activityIds.contains(transition.getToId())) {
transitionIterator.remove();
}
}
}