|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Query
An interface defining a query for QueryService.
Here is an example of how to query the first content directly under the SiteArea parentSiteArea that has an element called "myElement":
Content contentWithMyElement;
QueryService queryService = workspace.getQueryService();
Query query = queryService.createQuery(Content.class);
query.addParentId(parentSiteArea.getId(), QueryDepth.CHILDREN);
try
{
ResultIterator resultIterator = queryService.execute(query);
if (resultIterator.hasNext())
{
Content childContent = (Content) resultIterator.next();
if (childContent.hasComponent("myElement"))
{
contentWithMyElement = childContent;
}
}
}
catch (QueryServiceException e)
{
// Handle exception
}
QueryService| Method Summary | |
|---|---|
void |
addParentId(Identity parentId,
QueryDepth depth)
Instructs this query to find children of the parent document. |
void |
addSelector(Selector selector)
Adds a Selector to this Query. |
void |
addSelectors(Selector... selectors)
Adds multiple Selector to this Query. |
void |
addSort(Sort sort)
Adds a Sort to this Query. |
void |
clearSorts()
Clean the sort setting for this query. |
QueryDepth |
getDepth()
Returns whether this query will find descendant children of the parents or not. |
java.util.Set<Identity> |
getParentIds()
Return a Set of parent Identity. |
Query |
getParentQuery()
Returns the parent query. |
java.util.List<Selector> |
getSelectors()
Returns a List that contains all the Selector in this Query. |
java.util.List<Sort> |
getSorts()
Returns a List of the Sort in this query. |
boolean |
hasParents()
Returns true if this query has a parent Query. |
boolean |
isIdQuery()
Indicates whether this is query for DocumentId or not. |
boolean |
isObjectQuery()
Indicates whether this is query for Document or not. |
void |
returnIds()
Instructs the QueryService to return DocumentId instead of Document. |
void |
returnObjects()
Instructs the QueryService to return Document instead of DocumentId. |
void |
setAccessFilter(AccessFilter filter)
Set the access filter for this query. |
void |
setDepth(QueryDepth depth)
If a Query is scoped to parents, the QueryDepth tells the
Query to return all descendants or children of the parent(s). |
void |
setParentIds(java.util.Collection<Identity> parentIds,
QueryDepth depth)
Instructs this query to find children of the parent documents. |
void |
setParentQuery(Query parentQuery,
QueryDepth depth)
Instructs this query to find children of the parent documents. |
void |
setSorts(Sort... sorts)
Set all of the sorts, overriding any previous sorts added. |
| Method Detail |
|---|
void addSelector(Selector selector)
Selector to this Query.
selector - selector to be addedvoid addSelectors(Selector... selectors)
Selector to this Query.
selectors - selectors to be addedjava.util.List<Selector> getSelectors()
List that contains all the Selector in this Query.
Selectorvoid returnIds()
QueryService to return DocumentId instead of Document.
By default, the QueryService will return Documents.
void returnObjects()
QueryService to return Document instead of DocumentId.
By default, the QueryService will return Documents.
boolean isObjectQuery()
Document or not.
Documentboolean isIdQuery()
DocumentId or not.
DocumentIdvoid addSort(Sort sort)
Sort to this Query. It is possible to add multiple Sort
in one Query, the result will be sorted by adding order.
sort - Sort to be addedjava.util.List<Sort> getSorts()
List of the Sort in this query.
List of Sortvoid setSorts(Sort... sorts)
sorts - the sorts to setvoid clearSorts()
void addParentId(Identity parentId,
QueryDepth depth)
Note 1: If a parent query is also defined (via the setParentQuery method),
then this query will process the children of the specified parents who also satisfy the parent query.
Note 2: Will only return children from DRAFT parents when the query is
executed under a Project QueryScope
Note 3: The value of depth is global to the query and the value passed will override any previous value
parentId - the id of the parent documentdepth - find all descendant children
void setParentIds(java.util.Collection<Identity> parentIds,
QueryDepth depth)
Note 1: If a parent query is also defined (via the setParentQuery method),
then this query will process the children of the specified parents who also satisfy the parent query.
Note 2: Will only return children from DRAFT parents when the query is
executed under a Project QueryScope
Note 3: The value of depth is global to the query and the value passed will override any previous value
Note 4: If the collection contains duplicates these will be dropped
parentIds - collection of parent idsdepth - find all descendant childrenjava.util.Set<Identity> getParentIds()
Set of parent Identity.
void setParentQuery(Query parentQuery,
QueryDepth depth)
Note 1: If parent IDs are also defined (via the addParentId / setParentIds methods),
then this query will process the children of the defined parents who satisfy the parent query.
Note 2: Children will only be returned from PUBLISHED parents. If your parentQuery needs to be Project-Aware, then first execute it under a
Project QueryScope then set the returned Parent IDs on the Query via the Query.setParentIds / Query.addParentId methods
Note 3: The value of depth is global to the query and the value passed will override any previous value
parentQuery - query to locate parent documentsdepth - find all descendant childrenQuery getParentQuery()
void setDepth(QueryDepth depth)
Query is scoped to parents, the QueryDepth tells the
Query to return all descendants or children of the parent(s).
This has no effect if the query is not scoped to parents
depth - void setAccessFilter(AccessFilter filter)
AccessFiler allows the results of a
query to be filtered based on the access rights of specific users.
filter - QueryDepth getDepth()
boolean hasParents()
Query.
i.e. if this query is scoped by parents
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||