Class SuggestionCollection
java.lang.Object
org.silverpeas.components.suggestionbox.model.SuggestionCollection
- All Implemented Interfaces:
Iterable<Suggestion>,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 -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(Suggestion suggestion) voidadd(Suggestion suggestion, Collection<org.silverpeas.core.io.upload.UploadedFile> uploadedFiles) Adds the specified suggestion among the other suggestions of the suggestion box.booleanaddAll(Collection<? extends Suggestion> suggestions) voidclear()booleanbooleancontainsAll(Collection<?> suggestions) findAllProposedBy(org.silverpeas.core.admin.user.model.User author) Finds the list of all the suggestions that are proposed by the specified user.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.findInStatus(org.silverpeas.core.contribution.ContributionStatus... statuses) Finds the list of suggestions that are in the specified statuses.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.Finds the list of suggestions that are pending validation.Finds the list of suggestions that are published (validated status).findPublishedFor(org.silverpeas.core.admin.user.model.User user) Finds the list of suggestions that are published and which the creator is those specified.Gets the suggestion with the specified identifier from the suggestions of the suggestion box.voidindex()Indexes all the published suggestions in this collection.booleanisEmpty()iterator()publish(Suggestion suggestion) Publishes from the specified suggestion box the specified suggestion.booleanRemoves the specified suggestion from the suggestion box.booleanremoveAll(Collection<?> theSuggestions) booleanretainAll(Collection<?> c) intsize()Object[]toArray()<T> T[]toArray(T[] a) 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, waitMethods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
Constructor Details
-
SuggestionCollection
-
-
Method Details
-
size
public int size()- Specified by:
sizein interfaceCollection<Suggestion>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<Suggestion>
-
contains
- Specified by:
containsin interfaceCollection<Suggestion>
-
iterator
- Specified by:
iteratorin interfaceCollection<Suggestion>- Specified by:
iteratorin interfaceIterable<Suggestion>
-
toArray
- Specified by:
toArrayin interfaceCollection<Suggestion>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArrayin interfaceCollection<Suggestion>
-
add
- Specified by:
addin interfaceCollection<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
Removes the specified suggestion from the suggestion box.If the suggestion doesn't exist in the suggestion box, then nothing is done.
- Specified by:
removein interfaceCollection<Suggestion>- Parameters:
aSuggestion- the suggestion to remove.- Returns:
- true if the suggestion exists in this collection and then is removed.
-
containsAll
- Specified by:
containsAllin interfaceCollection<Suggestion>
-
addAll
- Specified by:
addAllin interfaceCollection<Suggestion>
-
removeAll
- Specified by:
removeAllin interfaceCollection<Suggestion>
-
retainAll
- Specified by:
retainAllin interfaceCollection<Suggestion>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<Suggestion>
-
get
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
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
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
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
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
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
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
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.
-