/**
   * 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;
  }