// TODO: can this be implemented in a simpler way?  is there
  // any real value to using the map here as opposed to iterating
  // the relationships live?
  private EjbRelationshipRole getRoleDescriptor(
      String ejbName, String cmrFieldName, boolean opposite) {
    Map rels = (HashMap) relationshipRoleMap.get(ejbName);
    Iterator iterator = rels.keySet().iterator();

    while (iterator.hasNext()) {
      EjbRelation rel = (EjbRelation) iterator.next();
      EjbRelationshipRole role = (EjbRelationshipRole) rels.get(rel);
      EjbRelationshipRole role1 = rel.getEjbRelationshipRole();
      EjbRelationshipRole role2 = rel.getEjbRelationshipRole2();
      CmrField candidateCmr = role.getCmrField();

      if (ejbName.equals(role.getRelationshipRoleSource().getEjbName())
          && (candidateCmr != null)
          && cmrFieldName.equals(candidateCmr.getCmrFieldName())) {
        return ((opposite) ? ((role == role1) ? role2 : role1) : role);
      } else { // check for self ref relationship
        String ejb1 = role1.getRelationshipRoleSource().getEjbName();

        if (ejb1.equals(role2.getRelationshipRoleSource().getEjbName()) && ejbName.equals(ejb1)) {
          role = ((role == role1) ? role2 : role1);
          candidateCmr = role.getCmrField();

          if ((candidateCmr != null) && cmrFieldName.equals(candidateCmr.getCmrFieldName())) {
            return ((opposite) ? ((role == role1) ? role2 : role1) : role);
          }
        }
      }
    }
    throw new IllegalArgumentException();
  }
  // TODO: is caching okay?  is synchronization needed?
  private void addRole(EjbRelation relationship, EjbRelationshipRole testRole) {
    String ejbName = testRole.getRelationshipRoleSource().getEjbName();
    Map rels = (HashMap) relationshipRoleMap.get(ejbName);

    if (rels == null) {
      rels = new HashMap();
      relationshipRoleMap.put(ejbName, rels);
    }

    rels.put(relationship, testRole);
  }
  public String getRelationshipFieldContent(String ejbName, String fieldName) {
    EjbRelationshipRole oppRole = getOppositeRoleDescriptor(ejbName, fieldName);

    return oppRole.getRelationshipRoleSource().getEjbName();
  }