Package org.silverpeas.components.suggestionbox.model

# Class SuggestionCollection

java.lang.Object
org.silverpeas.components.suggestionbox.model.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 Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `SuggestionCollection(SuggestionBox suggestionBox)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `add(Suggestion suggestion)`
  `void`
  `add(Suggestion suggestion, Collection<org.silverpeas.core.io.upload.UploadedFile> uploadedFiles)`
  Adds the specified suggestion among the other suggestions of the suggestion box.
  `boolean`
  `addAll(Collection<? extends Suggestion> suggestions)`
  `void`
  `clear()`
  `boolean`
  `contains(Object suggestion)`
  `boolean`
  `containsAll(Collection<?> suggestions)`
  `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.
  `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.
  `List<Suggestion>`
  `findInStatus(org.silverpeas.core.contribution.ContributionStatus... statuses)`
  Finds the list of suggestions that are in the specified statuses.
  `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.
  `List<Suggestion>`
  `findPendingValidation()`
  Finds the list of suggestions that are pending validation.
  `List<Suggestion>`
  `findPublished()`
  Finds the list of suggestions that are published (validated status).
  `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.
  `Suggestion`
  `get(String suggestionId)`
  Gets the suggestion with the specified identifier from the suggestions of the suggestion box.
  `void`
  `index()`
  Indexes all the published suggestions in this collection.
  `boolean`
  `isEmpty()`
  `Iterator<Suggestion>`
  `iterator()`
  `Suggestion`
  `publish(Suggestion suggestion)`
  Publishes from the specified suggestion box the specified suggestion.
  `boolean`
  `remove(Object aSuggestion)`
  Removes the specified suggestion from the suggestion box.
  `boolean`
  `removeAll(Collection<?> theSuggestions)`
  `boolean`
  `retainAll(Collection<?> c)`
  `int`
  `size()`
  `Object[]`
  `toArray()`
  `<T> T[]`
  `toArray(T[] a)`
  `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.

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

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

  ### Methods inherited from interface java.util.Collection

  `equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray`

  ### Methods inherited from interface java.lang.Iterable

  `forEach`

- ## Constructor Details

  - ### SuggestionCollection

    protected SuggestionCollection(SuggestionBox suggestionBox)

- ## Method Details

  - ### size

    public int size()
    Specified by:
      `size` in interface `Collection<Suggestion>`

  - ### isEmpty

    public boolean isEmpty()
    Specified by:
      `isEmpty` in interface `Collection<Suggestion>`

  - ### contains

    public boolean contains(Object suggestion)
    Specified by:
      `contains` in interface `Collection<Suggestion>`

  - ### iterator

    public Iterator<Suggestion> iterator()
    Specified by:
      `iterator` in interface `Collection<Suggestion>`
    Specified by:
      `iterator` in interface `Iterable<Suggestion>`

  - ### toArray

    public Object[] toArray()
    Specified by:
      `toArray` in interface `Collection<Suggestion>`

  - ### toArray

    public <T> T[] toArray(T[] a)
    Specified by:
      `toArray` in interface `Collection<Suggestion>`

  - ### add

    public boolean add(Suggestion suggestion)
    Specified by:
      `add` in interface `Collection<Suggestion>`

  - ### 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.

  - ### containsAll

    public boolean containsAll(Collection<?> suggestions)
    Specified by:
      `containsAll` in interface `Collection<Suggestion>`

  - ### addAll

    public boolean addAll(Collection<? extends Suggestion> suggestions)
    Specified by:
      `addAll` in interface `Collection<Suggestion>`

  - ### removeAll

    public boolean removeAll(Collection<?> theSuggestions)
    Specified by:
      `removeAll` in interface `Collection<Suggestion>`

  - ### retainAll

    public boolean retainAll(Collection<?> c)
    Specified by:
      `retainAll` in interface `Collection<Suggestion>`

  - ### clear

    public void clear()
    Specified by:
      `clear` in interface `Collection<Suggestion>`

  - ### 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.