Class PortalQueryParameters


  • public final class PortalQueryParameters
    extends Object
    Contains query parameters suitable for finding content or groups contained in a portal. Setter methods are provided for a number of particular parameters: 'sort order', 'sort field', 'start index', 'results limit', and 'bounding box'. There are also a number of setters that set a 'query string' that can be a complex expression that contains names and values of one or more fields, for example "owner:username AND title:mygroupname". When the query string is set, any previous value is overwritten.

    Start index and results limit are used when paging through large result sets. See PortalQueryResultSet.

    A typical usage pattern is:

    1. Create a new PortalQueryParameters object.
    2. Optionally call one or more of the setter methods.
    3. Use the object by passing it to Portal.findItemsAsync(PortalQueryParameters) or Portal.findGroupsAsync(PortalQueryParameters).
    4. Optionally call PortalQueryResultSet.getNextQueryParameters() to get a new PortalQueryParameters object that can be used to 'find' the next batch of results.
    Since:
    100.0.0
    • Constructor Detail

      • PortalQueryParameters

        public PortalQueryParameters()
        Creates a PortalQueryParameters with default settings. Start index will be 1, results limit will be 10, sort order will be ascending, and bounding box will be null. The query string will be null until one is set. If no query string is set, the PortalQueryParameters can be used to perform a generic search to find everything that is accessible to the current user.
        Since:
        100.0.0
      • PortalQueryParameters

        public PortalQueryParameters​(String query)
        Creates a PortalQueryParameters with a particular query string. This is the same as PortalQueryParameters(), with the addition of the query string being set.
        Parameters:
        query - the query string to use. The format is such as "owner:username AND title:mygroupname".
        Since:
        100.0.0
      • PortalQueryParameters

        public PortalQueryParameters​(Envelope boundingBox)
        Creates a PortalQueryParameters with a particular bounding box. This is the same as PortalQueryParameters(), with the addition of the bounding box being set.
        Parameters:
        boundingBox - an Envelope specifying the bounding box
        Throws:
        IllegalArgumentException - if boundingBox has no SpatialReference
        Since:
        100.2.0
        See Also:
        setBoundingBox(Envelope)
      • PortalQueryParameters

        public PortalQueryParameters​(String query,
                                     Envelope boundingBox)
        Creates a PortalQueryParameters with a particular query string and bounding box. This is the same as PortalQueryParameters(), with the addition of the query string and bounding box being set.
        Parameters:
        query - the query string to use. The format is such as "owner:username AND title:mygroupname".
        boundingBox - an Envelope specifying the bounding box
        Throws:
        IllegalArgumentException - if boundingBox has no SpatialReference
        Since:
        100.2.0
        See Also:
        setBoundingBox(Envelope)
      • PortalQueryParameters

        public PortalQueryParameters​(String query,
                                     int limit)
        Creates a PortalQueryParameters with a particular query string and results limit. This is the same as PortalQueryParameters(), with the addition of the query string and results limit being set.
        Parameters:
        query - the query string to use. The format is such as "owner:username AND title:mygroupname".
        limit - maximum number of results to be included in the result set response. Used when paging through large result sets.
        Since:
        100.0.0
        See Also:
        getLimit(), PortalQueryResultSet
    • Method Detail

      • withNextStart

        public PortalQueryParameters withNextStart​(int nextStart)
        Returns a new copy of the PortalQueryParameters with the start index field being set to the nextStart parameter. Start index is used when paging through large result sets.
        Parameters:
        nextStart - the next start index
        Returns:
        a copy of this PortalQueryParameters with the start index field being set to the nextStart parameter, or null if nextStart is negative
        Since:
        100.0.0
        See Also:
        getStartIndex(), PortalQueryResultSet
      • setQueryForItemsInGroup

        public PortalQueryParameters setQueryForItemsInGroup​(String groupId)
        Sets the query string to find items in a specified group.
        Parameters:
        groupId - ID of the group for which items are required
        Returns:
        this PortalQueryParameters
        Throws:
        IllegalArgumentException - if groupId is null or empty
        Since:
        100.0.0
      • setQueryForItemsWithOwner

        public PortalQueryParameters setQueryForItemsWithOwner​(String owner,
                                                               PortalItem.Type type,
                                                               String searchQuery)
        Sets the query string to find items with a specified owner.
        Parameters:
        owner - username of the owner of the items to search for
        type - item type to search for, or null to search for items of any type
        searchQuery - search string to use; null or empty for no search string
        Returns:
        this PortalQueryParams
        Throws:
        IllegalArgumentException - if owner is null or empty
        Since:
        100.3.0
      • setQueryForGroups

        public PortalQueryParameters setQueryForGroups​(String owner,
                                                       String title)
        Sets the query string to find groups with a specified owner and title.

        Either owner or title may be null, and the query string will only be set for the non-null parameter. If both are set, the query string will search for groups that are owned by the named user AND that match the specified title.

        Parameters:
        owner - username of the owner of the groups to search for; null or empty to search for groups with any owner
        title - the title of the groups to search for; null or empty to search for groups with any title
        Returns:
        this PortalQueryParameters
        Throws:
        IllegalArgumentException - if owner and title are both null or empty
        Since:
        100.0.0
      • setQuery

        public PortalQueryParameters setQuery​(PortalItem.Type type,
                                              String groupId,
                                              String searchQuery)
        Sets the query string to find items of a given type that are in a specific group with a specific search string.

        Any of the parameters may be null, and the query string will only be set for the non-null parameters. If all are set, the query string will search for items that match the type AND are in the group AND match the search string. If none are set, the query string will do a generic search to find everything that is accessible to the current user.

        Parameters:
        type - item type to search for, or null to search for items of any type
        groupId - ID of the group to search for; null or empty to search for items in any group
        searchQuery - search string to use; null or empty for no search string
        Returns:
        this PortalQueryParameters
        Since:
        100.0.0
      • setQuery

        public PortalQueryParameters setQuery​(Iterable<PortalItem.Type> types,
                                              String owner,
                                              String groupId,
                                              String searchQuery)
        Sets the query string to find items of any one of a number of given types. Optionally restricts the search to items belonging to a particular owner and/or group. An optional search string can be used to restrict the search even further.
        Parameters:
        types - item types to search for
        owner - username of the owner of the items; null or empty to search for items with any owner
        groupId - ID of the group to search for; null or empty to search for items in any group
        searchQuery - search string to use; null or empty for no search string
        Returns:
        this PortalQueryParams
        Throws:
        IllegalArgumentException - if types is null or empty
        Since:
        100.3.0
      • setQueryForItemWithId

        public PortalQueryParameters setQueryForItemWithId​(String itemId)
        Sets the query string to find an item with a specified item ID. This is a convenience method provided for the case where the user already has a portal and groups, knows the item ID, and is ready to use it.
        Parameters:
        itemId - ID of the item
        Returns:
        this PortalQueryParameters
        Throws:
        IllegalArgumentException - if itemId is null or empty
        Since:
        100.0.0
      • getQuery

        public String getQuery()
        Gets the query string to search with.
        Returns:
        query string to search with
        Since:
        100.0.0
      • setQuery

        public PortalQueryParameters setQuery​(String query)
        Sets the query string to search with.
        Parameters:
        query - the query string for searching the portal, for example "owner:user AND title:username"
        Returns:
        this PortalQueryParameters
        Since:
        100.0.0
      • getBoundingBox

        public Envelope getBoundingBox()
        Gets the bounding box if one has been set.
        Returns:
        the bounding box, or null if none has been set
        Since:
        100.2.0
        See Also:
        setBoundingBox(Envelope)
      • setBoundingBox

        public PortalQueryParameters setBoundingBox​(Envelope boundingBox)
        Sets the bounding box for a spatial search. The spatial search is an overlaps/intersects function of the query bounding box and the extent of the document. Documents that have no extent (for example mxds, 3dds, lyr) will not be found when doing a bounding box search.
        Parameters:
        boundingBox - an Envelope specifying the bounding box; z- and m values, if any, are ignored; null is allowed and clears any bounding box that was previously set
        Returns:
        this PortalQueryParameters
        Throws:
        IllegalArgumentException - if boundingBox has no SpatialReference
        Since:
        100.2.0
      • getCategories

        public List<String> getCategories()
        Gets a mutable List of content category specifications to use when searching for items using Portal.findItemsAsync(PortalQueryParameters).

        Each entry in the List is a String containing a comma-separated list of up to 8 organization-level content categories. The full path of each category is required and an OR relationship is applied between the categories within a particular String.

        There can be up to 8 Strings with an AND relationship being applied between the different Strings.

        For example, to search for items belonging to either the Water or Forest categories, both within the US, specify two Strings as follows: "/Categories/Water,/Categories/Forest" and "/Region/US".

        The categories property is ignored if the PortalQueryParameters is used to search for groups using Portal.findGroupsAsync(PortalQueryParameters).

        Returns:
        a mutable List of content category specifications. Initially this List is empty and you can add content category specifications to it.
        Since:
        100.8.0
      • getSortField

        public String getSortField()
        Gets the field or fields to sort the results by.
        Returns:
        String containing a list of one or more fields names, comma separated, or null if none
        Since:
        100.0.0
        See Also:
        setSortField(String)
      • setSortField

        public PortalQueryParameters setSortField​(String sortField)
        Sets the field or fields to sort the results by. Allowed field names are title, uploaded, type, owner, avgRating, numRatings, numComments, and numViews.
        Parameters:
        sortField - String containing a list of one or more fields names, comma separated
        Returns:
        this PortalQueryParameters
        Since:
        100.0.0
      • getSortOrder

        public PortalQueryParameters.SortOrder getSortOrder()
        Gets the sort order, indicating whether the results are returned in ascending or descending order.
        Returns:
        the sort order for results
        Since:
        100.0.0
      • setSortOrder

        public PortalQueryParameters setSortOrder​(PortalQueryParameters.SortOrder sortOrder)
        Sets the sort order, indicating whether the results are returned in ascending or descending order.
        Parameters:
        sortOrder - sort order for results
        Returns:
        this PortalQueryParameters
        Since:
        100.0.0
      • getStartIndex

        public int getStartIndex()
        Gets the start index, which is used when paging through large result sets. It is the index within the entire set of results of the first entry in the current page. The index number is 1-based.
        Returns:
        start index to use when these PortalQueryParameters are submitted
        Since:
        100.0.0
        See Also:
        PortalQueryResultSet
      • setStartIndex

        public PortalQueryParameters setStartIndex​(int startIndex)
        Sets the start index, which is used when paging through large result sets. It is the index within the entire set of results of the first entry in the current page. The index number is 1-based.
        Parameters:
        startIndex - start index to use when these PortalQueryParameters are submitted
        Returns:
        this PortalQueryParameters
        Since:
        100.0.0
        See Also:
        PortalQueryResultSet
      • getLimit

        public int getLimit()
        Gets the results limit, which is used when paging through large result sets. It is the maximum number of results to be included in the result set response.
        Returns:
        results limit to use when these PortalQueryParameters are submitted
        Since:
        100.0.0
        See Also:
        PortalQueryResultSet
      • setLimit

        public PortalQueryParameters setLimit​(int limit)
        Sets the results limit, which is used when paging through large result sets. It is the maximum number of results to be included in the result set response. It defaults to 10 if not set.
        Parameters:
        limit - the results limit to use when these PortalQueryParameters are submitted
        Returns:
        this PortalQueryParameters
        Since:
        100.0.0
        See Also:
        PortalQueryResultSet
      • isCanSearchPublic

        public boolean isCanSearchPublic()
        Returns whether or not public items outside the organization may be included in the query.
        Returns:
        true if items outside the organization may be included
        Since:
        100.0.0
      • setCanSearchPublic

        public void setCanSearchPublic​(boolean canSearchPublic)
        Determines if public items outside the organization may be included in the query. Default behavior is they are included.
        Parameters:
        canSearchPublic - true to include items outside the organization
        Since:
        100.0.0