/**
   * Removes the relation (and its inverse in case of a bidirectional relation) from the database.
   *
   * @param relation the relation to be removed
   * @throws PortalException if the relation is bidirectional and its inverse relation could not be
   *     found
   * @throws SystemException if a system exception occurred
   */
  public void deleteRelation(SocialRelation relation) throws PortalException, SystemException {

    socialRelationPersistence.remove(relation);

    if (SocialRelationConstants.isTypeBi(relation.getType())) {
      SocialRelation biRelation =
          socialRelationPersistence.findByU1_U2_T(
              relation.getUserId2(), relation.getUserId1(), relation.getType());

      socialRelationPersistence.remove(biRelation);
    }
  }