com.crystaldecisions.sdk.occa.infostore
Interface ICMSQuery


public interface ICMSQuery

Represents a CMS query that can be reused and passed to the InfoStore. The CMS query represents a page of objects. By default, each page is quite large, at 1000 objects. This coincides with regular CMS query syntax, the amount of objects returned from CMS is defined by its TOP N parameter. If TOP N is not specified it defaults to 1000 objects.

By using ICMSQuery you can determine the size of each page and which page you want to view. One thing to be aware of is if you adjust the page size, by default the ICMSQuery will query for the objects at its original page number. For example, if you have 100 objects, your page size is 10 and you're on page 2, objects 11 - 20 are represented by this ICMSQuery. If you call setPageSize(5), and you query again, objects 5 - 10 will be returned. If you want objects 11-15, you'll need to change the page number to page 3 by calling ICMSQuery.setCurrentPageNumber(int).

ICMSQuery also exposes some configurable options (ICMSQuery.getQueryConfig()) that can be passed to the CMS, such as object caching.


Method Summary
 int getCurrentPageNumber()
          Returns the page number (base 1 index) this ICMSQuery represents.
 int getPageAlignment()
          Returns the number of objects which are not included in the first page.
 int getPageSize()
          Returns the number of objects to be queried for
 IQueryConfiguration getQueryConfig()
          Returns the configuration for this ICMSQuery
 boolean hasNextPage()
          Determines whether a page exists after the current page.
 void nextPage()
          Increments to the next page
 int queryForLastPageNumber()
          Queries the CMS and traverses through all the InfoObjects up to the last page to return its page number (pages start at 1).
 void setCurrentPageNumber(int pageNumber)
          Set a different page number (base 1 index) to query for.
 void setPageSize(int n)
           Sets the number of objects to be queried for.
 void setQueryConfig(IQueryConfiguration config)
          Sets the configuration for this ICMSQuery
 

Method Detail

getPageAlignment

int getPageAlignment()
Returns the number of objects which are not included in the first page. It is possible to query for a page of objects such that the first object of the first page is not aligned with the first object of all the results. For example. If there are 100 objects, and we query for TOP 7-11, our page size is 5, but our first page will start at object 2. In this case our page alignment is offset by 1 The page alignment offset is always less than the page size.

Returns:

getPageSize

int getPageSize()
Returns the number of objects to be queried for

Returns:

setPageSize

void setPageSize(int n)

Sets the number of objects to be queried for. Defaults to 1000 if not set. The page number is maintained; the current object index is not. For example if you're on page 2 with a page size of 10 this ICMSQuery represents objects 11-20. If you call ICMSQuery.setPageSize(int), changing the page size to 5, the page number is maintained, and this ICMSQuery represents objects 6-10.

The TOP M-N specification in the original query will be respected if the query is created with maintainTopN set to true in IInfoStore.createCMSQuery. For example if you are querying for "top 4-10" with a page size of 3, then the first page will contain top 4-6 and second page top 7-9 and third page top 10-10. Now suppose you are on page 2. If you call #setPageSize(int, boolean) with maintainTopN = true, and change the page size to 5, the page number is maintained, and this ICMSQuery represents objects top 9-10.

Parameters:
n - The new page size. A positive number.

getCurrentPageNumber

int getCurrentPageNumber()
Returns the page number (base 1 index) this ICMSQuery represents.

Returns:

setCurrentPageNumber

void setCurrentPageNumber(int pageNumber)
Set a different page number (base 1 index) to query for.

Parameters:
pageNumber -

getQueryConfig

IQueryConfiguration getQueryConfig()
Returns the configuration for this ICMSQuery

Returns:

setQueryConfig

void setQueryConfig(IQueryConfiguration config)
Sets the configuration for this ICMSQuery


queryForLastPageNumber

int queryForLastPageNumber()
                           throws SDKException
Queries the CMS and traverses through all the InfoObjects up to the last page to return its page number (pages start at 1).

Note: Since this traverses though all the InfoObjects that match this query, this could be very expensive on the CMS performance wise.

Returns:
The last page number. Returns 0 if there are no pages
Throws:
SDKException

hasNextPage

boolean hasNextPage()
                    throws SDKException
Determines whether a page exists after the current page. The current page is set by ICMSQuery.setCurrentPageNumber(int). This hasNextPage version maintains/ignores the topN specification in the original query depending on how the maintainTopN flag is set in IInfoStore.createCMSQuery.

Returns:
True if the page after is non-empty
Throws:
SDKException - Can be thrown if this ICMSQuery represents a malformed query

nextPage

void nextPage()
Increments to the next page

Throws:
SDKException - Can be thrown if this ICMSQuery represents a malformed query
See Also:
ICMSQuery.setCurrentPageNumber(int)