/*
  * Add 'global' noflow actions for a node.
  */
 private void addNoflow(Node node, Choice choice) {
   Action noflow = noflow(node);
   if (noflow != null) {
     if (noflow instanceof Choice) {
       choice.getActions().addAll(((Choice) noflow).getActions());
     } else {
       choice.getActions().add(noflow);
     }
   }
 }
  /*
   * (non-Javadoc)
   * @see org.ect.reo.NodeSwitch#caseRouteNode(org.ect.reo.Node)
   */
  @Override
  protected Process caseRouteNode(Node node) {

    // Create a choice.
    Choice choice = new Choice();

    for (SinkEnd sink : node.getSinkEnds()) {
      for (SourceEnd source : node.getSourceEnds()) {

        // Create a synchronization.
        Synchronization sync = new Synchronization();

        // Add active ends to the synchronization.
        sync.getActions().add(flow(sink));
        sync.getActions().add(flow(source));

        // No-flow actions:
        for (PrimitiveEnd inactive : node.getAllEnds()) {
          if (inactive == sink || inactive == source) continue;
          Action noflow = noflow(inactive);
          if (noflow != null) sync.getActions().add(noflow);
        }

        // Add the synchronization to the choice action.
        choice.getActions().add(sync);
      }
    }

    // Wrap the flow actions.
    choice = new Choice(wrapFlowAction(node, choice));

    // Additional noflow:
    addNoflow(node, choice);

    // Try to simplify the action a bit.
    Action action = (choice.getActions().size() == 1) ? choice.getActions().get(0) : choice;

    // Wrap and return the action.
    return wrapAction(node, action);
  }