/** @TODO: author to add some doc. Middleware specific? */
 public static String getConnectionOtherSide(Port p1) {
   if (p1.getEnds().size() > 0) {
     Connector conn = (Connector) p1.getEnds().get(0).getOwner();
     ConnectorEnd e1 = conn.getEnds().get(0);
     ConnectorEnd e2 = conn.getEnds().get(1);
     Port p2 = null;
     java.lang.System.out.println("p1=" + p1.getName());
     Property c2 = null;
     if (e1.getRole() == p1) {
       p2 = (Port) e2.getRole();
       c2 = e2.getPartWithPort();
       java.lang.System.out.println("1 - p2=" + p2.getName() + ", c2=" + c2.getName());
     } else if (e2.getRole() == p1) {
       p2 = (Port) e1.getRole();
       c2 = e1.getPartWithPort();
       java.lang.System.out.println("2 - p2=" + p2.getName() + ", c2=" + c2.getName());
     }
     if (c2.getName().equals(((NamedElement) conn.getOwner()).getName())) {
       return "@" + p2.getName();
     } else {
       return "@" + c2.getName() + "." + p2.getName();
     }
   } else {
     return "?????";
   }
 }
 /**
  * @TODO: this seems to be middleware specific. To be moved to corresponding middleware generator
  * project.
  */
 public static String getConnectionDefinition(Connector connector) {
   ConnectorEnd e1 = connector.getEnds().get(0);
   ConnectorEnd e2 = connector.getEnds().get(1);
   return e1.getPartWithPort().getName()
       + "."
       + e1.getRole().getName()
       + ".connectTo("
       + e2.getPartWithPort().getName()
       + "."
       + e2.getRole().getName()
       + ")";
 }
  /**
   * Checks if is correct graphical view.
   *
   * @param connectorEnd a connector end
   * @param view a view
   * @return <code>true</code> if the view represents the role of the connector AND if the view is
   *     encapsulated as required by the nested path of the connector end
   */
  protected boolean isCorrectGraphicalView(final ConnectorEnd connectorEnd, final View view) {
    final NestedConnectorEnd nestedConnectorEnd =
        org.eclipse.uml2.uml.util.UMLUtil.getStereotypeApplication(
            connectorEnd, NestedConnectorEnd.class);
    final Property partWithPort = connectorEnd.getPartWithPort();
    // final ConnectableElement role = end.getRole();
    // 1. we get the top view of this view with the same semantic element
    View localView = getTopViewWithSameSemanticElement(view);

    // 2. we verify the part with port
    if (partWithPort != null) {
      View parent = getTopViewWithSameSemanticElement(ViewUtil.getViewContainer(localView));
      if (parent.getElement() != partWithPort) {
        return false;
      }
    }

    // 3. we verify the nested path
    if (nestedConnectorEnd != null && nestedConnectorEnd.getPropertyPath().size() > 0) {
      View parent = view;
      final List<Property> paths = nestedConnectorEnd.getPropertyPath();
      for (int i = paths.size() - 1; i >= 0; i--) {
        final Property currentProperty = paths.get(i);
        parent = getTopViewWithSameSemanticElement(ViewUtil.getViewContainer(parent));
        if (parent.getElement() != currentProperty) {
          return false;
        }
      }
    }
    return true;
  }
 /** @TODO: author to add some doc */
 public static Boolean isConnectionValid(Connector connector) {
   if (connector.getEnds().size() != 2) {
     return false;
   }
   for (ConnectorEnd cend : connector.getEnds()) {
     if ((cend.getRole() == null) || (cend.getPartWithPort() == null)) {
       return false;
     }
   }
   return true;
 }
 /**
  * Checks whether or not a port is a "destination port" from the point of view of a given
  * connector. A destination port can be an input port for a connector stepping out of a component
  * or it can be an output port for a connector linking a component model output port to a
  * component output port inside the component model (e.g. from a component inside the model to the
  * model boundaries).
  */
 private static boolean isDestPort(ConnectorEnd end, Port p) {
   return ((isAnOutputPort(p) && end.getPartWithPort() == null)
       || (isAnInputPort(p) && end.getPartWithPort() != null));
 }