Class PublicationCriteria

java.lang.Object
com.jalios.jcms.db.PublicationCriteria
All Implemented Interfaces:
DBConstants, JaliosConstants

public class PublicationCriteria extends Object implements JaliosConstants, DBConstants
This class contains criteria for a DB publication query.
Since:
jcms-6.0.0
Author:
Olivier Dedieu
  • Constructor Details

  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class 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 Class<? extends Publication> getPubClass()
    • setPubClass

      public PublicationCriteria setPubClass(Class<? extends Publication> clazz)
    • getQueryHandler

      public QueryHandler getQueryHandler()
    • setQueryHandler

      public PublicationCriteria setQueryHandler(QueryHandler qh)
    • getWorkspaceId

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

      public PublicationCriteria setWorkspaceId(String workspaceId)
      Parameters:
      workspaceId - the workspace id to refine on.
      Returns:
      the publication criteria.
    • setWorkspace

      public PublicationCriteria setWorkspace(Workspace workspace)
      Parameters:
      workspace - the workspace to refine on.
      Returns:
      the publication criteria.
    • setWorkspaceIdSet

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

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

      public 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(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
    • setAuthor

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

      public 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(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(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 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(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 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(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)
    • getPstatusArray

      public int[] getPstatusArray()
      Retrieve the pstatus publication must match or not match to be found.
      Returns:
      an array of pstatus to use during publication query
      See Also:
    • 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:
    • isIncludePstatus

      public boolean isIncludePstatus()
      Retrieve boolean indicating how pstatus specified in setPstatusArray(int...) must be used.
      Returns:
      true if value specified in getPstatusArray() are required, false if values are excluded.
      See Also:
    • 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:
    • getText

      public 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(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(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 Date getBeginDate()
      Retrieve begin date to use during search.
      Returns:
      a date or null if no begin date was specified
      See Also:
    • setBeginDate

      public PublicationCriteria setBeginDate(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:
    • getEndDate

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

      public PublicationCriteria setEndDate(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:
    • getDateType

      public 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(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:
    • setRowIdSet

      public PublicationCriteria setRowIdSet(Set<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:
    • getFirstResult

      public int getFirstResult()
    • setFirstResult

      public PublicationCriteria setFirstResult(int firstResult)
    • getMaxResults

      public int getMaxResults()
    • setMaxResults

      public PublicationCriteria setMaxResults(int maxResults)
    • getOrder

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

      public PublicationCriteria setOrder(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

      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:
    • 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 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(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:
    • 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 Map<String,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 String getCriteriaAlias()
    • setCriteriaAlias

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

      public void setCatMode(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(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