<?xml version="1.0" encoding="UTF-8"?>
<component name="org.nuxeo.ecm.collections.pageprovider">

  <extension target="org.nuxeo.ecm.platform.query.api.PageProviderService"
    point="providers">

    <coreQueryPageProvider name="default_collection">
      <property name="maxResults">PAGE_SIZE</property>
      <pattern quoteParameters="false" escapeParameters="true">
        SELECT * FROM Document WHERE /*+ES: INDEX(dc:title.fulltext) OPERATOR(match_phrase_prefix) */
        dc:title ILIKE '?%' AND ecm:mixinType = 'Collection' AND ecm:primaryType != 'Favorites' AND
        ecm:isProxy = 0 AND ecm:mixinType != 'HiddenInNavigation' AND
        ecm:isVersion = 0 AND ecm:isTrashed = 0
      </pattern>
      <sort column="dc:title" ascending="true" />
      <pageSize>50</pageSize>
    </coreQueryPageProvider>

    <coreQueryPageProvider name="user_collections">
      <pattern quoteParameters="true" escapeParameters="true">
        SELECT * FROM Document WHERE /*+ES: INDEX(dc:title.fulltext) OPERATOR(match_phrase_prefix) */
        dc:title ILIKE :searchTerm AND ecm:mixinType = 'Collection' AND
        ecm:primaryType != 'Favorites' AND
        ecm:isProxy = 0 AND ecm:mixinType != 'HiddenInNavigation' AND
        ecm:isVersion = 0 AND ecm:isTrashed = 0
      </pattern>
      <parameter>#{currentUser.name}</parameter>
      <sort column="dc:modified" ascending="false" />
      <pageSize>50</pageSize>
    </coreQueryPageProvider>

    <coreQueryPageProvider name="default_collection_candidate">
      <property name="maxResults">PAGE_SIZE</property>
      <pattern quoteParameters="false" escapeParameters="true">
        SELECT * FROM Document WHERE /*+ES: INDEX(dc:title.fulltext) OPERATOR(match_phrase_prefix) */ dc:title ILIKE '?%'
        AND ecm:mixinType != 'SystemDocument' AND ecm:mixinType !=
        'NotCollectionMember' AND ecm:mixinType != 'HiddenInNavigation' AND
        ecm:isTrashed = 0
      </pattern>
      <sort column="dc:title" ascending="true" />
      <pageSize>50</pageSize>
    </coreQueryPageProvider>

    <coreQueryPageProvider name="default_content_collection">
      <pattern>
        SELECT * FROM Document where ecm:mixinType != 'HiddenInNavigation' AND
        ecm:isTrashed = 0
        AND collectionMember:collectionIds/* = ?
      </pattern>
      <sort column="dc:title" ascending="true" />
      <pageSize>50</pageSize>
    </coreQueryPageProvider>

    <coreQueryPageProvider name="ordered_content_collection">
      <pattern>
        SELECT collection:documentIds/* FROM Document where ecm:mixinType != 'HiddenInNavigation' AND
        ecm:isVersion = 0 AND ecm:isTrashed = 0
        AND ecm:uuid = ?
      </pattern>
      <pageSize>50</pageSize>
    </coreQueryPageProvider>

    <coreQueryPageProvider name="all_collections">
      <property name="maxResults">PAGE_SIZE</property>
      <pattern>
        SELECT * FROM Document WHERE ecm:mixinType = 'Collection' AND
        ecm:isProxy = 0 AND ecm:mixinType != 'HiddenInNavigation' AND
        ecm:isVersion = 0 AND ecm:isTrashed = 0
      </pattern>
      <pageSize>1000</pageSize>
    </coreQueryPageProvider>

  </extension>

</component>
