/**
  * Searches the software component for the specified repID.
  *
  * @param repID the repID to search for
  * @param removePorts the {@link Uses} or {@link Provides} ports being removed, these are
  *     disregarded
  * @param repIds the {@link Set} of repIds belonging to the {@link
  *     mil.jpeojtrs.sca.scd.SoftwareComponent}
  * @return <code> true </code> if the repID is found; <code> false </code> otherwise
  */
 private boolean containsRepId(final String repID, final Collection<EObject> removePorts) {
   // If it's a supported interface, return true;
   if (getSupportsInterfaceIds().contains(repID)) {
     return true;
   } else {
     // Go through the ports and try to match
     for (final FeatureMap.Entry entry : getPorts().getGroup()) {
       if (!(entry.getValue() instanceof AbstractPort)) {
         continue; // unexpected
       }
       final AbstractPort port = (AbstractPort) entry.getValue();
       // Ignore ports being removed
       if (!removePorts.contains(port) && !removePorts.contains(port.getSibling())) {
         if (port instanceof Provides) {
           if (!repID.equals(((Provides) port).getRepID())) {
             for (final InheritsInterface inherits :
                 ((Provides) port).getInterface().getInheritsInterfaces()) {
               if (repID.equals(inherits.getRepid())) {
                 return true;
               }
             }
           } else {
             return true;
           }
         } else { // Uses
           if (!repID.equals(((Uses) port).getRepID())) {
             for (final InheritsInterface inherits :
                 ((Uses) port).getInterface().getInheritsInterfaces()) {
               if (repID.equals(inherits.getRepid())) {
                 return true;
               }
             }
           } else {
             return true;
           }
         }
       }
     }
   }
   return false;
 }
  /**
   * Creates and returns a command to remove the specified ports.
   *
   * @param ports the ports to remove from the {@link mil.jpeojtrs.sca.scd.SoftwareComponent}
   * @param ignoreIds ignore the specified repIds when considering which interfaces to remove
   * @return the {@link Command} to remove the port and all associated {@link Interface}
   */
  public Command createRemovePortCommand(
      final Collection<Object> ports, final Set<String> ignoreIds) {
    final Set<String> repIds = new HashSet<String>();
    final List<EObject> removePorts = new ArrayList<EObject>();
    final CompoundCommand command = new CompoundCommand("Remove Ports");
    for (final Object obj : ports) {
      final EObject port = (EObject) AdapterFactoryEditingDomain.unwrap(obj);
      if (port instanceof AbstractPort) {
        for (AbstractPort p : getPorts().getAllPorts()) {
          if (p.equals(port)) {
            final AbstractPort sibling = p.getSibling();
            if (sibling == null || !(p instanceof Uses)) {
              repIds.add(p.getRepID());
              command.append(
                  RemoveCommand.create(this.editingDomain, getPorts(), p.eContainingFeature(), p));
              if (sibling != null) {
                command.append(
                    RemoveCommand.create(
                        this.editingDomain, getPorts(), sibling.eContainingFeature(), sibling));
              }
              removePorts.add(p);
            }
          }
        }
      }
    }

    for (final String repId : repIds) {
      if (this.interfaceMap.containsKey(repId) && !ignoreIds.contains(repId)) {
        final Command interfaceCommand =
            this.createRemoveInterfaceCommand(removePorts, ignoreIds, this.interfaceMap.get(repId));
        if (interfaceCommand != null) {
          command.append(interfaceCommand);
          this.interfaceMap.remove(repId);
        }
      }
    }
    return command;
  }