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());
     
     
      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()); 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(); } } }