Package org.silverpeas.components.community.model

## Class CommunityMembershipsProvider

- java.lang.Object
- - org.silverpeas.components.community.model.CommunityMembershipsProvider

-     public class CommunityMembershipsProvider
      extends Object

  A provider of memberships to a community of users. The provider is always related to a community of users for which it provides access to his table of memberships. All the memberships to a community of users are accessed only through such a provider with which memberships can be requested on only some subsets of them.
  Author:
    mmoquillon

- - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `Optional<CommunityMembership>` | `get​(String membershipId)` | Gets the membership to the community of users with the specified unique identifier.
    `Optional<CommunityMembership>` | `get​(org.silverpeas.core.admin.user.model.User user)` | Gets the membership of the specified user to the community of users.
    `org.silverpeas.core.util.SilverpeasList<CommunityMembership>` | `getHistory​(org.silverpeas.core.admin.PaginationPage page)` | Gets the history of memberships to the community of users that are within the specified pagination page.
    `org.silverpeas.core.util.SilverpeasList<CommunityMembership>` | `getInRange​(org.silverpeas.core.admin.PaginationPage page)` | Gets all the committed memberships to the community of users that are within the specified pagination page.
    `org.silverpeas.core.util.SilverpeasList<CommunityMembership>` | `getPending​(org.silverpeas.core.admin.PaginationPage page)` | Gets all pending memberships to the community of users.
    `boolean` | `isEmpty()` | Is the underlying community of users hasn't yet any memberships?

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### isEmpty

          public boolean isEmpty()

      Is the underlying community of users hasn't yet any memberships?
      Returns:
        true if no membership has been registered for the community of users. False otherwise.

    - #### get

          public Optional<CommunityMembership> get​(@Nonnull
                                                   String membershipId)

      Gets the membership to the community of users with the specified unique identifier.
      Parameters:
        `membershipId` - the unique identifier of a membership to the community of users.
      Returns:
        either a `CommunityMembership` instance representing the asked membership or nothing if no such membership to the community of users exists.

    - #### get

          public Optional<CommunityMembership> get​(@Nullable
                                                   org.silverpeas.core.admin.user.model.User user)

      Gets the membership of the specified user to the community of users. If the user isn't member of the community, then nothing is returned. Only the user whose membership is either pending or committed is returned.
      Parameters:
        `user` - a user in Silverpeas. If null, nothing is returned.
      Returns:
        either a `CommunityMembership` instance representing the membership of the user to the community or nothing if the user isn't (anymore) member of the community.

    - #### getPending

          public org.silverpeas.core.util.SilverpeasList<CommunityMembership> getPending​(@Nullable
                                                                                         org.silverpeas.core.admin.PaginationPage page)

      Gets all pending memberships to the community of users.
      Parameters:
        `page` - a page in the table of pending members defining a range of them to get. If null, all is got.
      Returns:
        a paginated list of pending members.

    - #### getInRange

          public org.silverpeas.core.util.SilverpeasList<CommunityMembership> getInRange​(@Nonnull
                                                                                         org.silverpeas.core.admin.PaginationPage page)

      Gets all the committed memberships to the community of users that are within the specified pagination page. Because the members of a community can be huge, only a range of their membership is allowed to be got.
      Parameters:
        `page` - a page in the table of memberships defining a range of them to get.
      Returns:
        a paginated list of actual memberships to the community.
      Implementation Note:
        a synchronization between the roles of the community space and the table of memberships is performed before getting the memberships.

    - #### getHistory

          public org.silverpeas.core.util.SilverpeasList<CommunityMembership> getHistory​(@Nonnull
                                                                                         org.silverpeas.core.admin.PaginationPage page)

      Gets the history of memberships to the community of users that are within the specified pagination page. All memberships are taken into account, whatever the status of membership.
      Parameters:
        `page` - a page in the table of memberships defining a range of them to get.
      Returns:
        a paginated list of memberships to the community of users, whatever the status of membership.
      Implementation Note:
        a synchronization between the roles of the community space and the table of memberships is performed before getting the history.