org.liquidsite.core.data
Class ContentQuery

java.lang.Object
  extended byorg.liquidsite.core.data.ContentQuery

public class ContentQuery
extends java.lang.Object

A content database query. This class is used to compose complex select queries for selecting lists of content objects.


Field Summary
static java.lang.String AUTHOR_KEY
          The content revision author sorting key.
static java.lang.String CATEGORY_KEY
          The content category sorting key.
static java.lang.String COMMENT_KEY
          The content revision comment sorting key.
static java.lang.String ID_KEY
          The content identifier sorting key.
static java.lang.String MODIFIED_KEY
          The content revision modified date sorting key.
static java.lang.String NAME_KEY
          The content name sorting key.
static java.lang.String ONLINE_KEY
          The content online date sorting key.
static java.lang.String PARENT_KEY
          The content parent identifier sorting key.
static java.lang.String REVISION_KEY
          The content revision sorting key.
 
Constructor Summary
ContentQuery(java.lang.String domain)
          Creates a new content query for objects in the specified domain.
 
Method Summary
 DatabaseQuery createCountQuery()
          Creates a new database count query containing all of the parameters in this query.
 DatabaseQuery createSelectQuery()
          Creates a new database select query containing all of the parameters in this query.
 boolean isSorting()
          Checks if the query contains sort columns.
 void limitResults(int start, int count)
          Sets the result start and count limitations.
 void requireAttribute(java.lang.String attribute, java.lang.String value)
          Sets the attribute value requirement.
 void requireCategory(int category)
          Sets the content category requirement.
 void requireOnline(boolean online)
          Sets the online content requirement.
 void requireParent(int parent)
          Adds a content parent requirement.
 void requirePublished(boolean published)
          Sets the published content requirement.
 void sortByAttribute(java.lang.String attribute, boolean ascending)
          Adds a sort key attribute to the query.
 void sortByKey(java.lang.String key, boolean ascending)
          Adds a sort key column to the query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID_KEY

public static final java.lang.String ID_KEY
The content identifier sorting key.

See Also:
Constant Field Values

REVISION_KEY

public static final java.lang.String REVISION_KEY
The content revision sorting key.

See Also:
Constant Field Values

CATEGORY_KEY

public static final java.lang.String CATEGORY_KEY
The content category sorting key.

See Also:
Constant Field Values

NAME_KEY

public static final java.lang.String NAME_KEY
The content name sorting key.

See Also:
Constant Field Values

PARENT_KEY

public static final java.lang.String PARENT_KEY
The content parent identifier sorting key.

See Also:
Constant Field Values

ONLINE_KEY

public static final java.lang.String ONLINE_KEY
The content online date sorting key.

See Also:
Constant Field Values

MODIFIED_KEY

public static final java.lang.String MODIFIED_KEY
The content revision modified date sorting key.

See Also:
Constant Field Values

AUTHOR_KEY

public static final java.lang.String AUTHOR_KEY
The content revision author sorting key.

See Also:
Constant Field Values

COMMENT_KEY

public static final java.lang.String COMMENT_KEY
The content revision comment sorting key.

See Also:
Constant Field Values
Constructor Detail

ContentQuery

public ContentQuery(java.lang.String domain)
Creates a new content query for objects in the specified domain.

Parameters:
domain - the domain name
Method Detail

isSorting

public boolean isSorting()
Checks if the query contains sort columns.

Returns:
true if the query sorts the results, or false otherwise

requireParent

public void requireParent(int parent)
Adds a content parent requirement. By default any content parent will be accepted. By calling this method several times with different parents, a set of content parents will be accepted.

Parameters:
parent - the content parent identifier

requireCategory

public void requireCategory(int category)
Sets the content category requirement. By default any content category will be accepted.

Parameters:
category - the content category required

requirePublished

public void requirePublished(boolean published)
Sets the published content requirement. By default the latest (work) revision will be accepted. When this flag is set, only published objects will be returned.

Parameters:
published - the published flag

requireOnline

public void requireOnline(boolean online)
Sets the online content requirement. By default no checks for online dates are made. When this flag is set, only objects that are currently online will be returned.

Parameters:
online - the online flag

requireAttribute

public void requireAttribute(java.lang.String attribute,
                             java.lang.String value)
Sets the attribute value requirement. By default any attribute values will be accepted. When an attribute value is required, only objects having the specified value will be returned. By calling this method several times with different values, a set of attribute values will be accepted.

Parameters:
attribute - the attribute name
value - the attribute value

sortByKey

public void sortByKey(java.lang.String key,
                      boolean ascending)
Adds a sort key column to the query. Several columns can be added, giving priority to the first ones added.

Parameters:
key - the sort column key
ascending - the ascending sort order flag

sortByAttribute

public void sortByAttribute(java.lang.String attribute,
                            boolean ascending)
Adds a sort key attribute to the query. Several attributes can be added, giving priority to the first ones added.

Parameters:
attribute - the sort attribute name
ascending - the ascending sort order flag

limitResults

public void limitResults(int start,
                         int count)
Sets the result start and count limitations. By default a maximum of 100 rows are retrieved, starting from index zero (0).

Parameters:
start - the index of the first result row
count - the maximum number of result rows

createCountQuery

public DatabaseQuery createCountQuery()
Creates a new database count query containing all of the parameters in this query.

Returns:
the database count query

createSelectQuery

public DatabaseQuery createSelectQuery()
Creates a new database select query containing all of the parameters in this query.

Returns:
the database select query