예제 #1
0
 /** @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 "?????";
   }
 }
예제 #2
0
 /** @TODO: author to add some doc. */
 public static Boolean isPortConnected(Port p1) {
   if (p1.getEnds().size() > 0) {
     Connector conn = (Connector) p1.getEnds().get(0).getOwner();
     return isConnectionValid(conn);
   } else {
     return false;
   }
 }
예제 #3
0
  public static Port getConnectedPort(Port port) {
    if (port.getEnds().size() == 0) {
      return null;
    }

    Connector conn = (Connector) port.getEnds().get(0).getOwner();
    ConnectorEnd e1 = conn.getEnds().get(0);
    ConnectorEnd e2 = conn.getEnds().get(1);
    return (e1.getRole() == port) ? (Port) e2.getRole() : (Port) e1.getRole();
  }
  private boolean portIsRelated(EObject toFilter, Port portContext) {

    if (portContext == toFilter) {
      return false;
    }

    if (toFilter instanceof Port) {
      final List<ConnectorEnd> ends = portContext.getEnds();
      for (final ConnectorEnd portEnd : ends) {
        final EObject eContainer = portEnd.eContainer();
        if (eContainer instanceof Connector) {
          final Connector connector = (Connector) eContainer;
          final EList<ConnectorEnd> connectorEnds = connector.getEnds();
          for (final ConnectorEnd connectorEnd : connectorEnds) {
            if (connectorEnd.getRole() != null && connectorEnd.getRole().equals(toFilter)) {
              return true;
            }
          }
        }
      }
    } else if (toFilter instanceof EncapsulatedClassifier) {
      final List<Port> ownedPortsToFilter = ((EncapsulatedClassifier) toFilter).getOwnedPorts();
      for (final Port portToFilter : ownedPortsToFilter) {
        if (portIsRelated(portToFilter, portContext)) {
          return true;
        }
      }
    }

    return false;
  }
예제 #5
0
  /**
   * Get external connectors to a port
   *
   * @param port
   * @return a list of connectors which are connected to the port.
   */
  public static List<org.eclipse.uml2.uml.Connector> getConnectionsFromPort(Port port) {
    LinkedList<org.eclipse.uml2.uml.Connector> connectors =
        new LinkedList<org.eclipse.uml2.uml.Connector>();

    for (ConnectorEnd connEnd : port.getEnds()) {
      Connector conn = (Connector) connEnd.getOwner();

      if (conn.getEnds().size() >= 2
          && conn.getEnds().get(0).getPartWithPort() != null
          && conn.getEnds().get(1).getPartWithPort() != null) {
        connectors.add(conn);
      }
    }

    return connectors;
  }