|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.atlassian.crowd.search.builder.QueryBuilder
public class QueryBuilder
Recommended convenience class to build queries.
Examples are presented below. 1) Find all users, return results indexed from 0 to 99 or less:
QueryBuilder.queryFor(USER).returningAtMost(100)
This is the minimum required structure for a query.
2) Find all users with the username matching b*, return results
indexed from 100 to 109 or less:
QueryBuilder.queryFor(USER).with(
Restriction.on(UserTermKeys.USERNAME).startingWith("b")
).startingAt(100).returningAtMost(10)
3) Find all users that have an attribute color with a value
that matches red* OR scarlet OR crimson, returning results
indexed from 0 to 49 or less:
QueryBuilder.queryFor(USER).with(
Combine.anyOf(
Restriction.on("color").startingWith("red"),
Restriction.on("color").exactlyMatching("scarlet"),
Restriction.on("color").exactlyMatching("crimson")
)
).returningAtMost(50)
4) Find all users that like the color red AND blue, returning
results indexed from 0 to 49:
QueryBuilder.queryFor(USER).with(
Combine.allOf(
Restriction.on("color").exactlyMatching("red"),
Restriction.on("color").exactlyMatching("blue")
)
).returningAtMost(50)
5) Find all users that like the color red and have a name
starting "r" or like blue and have a name starting with "b",
returning results indexed from 0 to 9 or less:
QueryBuilder.queryFor(USER).with(
Combine.anyOf(
Combine.allOf(
Restriction.on("color").exactlyMatching("red"),
Restriction.on(UserTermKeys.USERNAME).startingWith("r")
),
Combine.allOf(
Restriction.on("color").exactlyMatching("blue"),
Restriction.on(UserTermKeys.USERNAME).startingWith("b")
)
)
).returningAtMost(10)
This is equivalent to verbosely constructing the same query as so:
TermRestriction colorRed = new TermRestriction("color", EXACTLY_MATCHES, "red");
TermRestriction colorBlue = new TermRestriction("color", EXACTLY_MATCHES, "blue");
TermRestriction userNameR = new TermRestriction(UserTermKeys.USERNAME, STARTS_WITH, "r");
TermRestriction userNameB = new TermRestriction(UserTermKeys.USERNAME, STARTS_WITH, "b");
MultiTermRestriction conjuction1 = new MultiTermRestriction(BooleanLogic.AND, colorRed, userNameR);
MultiTermRestriction conjuction2 = new MultiTermRestriction(BooleanLogic.AND, colorBlue, userNameB);
MultiTermRestriction disjunction = new MultiTermRestriction(BooleanLogic.OR, conjuction1, conjuction2);
EntityQuery query = new EntityQuery(USER, disjunction, 0, 10);
Membership Queryies
1) Find first 10 members of a group:
QueryBuilder.queryFor(USER).membersOf(GROUP).withName("crowd-administrators").returningAtMost(10);
QB.queryFor(GROUP).ofType(ROLE).with(Restriction.on(GTK.NAME).startingWith("role"))
| Nested Class Summary | |
|---|---|
static class |
QueryBuilder.PartialEntityQuery
|
static class |
QueryBuilder.PartialEntityQueryWithRestriction
|
static class |
QueryBuilder.PartialEntityQueryWithStartIndex
|
static class |
QueryBuilder.PartialMembershipQueryWithEntityToMatch
|
static class |
QueryBuilder.PartialMembershipQueryWithNameToMatch
|
static class |
QueryBuilder.PartialMembershipQueryWithStartIndex
|
| Constructor Summary | |
|---|---|
QueryBuilder()
|
|
| Method Summary | |
|---|---|
static QueryBuilder.PartialEntityQuery |
queryFor(EntityDescriptor entity)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public QueryBuilder()
| Method Detail |
|---|
public static QueryBuilder.PartialEntityQuery queryFor(EntityDescriptor entity)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||