@Override
  public Relationships getRelationships(Context ctx, PeopleId viewer, PeopleId... targets) {
    ParamChecker.notNull("ctx", ctx);
    ParamChecker.notNull("viewer", viewer);
    ParamChecker.notNull("targets", targets);

    Relationships rels = new Relationships();
    if (targets.length > 0) {
      for (PeopleId target : targets) rels.add(Relationship.disrelated(viewer, target));

      if (viewer.isUser()) {
        FriendEntries fes = getFriendEntries(ctx, viewer.getIdAsLong());
        if (fes != null) {
          for (PeopleId target : targets)
            rels.getRelation(viewer, target)
                .setTargetInViewerCircles(fes.getInCirclesByFriend(target));
        }
      }

      for (PeopleId target : targets) {
        if (!target.isUser()) break;

        FriendEntries fes = getFriendEntries(ctx, target.getIdAsLong());
        if (fes != null)
          rels.getRelation(viewer, target)
              .setViewerInTargetCircles(fes.getInCirclesByFriend(viewer));
      }
    }
    return rels;
  }
  private void initRelationshipMap() {
    Relationships relationships = getBundleDescriptor().getSingleRelationships();

    if (relationships != null) {
      EjbRelation[] rels = relationships.getEjbRelation();
      int i, count = ((rels != null) ? rels.length : 0);

      // cache relationship roles by ejb name
      for (i = 0; i < count; i++) {
        EjbRelation relationship = rels[i];

        addRole(relationship, relationship.getEjbRelationshipRole());
        addRole(relationship, relationship.getEjbRelationshipRole2());
      }
    }
  }