|
||||||||||
| 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.QueryBuilder.queryFor(User.class, EntityDescriptor.user()).returningAtMost(100);This is the minimum required structure for a query.
QueryBuilder.queryFor(User.class, EntityDescriptor.user()).with(
Restriction.on(UserTermKeys.USERNAME).startingWith("b")
).startingAt(100).returningAtMost(10);
QueryBuilder.queryFor(User.class, EntityDescriptor.user()).with(
Combine.anyOf(
Restriction.on(PropertyUtils.ofTypeString("color")).startingWith("red"),
Restriction.on(PropertyUtils.ofTypeString("color")).exactlyMatching("scarlet"),
Restriction.on(PropertyUtils.ofTypeString("color")).exactlyMatching("crimson")
)
).returningAtMost(50);
QueryBuilder.queryFor(String.class, EntityDescriptor.user()).with(
Combine.allOf(
Restriction.on(PropertyUtils.ofTypeString("color")).exactlyMatching("red"),
Restriction.on(PropertyUtils.ofTypeString("color")).exactlyMatching("blue")
)
).returningAtMost(50);
QueryBuilder.queryFor(User.class, EntityDescriptor.user()).with(
Combine.anyOf(
Combine.allOf(
Restriction.on(PropertyUtils.ofTypeString("color")).exactlyMatching("red"),
Restriction.on(UserTermKeys.USERNAME).startingWith("r")
),
Combine.allOf(
Restriction.on(PropertyUtils.ofTypeString("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(PropertyUtils.ofTypeString("color"), MatchMode.EXACTLY_MATCHES, "red"); TermRestriction colorBlue = new TermRestriction (PropertyUtils.ofTypeString("color"), MatchMode.EXACTLY_MATCHES, "blue"); TermRestriction userNameR = new TermRestriction (UserTermKeys.USERNAME, MatchMode.STARTS_WITH, "r"); TermRestriction userNameB = new TermRestriction (UserTermKeys.USERNAME, MatchMode.STARTS_WITH, "b"); BooleanRestriction conjuction1 = new BooleanRestrictionImpl(BooleanRestriction.BooleanLogic.AND, colorRed, userNameR); BooleanRestriction conjuction2 = new BooleanRestrictionImpl(BooleanRestriction.BooleanLogic.AND, colorBlue, userNameB); BooleanRestriction disjunction = new BooleanRestrictionImpl(BooleanRestriction.BooleanLogic.OR, conjuction1, conjuction2); UserQuery query = new UserQuery(User.class, disjunction, 0, 10);
QueryBuilder.queryFor(User.class, EntityDescriptor.user()).childrenOf(EntityDescriptor.group()).withName("group-name").returningAtMost(10);
QueryBuilder.queryFor(String.class, EntityDescriptor.user()).childrenOf(EntityDescriptor.group()).withName("group-name").returningAtMost(10);
QueryBuilder.queryFor(Group.class, EntityDescriptor.group()).childrenOf(EntityDescriptor.group()).withName("group-name").returningAtMost(10);
QueryBuilder.queryFor(Group.class, EntityDescriptor.group()).parentsOf(EntityDescriptor.user()).withName("user-name").returningAtMost(10);
QueryBuilder.queryFor(String.class, EntityDescriptor.group()).parentsOf(EntityDescriptor.user()).withName("user-name").returningAtMost(10);
| Nested Class Summary | |
|---|---|
static class |
QueryBuilder.PartialEntityQuery<T>
|
static class |
QueryBuilder.PartialEntityQueryWithRestriction<T>
|
static class |
QueryBuilder.PartialEntityQueryWithStartIndex<T>
|
static class |
QueryBuilder.PartialMembershipQueryWithEntityToMatch<T>
|
static class |
QueryBuilder.PartialMembershipQueryWithNameToMatch<T>
|
static class |
QueryBuilder.PartialMembershipQueryWithStartIndex<T>
|
| Constructor Summary | |
|---|---|
QueryBuilder()
|
|
| Method Summary | ||
|---|---|---|
static
|
createMembershipQuery(int maxResults,
int startIndex,
boolean findMembers,
EntityDescriptor entityToReturn,
java.lang.Class<T> returnType,
EntityDescriptor entityToMatch,
java.lang.String nameToMatch)
|
|
static
|
queryFor(java.lang.Class<T> returnType,
EntityDescriptor entity)
|
|
static
|
queryFor(java.lang.Class<T> returnType,
EntityDescriptor entity,
SearchRestriction searchRestriction,
int startIndex,
int maxResults)
|
|
| 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 <T> QueryBuilder.PartialEntityQuery<T> queryFor(java.lang.Class<T> returnType,
EntityDescriptor entity)
public static <T> EntityQuery<T> queryFor(java.lang.Class<T> returnType,
EntityDescriptor entity,
SearchRestriction searchRestriction,
int startIndex,
int maxResults)
public static <T> MembershipQuery<T> createMembershipQuery(int maxResults,
int startIndex,
boolean findMembers,
EntityDescriptor entityToReturn,
java.lang.Class<T> returnType,
EntityDescriptor entityToMatch,
java.lang.String nameToMatch)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||