Class SuggestionCollection

  • All Implemented Interfaces:
    Iterable<Suggestion>, Collection<Suggestion>

    @Vetoed
    public class SuggestionCollection
    extends Object
    implements Collection<Suggestion>
    A collection of suggestions enriched with business methods on them. A collection of suggestions belongs always to a given suggestion box.
    Author:
    mmoquillon
    • Constructor Detail

      • SuggestionCollection

        protected SuggestionCollection​(SuggestionBox suggestionBox)
    • Method Detail

      • add

        public void add​(Suggestion suggestion,
                        Collection<org.silverpeas.core.io.upload.UploadedFile> uploadedFiles)
        Adds the specified suggestion among the other suggestions of the suggestion box.

        The suggestion will be persisted automatically once added.

        Parameters:
        suggestion - the suggestion to add.
        uploadedFiles - a collection of file to attach to the suggestion.
      • remove

        public boolean remove​(Object aSuggestion)
        Removes the specified suggestion from the suggestion box.

        If the suggestion doesn't exist in the suggestion box, then nothing is done.

        Specified by:
        remove in interface Collection<Suggestion>
        Parameters:
        aSuggestion - the suggestion to remove.
        Returns:
        true if the suggestion exists in this collection and then is removed.
      • get

        public Suggestion get​(String suggestionId)
        Gets the suggestion with the specified identifier from the suggestions of the suggestion box.
        Parameters:
        suggestionId - the unique identifier of the suggestion to get.
        Returns:
        the suggestion matching the specified identifier or NONE if no such suggestion exists in the suggestions of the suggestion box.
      • findInDraftFor

        public List<Suggestion> findInDraftFor​(org.silverpeas.core.admin.user.model.User user)
        Finds the list of suggestions that are in draft and which the creator is those specified.
        Parameters:
        user - the creator of the returned suggestions.
        Returns:
        the list of suggestions as described above and ordered by ascending last update date.
      • findOutOfDraftFor

        public List<Suggestion> findOutOfDraftFor​(org.silverpeas.core.admin.user.model.User user)
        Finds the list of suggestions that are out of draft and which the creator is those specified.
        Parameters:
        user - the creator of the returned suggestions.
        Returns:
        the list of suggestions as described above and ordered by ascending last update date.
      • findPublishedFor

        public List<Suggestion> findPublishedFor​(org.silverpeas.core.admin.user.model.User user)
        Finds the list of suggestions that are published and which the creator is those specified.
        Parameters:
        user - the creator of the returned suggestions.
        Returns:
        the list of suggestions as described above and ordered by ascending last update date.
      • findPendingValidation

        public List<Suggestion> findPendingValidation()
        Finds the list of suggestions that are pending validation.
        Returns:
        the list of suggestions as described above and ordered by ascending last update date.
      • findPublished

        public List<Suggestion> findPublished()
        Finds the list of suggestions that are published (validated status).
        Returns:
        the list of suggestions as described above and ordered by descending validation date.
      • publish

        public Suggestion publish​(Suggestion suggestion)
        Publishes from the specified suggestion box the specified suggestion.

        The publication of a suggestion consists in changing its status from DRAFT to PENDING_VALIDATION and sending a notification to the moderator if the updater is at most a writer on the suggestion box.

        If the suggestion doesn't exist in the suggestion box, then nothing is done.

        Parameters:
        suggestion - the suggestion to publish.
        Returns:
        the suggestion updated.
      • validate

        public Suggestion validate​(Suggestion suggestion,
                                   org.silverpeas.core.contribution.model.ContributionValidation validation)
        Validates the specified suggestion in the current suggestion box with the specified validation information.

        The publication of a suggestion consists in changing its status to VALIDATED or REFUSED and sending a notification to the creator in order to inform him about the validation result.

        If the suggestion doesn't exist in the suggestion box, then nothing is done.

        Parameters:
        suggestion - the suggestion to validate.
        validation - the validation information.
        Returns:
        the updated suggestion.
      • findInStatus

        public List<Suggestion> findInStatus​(org.silverpeas.core.contribution.ContributionStatus... statuses)
        Finds the list of suggestions that are in the specified statuses. The suggestions are ordered by their status and for each status by their modification date. This method is a convenient one to get suggestions of different statuses.
        Returns:
        a list of suggestions ordered by their status and by their modification date.
      • findAllProposedBy

        public List<Suggestion> findAllProposedBy​(org.silverpeas.core.admin.user.model.User author)
        Finds the list of all the suggestions that are proposed by the specified user. The suggestions are ordered by status and for each status by modification date.
        Parameters:
        author - the author of the asked suggestions.
        Returns:
        a list of suggestions ordered by status and by modification date. The list is empty if the user has not proposed any suggestions.
      • index

        public void index()
        Indexes all the published suggestions in this collection.