Class PublicationCriteria

    • Constructor Detail

      • PublicationCriteria

        public PublicationCriteria​(java.lang.Class<? extends Publication> clazz)
      • PublicationCriteria

        public PublicationCriteria​(java.lang.Class<? extends Publication> clazz,
                                   QueryHandler qh)
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • buildCriteria

        public org.hibernate.Criteria buildCriteria​(boolean count)
        Build an hibernate Criteria object from all settings specified in this PublicationCriteria.
        Parameters:
        count - true to build a Critera for an efficient counting query (i.e. without sorting), false to build a Criteria complying with all criterion (ie sort order is applied with proper order by clause)
        Returns:
        a new hibernate Criteria instance. Warning: may return null !
      • isTextSearch

        public boolean isTextSearch()
        Returns true if the text parameter has been setup.
        Returns:
        true if the text parameter has been setup.
        Since:
        jcms-6.0.0
      • getPubClass

        public java.lang.Class<? extends Publication> getPubClass()
      • getWorkspaceId

        public java.lang.String getWorkspaceId()
        Use instead getWorkspaceIdSet().
        Returns:
        the workspace id to refine on.
      • setWorkspaceIdSet

        public void setWorkspaceIdSet​(java.util.Collection<java.lang.String> wsIds)
        Parameters:
        wsIds - the set of workspace's ids to refine on.
        Since:
        jcms-7.1.3, jcms-8.0.0
      • getWorkspaceIdSet

        public java.util.Set<java.lang.String> getWorkspaceIdSet()
        Returns:
        the workspaceIdSet to refine on.
        Since:
        jcms-7.1.3, jcms-8.0.0
      • getAuthorId

        public java.lang.String getAuthorId()
        Retrieve the author id publication MUST match to be found. Return an id if and only if one author was specified.
        Returns:
        the Member id to use for author refinement, or null if none or several members were specified
      • setAuthorId

        public PublicationCriteria setAuthorId​(java.lang.String authorId)
        Set the author id publication MUST match to be found. Exclusive with setAuthorIds(String...) and setAuthor(Member)
        Parameters:
        authorId - the Member id the authors the publication must match to be found
        Returns:
        this PublicationCriteria instance, for method chaining
      • getAuthorIds

        public java.lang.String[] getAuthorIds()
        Retrieve the authors ids that publication MUST match to be found.
        Returns:
        an array of member's id.
        Since:
        jcms-9.0.3
      • setAuthorIds

        public PublicationCriteria setAuthorIds​(java.lang.String... mbrIds)
        Set the authors of publication to found. Exclusive with setAuthor(Member) and setAuthorId(String)
        Parameters:
        mbrIds - an array of Member's ids defining the authors the publication must match to be found
        Returns:
        this PublicationCriteria instance, for method chaining
        Since:
        jcms-9.0.3
      • setOpAuthorId

        public PublicationCriteria setOpAuthorId​(java.lang.String opAuthorId)
        Set the op author id publication MUST match to be found. Exclusive with setOpAuthorIds(String...) and setOpAuthor(Member)
        Parameters:
        opAuthorId - the Member id the op authors the publication must match to be found
        Returns:
        this PublicationCriteria instance, for method chaining
        Since:
        jcms-10.0.5 / JCMS-8387
      • setOpAuthor

        public PublicationCriteria setOpAuthor​(Member opAuthor)
        Set the op author of publication to found. Exclusive with setOpAuthorIds(String...) and setOpAuthorId(String)
        Parameters:
        opAuthor - the Member the op authors the publication must match to be found
        Returns:
        this PublicationCriteria instance, for method chaining
        Since:
        jcms-10.0.5 / JCMS-8387
      • getOpAuthorIds

        public java.lang.String[] getOpAuthorIds()
        Retrieve the op authors ids that publication MUST match to be found.
        Returns:
        an array of member's id.
        Since:
        jcms-10.0.5 / JCMS-8387
      • setOpAuthorIds

        public PublicationCriteria setOpAuthorIds​(java.lang.String... mbrIds)
        Set the op authors of publication to found. Exclusive with setOpAuthor(Member) and setOpAuthorId(String)
        Parameters:
        mbrIds - an array of Member's ids defining the op authors the publication must match to be found
        Returns:
        this PublicationCriteria instance, for method chaining
        Since:
        jcms-10.0.5 / JCMS-8387
      • getAuthorIdsOff

        public java.lang.String[] getAuthorIdsOff()
        Retrieve the authors ids that publication MUST NOT match to be found.
        Returns:
        an array of member's id.
        Since:
        jcms-9.0.3
      • setAuthorIdsOff

        public PublicationCriteria setAuthorIdsOff​(java.lang.String... mbrIds)
        Set the authors ids that publication MUST NOT match to be found.
        Parameters:
        mbrIds - an array of Member's ids defining the authors the publication must NOT match to be found
        Returns:
        this PublicationCriteria instance, for method chaining
        Since:
        jcms-9.0.3
      • setFilterOnMemberWorkspaces

        public void setFilterOnMemberWorkspaces​(boolean filterOnMemberWorkspaces)
      • setPstatusArray

        public PublicationCriteria setPstatusArray​(int... pstatusArray)
        Set the pstatus publication must match or not match to be found.

        Set setIncludePstatus(boolean) simultaneously to control how those values are being used.

        Examples :

        To find all publication in the published state :

         pubCriteria.setIncludePstatus(true);
         pubCriteria.setPstatusArray(WorkflowConstants.PUBLISHED_PSTATUS);
         
        To find all publication which are NOT expired :
         pubCriteria.setIncludePstatus(false);
         pubCriteria.setPstatusArray(WorkflowConstants.EXPIRED_PSTATUS);
         
        Parameters:
        pstatusArray - one or more workflow pstatus to use in the criterion
        Returns:
        this PublicationCriteria instance, for method chaining
        See Also:
        setIncludePstatus(boolean)
      • setIncludePstatus

        public PublicationCriteria setIncludePstatus​(boolean includePstatus)
        Set how pstatus specified in setPstatusArray(int...) must be used.

        Default value is true if a QueryHandler was specified on this PublicationCriteria (through constructor or setter), false otherwise.

        Parameters:
        includePstatus - true if value specified in getPstatusArray() are required ; publication will match only if their pstatus IS one of the specified value,
        false if values are excluded ; publication will match only if their pstatus IS NOT one of the specified value.
        Returns:
        this PublicationCriteria instance, for method chaining
        See Also:
        setPstatusArray(int...)
      • getText

        public java.lang.String getText()
        Retrieve text publication must contain to be found.
        Returns:
        any text to look for or null if no text search was specified
      • setText

        public PublicationCriteria setText​(java.lang.String text)
        Set the text to look for in publication.
        Parameters:
        text - a search string, as supported by lucene full text search.
        Returns:
        this PublicationCriteria instance, for method chaining
      • setDocumentKinds

        public PublicationCriteria setDocumentKinds​(java.lang.String... kinds)
        Set the kind of document to match. Setting this value will for a search en DBFileDocument (and subtypes), unless a DBFileDocument class is already being search for.
        Parameters:
        kinds - an array of document kind (e.g "pdf", "image", "spreadsheet", ...)
        Returns:
        this PublicationCriteria for chained invocation
        Since:
        jcms-9.0.3 JCMS-5305
      • getBeginDate

        public java.util.Date getBeginDate()
        Retrieve begin date to use during search.
        Returns:
        a date or null if no begin date was specified
        See Also:
        setBeginDate(Date), setDateType(String)
      • setBeginDate

        public PublicationCriteria setBeginDate​(java.util.Date beginDate)
        Set the date to use as lower value accepted for date search.

        Set setDateType(String) simultaneously to control which date field is being used.

        Parameters:
        beginDate - the date to use as lower bound
        Returns:
        this PublicationCriteria instance, for method chaining
        See Also:
        setDateType(String)
      • getEndDate

        public java.util.Date getEndDate()
        Retrieve end date to use during search.
        Returns:
        a date or null if no end date was specified
        See Also:
        setEndDate(Date), setDateType(String)
      • setEndDate

        public PublicationCriteria setEndDate​(java.util.Date endDate)
        Set the date to use as upper value accepted for date search.

        Set setDateType(String) simultaneously to control which date field is being used.

        Parameters:
        endDate - the date to use as upper bound
        Returns:
        this PublicationCriteria instance, for method chaining
        See Also:
        setDateType(String)
      • getDateType

        public java.lang.String getDateType()
        Retrieve the date field used for date filtering.
        Returns:
        a date field or null if no date type was specified
      • setDateType

        public PublicationCriteria setDateType​(java.lang.String dateType)
        Set the date field used for date filtering.

        "cdate" is the default value and fallback if an invalid type is specified.

        Accepted values are :

        • "cdate" : creation date
        • "mdate" : modification date
        • "pdate" : publication date
        • "edate" : expiration date
        • "adate" : archiving date
        Specific DB Publication types may support additional date types :
        • "udate" : last major modification date, for Historized type
        • "uploadDate" and "pdfUploadDate" for sub class of DBFileDocument
        Parameters:
        dateType - a date type from accepted values as described above.
        Returns:
        this PublicationCriteria instance, for method chaining
        See Also:
        setBeginDate(Date), setEndDate(Date)
      • setRowIdSet

        public PublicationCriteria setRowIdSet​(java.util.Set<java.lang.Long> rowIdSet)
      • setMember

        public void setMember​(Member member)
        Set the Member to use for read right control (aka logged member).
        Parameters:
        member - a Member (or null to reset to anonymous)
      • getMember

        public Member getMember()
        Retrieve the member being used for read right control (aka logged member).
        Returns:
        a Member or null if no author was requested.
      • checkReadRights

        public boolean checkReadRights()
        Indicates HOW read rights controls are being verified.
        • if true: controls are partially verified through SQL (to improve performance), the rest during iteration
        • if false: controls are entirely performed during iteration
        checkReadRights=false does NOT mean we do not verify read rights on return results.
        Returns:
        HOW read rights controls are being verified.
      • setCheckReadRights

        public void setCheckReadRights​(boolean checkReadRights)
        Set HOW read rights are performed (not if they are performed or not, because they always are).
        Parameters:
        checkReadRights - true to use SQL and iteration (if possible), false to use only iteration control
        See Also:
        checkReadRights()
      • getFirstResult

        public int getFirstResult()
      • getMaxResults

        public int getMaxResults()
      • getOrder

        public java.lang.String getOrder()
        Retrieve field name used for sorting.
        Returns:
        a field name or null if default sorting should be applied
      • setOrder

        public PublicationCriteria setOrder​(java.lang.String order)
        Set the field name to use for sorting.

        Set setAscendingOrder(boolean) simultaneously to control which arrangement should be used during ordering.

        Accepted values includes :

        • "mdate"
        • "cdate"
        • "pdate"
        • "edate"
        • "adate"
        • "title"
        • "pstatus"
        • "readerCount" (or "reader")
        • "voteCount"
        • "rowId" (or "id")
        But any valid field of the current publication type mapping can also be specified.
        Parameters:
        order - a field name
        Returns:
        this PublicationCriteria instance, for method chaining
      • isAscendingOrder

        public boolean isAscendingOrder()
        Checks ordering arrangement.
        Returns:
        true if ordering is ascending false if ordering is descending.
        See Also:
        setAscendingOrder(boolean)
      • setAscendingOrder

        public PublicationCriteria setAscendingOrder​(boolean ascendingOrder)
        Set the arrangement, ascending or descending, to used to use during ordering.
        Parameters:
        ascendingOrder - true to use ascending order, false to use descending order.
        Returns:
        this PublicationCriteria instance, for method chaining
        See Also:
        setOrder(String)
      • setCustomCriterion

        public PublicationCriteria setCustomCriterion​(org.hibernate.criterion.Criterion customCriterion)
        Set additionnal Hibernate criterion to use during query
        Parameters:
        customCriterion - an hibernate Criterion or null to reset value
        Returns:
        this PublicationCriteria instance, for method chaining
      • getMergeComparator

        public java.util.Comparator getMergeComparator()
        Returns the merge comparator used to sort hybrid search. If no comparator has been provided, it is deduced from getOrder() and isAscendingOrder().
        Returns:
        the merge comparator
        Since:
        jcms-7.0.0
      • setMergeComparator

        public PublicationCriteria setMergeComparator​(java.util.Comparator mergeComparator)
        Set the merge comparator to be used to sort hybrid search (and set the isHybridSearch flag)
        Parameters:
        mergeComparator - the merge comparator
        Returns:
        this PublicationCriteria for chained invocation
        Since:
        jcms-7.0.0
      • isHybridSearch

        public boolean isHybridSearch()
      • setHybridSearch

        public void setHybridSearch​(boolean isHybridSearch)
        Set whether this PublicationCriteria was used as part of an hybrid search (both JStore and JcmsDB) or JcmsDB only.
        Parameters:
        isHybridSearch - true for hybrid search, false for JcmsDB search only.
        See Also:
        setMergeComparator(Comparator)
      • isPolymorphicQuery

        public boolean isPolymorphicQuery()
      • isScrollRequired

        public boolean isScrollRequired()
      • queryCount

        public int queryCount()
      • isPartialCategoryRestriction

        public boolean isPartialCategoryRestriction()
        Returns true if the category restriction is partial.
        Returns:
        true if the category restriction is partial.
        Since:
        jcms-9.0.2
      • checkPublicationCategories

        public boolean checkPublicationCategories​(Publication pub)
        Returns true if the given publication matches the required categories (must be called if isPartialCategoryRestriction()).
        Parameters:
        pub - the publication
        Returns:
        true if the given publication matches the required categories (must be called if isPartialCategoryRestriction()).
        Since:
        jcms-9.0.2
      • getQueryFilterContext

        public java.util.Map<java.lang.String,​java.lang.Object> getQueryFilterContext()
      • clearQueryFilterContext

        protected void clearQueryFilterContext()
      • setSearchInAttachWS

        public PublicationCriteria setSearchInAttachWS​(boolean searchInAttachWS)
      • setSearchInTrash

        public PublicationCriteria setSearchInTrash​(boolean searchInTrash)
        Set wether to search trashed publication (true) or not (false).
        Parameters:
        searchInTrash - true to searched trashed publication, false to exclude them
        Returns:
        this PublicationCriteria instance, for method chaining
        Since:
        jcms-10.0.6 / JCMS-8934
      • getCriteriaAlias

        public java.lang.String getCriteriaAlias()
      • setCriteriaAlias

        public void setCriteriaAlias​(java.lang.String criteriaAlias)
        Add an alias on the Criteria
        Parameters:
        criteriaAlias - The name of the alias
      • setCatMode

        public void setCatMode​(java.lang.String catMode)
        Define the mode to use when dealing with categories.

        You can specify any of the following value:

        • "or": Union of categories
        • "and": Intersection of categories (default mode if empty or invalid)
        Parameters:
        catMode - "or" or "and"
        Since:
        jcms-10.0.5 / JCMS-8624
      • setExactCat

        public void setExactCat​(boolean exactMode)
        Set the filter mode to apply when searching in categories.
        • true to search publication directly categorized in the specified categories
        • false to search publication categorized in the specified in categories and in any of their children
        Default value is configured with property dbpub.search.category.exact.
        Parameters:
        exactMode - true to request exact mode, false to search in descendants
        Since:
        jcms-10.0.5 / JCMS-8624
      • setCategorySet

        public void setCategorySet​(java.util.Set<Category> catSet)
        Set the category to use for filtering
        Parameters:
        catSet - a Set of Category (may be null or empty to skip category filter)
        Since:
        jcms-10.0.5 / JCMS-8624