com.esri.core.portal
Class PortalQueryParams

java.lang.Object
  extended by com.esri.core.portal.PortalQueryParams

public class PortalQueryParams
extends Object

Creates query parameters suitable for finding content contained in a Portal. The query can contain multiple parameters that help to limit the content returned back by the Portal such as sort order, sort field, starting index, etc.


Nested Class Summary
static class PortalQueryParams.PortalQuerySortOrder
          Describes whether the query result order returns in ascending or descending order.
 
Constructor Summary
PortalQueryParams()
          Creates a PortalQueryParams with default settings.
PortalQueryParams(String query)
          Creates a PortalQueryParams with default settings.
PortalQueryParams(String query, int limit)
          Creates a PortalQueryParams with default settings.
 
Method Summary
 boolean equals(Object obj)
          
 HashMap<String,String> generateRequestParams()
           
 int getLimit()
          Returns the maximum number of results to be included in the result set response.
 String getQuery()
          Retruns the query string to search against.
 String getSortField()
          Returns the field to sort the results by.
 PortalQueryParams.PortalQuerySortOrder getSortOrder()
          Returns whether the order of results are returned in ascending or descending order.
 int getStartIndex()
          Returns the number of the first entry in the result set response.
 int hashCode()
          
 PortalQueryParams setLimit(int limit)
          Sets the maximum number of results to be included in the result set response.
 PortalQueryParams setQuery(PortalItemType type, String groupId, String searchQuery)
          Sets a query on the portalQueryParams that will (optionally) 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 will only be set for the non-null parameters.
 PortalQueryParams setQuery(String query)
          Sets the query string to search against.
 PortalQueryParams setQueryForGroups(String username, String title)
          Sets a query on the portalQueryParams that will find groups with a specified owner and title.
 PortalQueryParams setQueryForItemsInGroup(String groupId)
          Sets a query on the portalQueryParams that will find items in a specified group.
 PortalQueryParams setQueryForItemWithId(String itemId)
          Sets a query on the portalQueryParams that will find an item with a specified itemId.
 PortalQueryParams setSortField(String sortField)
          Set the field to sort the results by.
 PortalQueryParams setSortOrder(PortalQueryParams.PortalQuerySortOrder sortOrder)
          Sets whether the order of results are returned in ascending or descending order.
 PortalQueryParams setStartIndex(int startIndex)
          Set the number of the first entry in the result set response.
 String toString()
          
 PortalQueryParams withNextStart(int nextStart)
          Returns a new copy of the PortalQueryParams with the startIndex field being set to the nextStart parameter.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PortalQueryParams

public PortalQueryParams()
Creates a PortalQueryParams with default settings. Start Index will be 1, Limit will be 10, and Sort Order will be descending. The query will be null until one is set.


PortalQueryParams

public PortalQueryParams(String query)
Creates a PortalQueryParams with default settings. This is the same as PortalQueryParams(), with the addition of the query being set.

Parameters:
query - - this is a string query passed in by the user format such as OWNER:username AND title:mygroupname

PortalQueryParams

public PortalQueryParams(String query,
                         int limit)
Creates a PortalQueryParams with default settings. This is the same as PortalQueryParams(), with the addition of the query and limit being set.

Parameters:
query - - this is a string query passed in by the user format such as OWNER:username AND title:mygroupname
limit - - the limit is 10 if not set by the user
Method Detail

withNextStart

public PortalQueryParams withNextStart(int nextStart)
Returns a new copy of the PortalQueryParams with the startIndex field being set to the nextStart parameter.

Parameters:
nextStart -
Returns:
A new copy of the PortalQueryParams with the startIndex field being set to the nextStart parameter

setQueryForItemsInGroup

public PortalQueryParams setQueryForItemsInGroup(String groupId)
Sets a query on the portalQueryParams that will find items in a specified group.

Parameters:
groupId - - this is the id of the group for which the user needs to find items
Returns:
this PortalQueryParams

setQueryForGroups

public PortalQueryParams setQueryForGroups(String username,
                                           String title)
Sets a query on the portalQueryParams that will find groups with a specified owner and title.

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

Parameters:
username - - username of the group
title - - title of the group
Returns:
this PortalQueryParams

setQuery

public PortalQueryParams setQuery(PortalItemType type,
                                  String groupId,
                                  String searchQuery)
Sets a query on the portalQueryParams that will (optionally) 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 will only be set for the non-null parameters. If all are set, the query will search for items that match the type AND are in the group AND match the search string. If none are set, a generic search will be performed.

Parameters:
type - The item type - can be null
groupId - The group's ID - can be null
searchQuery - The string to search for - can be null
Returns:
this PortalQueryParams

setQueryForItemWithId

public PortalQueryParams setQueryForItemWithId(String itemId)
Sets a query on the portalQueryParams that will find an item with a specified itemId. Its a convenience method provided in the case where the user already has a portal and groups. Knows the item id and is ready to use it.

Parameters:
itemId - - item id of the item.
Returns:
this PortalQueryParams

generateRequestParams

public HashMap<String,String> generateRequestParams()

getQuery

public String getQuery()
Retruns the query string to search against.

Returns:
The query string to search against

setQuery

public PortalQueryParams setQuery(String query)
Sets the query string to search against.

Parameters:
query - - string for searching the portal for groups, e.g. OWNER:user AND TITLE:username
Returns:
this PortalQueryParams

getSortField

public String getSortField()
Returns the field to sort the results by.

Returns:
The field to sort the results by
See Also:
setSortField(String)

setSortField

public PortalQueryParams setSortField(String sortField)
Set the field to sort the results by. You can also sort by multiple fields for an item, comma seperated. The currently allowed field names are title, uploaded, type, owner, avgRating, numRatings, numComments and numViews.

Parameters:
sortField - - the results returned are sorted by the field provided.
Returns:
this PortalQueryParams

getSortOrder

public PortalQueryParams.PortalQuerySortOrder getSortOrder()
Returns whether the order of results are returned in ascending or descending order.

Returns:
The order of results are returned in ascending or descending order

setSortOrder

public PortalQueryParams setSortOrder(PortalQueryParams.PortalQuerySortOrder sortOrder)
Sets whether the order of results are returned in ascending or descending order.

Parameters:
sortOrder - - the results returned are in the order specified.
Returns:
this PortalQueryParams

getStartIndex

public int getStartIndex()
Returns the number of the first entry in the result set response. The index number is 1-based.

Returns:
The number of the first entry in the result set response. The index number is 1-based

setStartIndex

public PortalQueryParams setStartIndex(int startIndex)
Set the number of the first entry in the result set response. The index number is 1-based.

Parameters:
startIndex -
Returns:
this PortalQueryParams

getLimit

public int getLimit()
Returns the maximum number of results to be included in the result set response.

Returns:
The maximum number of results to be included in the result set response

setLimit

public PortalQueryParams setLimit(int limit)
Sets the maximum number of results to be included in the result set response.

Parameters:
limit - - maximum number of results returned, its preset to 10 until specified otherwise.
Returns:
this PortalQueryParams

hashCode

public int hashCode()

Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)

Overrides:
equals in class Object

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2012. All Rights Reserved.