Class MediaCriteria
- java.lang.Object
-
- org.silverpeas.components.gallery.model.MediaCriteria
-
public class MediaCriteria extends Object
Class that permits to set media search criteria for media application.- Author:
- Yohann Chastagnier
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MediaCriteria.QUERY_ORDER_BY
static class
MediaCriteria.VISIBILITY
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MediaCriteria
albumIdentifierIsOneOf(String... albumIds)
Sets the list of media album identifiers criterion to find media which are attached to one of the given ones.MediaCriteria
createdBy(org.silverpeas.core.admin.user.model.UserDetail user)
Sets the creator criterion to find media created by the given user.static MediaCriteria
fromComponentInstanceId(String componentInstanceId)
Initializes media search criteria axed on the given media component instance id.static MediaCriteria
fromMediaId(String mediaId)
Initializes media search criteria axed on the given media identifier.static MediaCriteria
fromNbDaysBeforeThatMediaIsNotVisible(Integer nbDaysBeforeThatMediaIsNotVisible)
Initializes media search criteria axed on the given nb of days before that a media is not visible.String
getComponentInstanceId()
Gets the indetifier of media instance.Integer
getNbDaysBeforeThatMediaIsNotVisible()
Gets the criterion of the nb of days before that a media is not visible.int
getResultLimit()
Gets the maximum number of media in a result list.MediaCriteria
identifierIsOneOf(String... identifiers)
Sets the identifiers criterion to find the medias with an identifier equals to one of the specified ones.MediaCriteria
limitResultTo(int nbMedia)
Limit the number of results.MediaCriteria
mediaTypeIsOneOf(MediaType... mediaTypes)
Sets the list of media type criterion to find media which have their type equals to one of the given ones.MediaCriteria
onComponentInstanceId(String componentInstanceId)
Sets the criterion of the identifier of the component instance the media must be attached.MediaCriteria
orderedBy(MediaCriteria.QUERY_ORDER_BY... orderBies)
Configures the order of the media list.void
processWith(MediaCriteriaProcessor processor)
Processes this criteria with the specified processor.MediaCriteria
referenceDateOf(Date referenceDate)
Sets the reference date criterion (the date of the day by default).MediaCriteria
setRequester(org.silverpeas.core.admin.user.model.UserDetail requester)
Sets the requester.MediaCriteria
withVisibility(MediaCriteria.VISIBILITY visibility)
Sets the visibility criterion to find the medias according to their period of visibility.
-
-
-
Method Detail
-
fromComponentInstanceId
public static MediaCriteria fromComponentInstanceId(String componentInstanceId)
Initializes media search criteria axed on the given media component instance id.- Parameters:
componentInstanceId
- the identifier of the media instance.- Returns:
- an instance of media criteria based on the specified identifier of component instance.
-
fromMediaId
public static MediaCriteria fromMediaId(String mediaId)
Initializes media search criteria axed on the given media identifier.- Parameters:
mediaId
- the identifier of the media instance.- Returns:
- an instance of media criteria based on the specified identifier of media.
-
fromNbDaysBeforeThatMediaIsNotVisible
public static MediaCriteria fromNbDaysBeforeThatMediaIsNotVisible(Integer nbDaysBeforeThatMediaIsNotVisible)
Initializes media search criteria axed on the given nb of days before that a media is not visible.- Parameters:
nbDaysBeforeThatMediaIsNotVisible
- the nb of days before that a media is not visible.- Returns:
- an instance of media criteria with the nb of days before that a media is not visible criterion set.
-
onComponentInstanceId
public MediaCriteria onComponentInstanceId(String componentInstanceId)
Sets the criterion of the identifier of the component instance the media must be attached.- Parameters:
componentInstanceId
- the identifier of the component instance.- Returns:
- an instance of media criteria with the instance of component instance criterion set.
-
setRequester
public MediaCriteria setRequester(org.silverpeas.core.admin.user.model.UserDetail requester)
Sets the requester. If no requester is specified to criteria, thenUserDetail.getCurrentRequester()
is used.- Parameters:
requester
- the requester.- Returns:
- an instance of media criteria with the requester criterion filled.
-
createdBy
public MediaCriteria createdBy(org.silverpeas.core.admin.user.model.UserDetail user)
Sets the creator criterion to find media created by the given user.- Parameters:
user
- the user that must be the creator of the media(s).- Returns:
- the media criteria itself with the new criterion on the media creator.
-
albumIdentifierIsOneOf
public MediaCriteria albumIdentifierIsOneOf(String... albumIds)
Sets the list of media album identifiers criterion to find media which are attached to one of the given ones.- Parameters:
albumIds
- the media album identifier list that the media must be attached.- Returns:
- the media criteria itself with the new criterion on the media types.
-
mediaTypeIsOneOf
public MediaCriteria mediaTypeIsOneOf(MediaType... mediaTypes)
Sets the list of media type criterion to find media which have their type equals to one of the given ones.- Parameters:
mediaTypes
- the media type list that the media type must verify.- Returns:
- the media criteria itself with the new criterion on the media types.
-
orderedBy
public MediaCriteria orderedBy(MediaCriteria.QUERY_ORDER_BY... orderBies)
Configures the order of the media list.- Parameters:
orderBies
- the list of order by directives.- Returns:
- the media criteria itself with the list ordering criterion.
-
identifierIsOneOf
public MediaCriteria identifierIsOneOf(String... identifiers)
Sets the identifiers criterion to find the medias with an identifier equals to one of the specified ones.- Parameters:
identifiers
- a list of identifiers the medias to find should have.- Returns:
- the media criteria itself with the new criterion on the media identifiers.
-
withVisibility
public MediaCriteria withVisibility(MediaCriteria.VISIBILITY visibility)
Sets the visibility criterion to find the medias according to their period of visibility. If visibility isMediaCriteria.VISIBILITY.BY_DEFAULT
, then the requester is verified to get VISIBLE (all user roles) or VISIBLE + HIDDEN (lowest user role must be the publisher one).- Parameters:
visibility
- the visibility requested.- Returns:
- the media criteria itself with the new criterion on the media visibility.
-
referenceDateOf
public MediaCriteria referenceDateOf(Date referenceDate)
Sets the reference date criterion (the date of the day by default).- Parameters:
referenceDate
- the reference date specified.- Returns:
- the media criteria itself with the new criterion on the media reference date.
-
limitResultTo
public MediaCriteria limitResultTo(int nbMedia)
Limit the number of results.- Parameters:
nbMedia
- the maximum media in a result.- Returns:
- the media criteria itself with the result limit set.
-
getResultLimit
public int getResultLimit()
Gets the maximum number of media in a result list.- Returns:
- the result limit.
-
getComponentInstanceId
public String getComponentInstanceId()
Gets the indetifier of media instance.fromComponentInstanceId(String)
- Returns:
- the criterion on the media instance to which the medias should belong.
-
getNbDaysBeforeThatMediaIsNotVisible
public Integer getNbDaysBeforeThatMediaIsNotVisible()
Gets the criterion of the nb of days before that a media is not visible.- Returns:
- the nb of days before that a media is not visible.
-
processWith
public void processWith(MediaCriteriaProcessor processor)
Processes this criteria with the specified processor. It chains in a given order the different criterion to process.- Parameters:
processor
- the processor to use for processing each criterion in this criteria.
-
-