Merge "GroupIndex: Put the owner predicate back in place"
This commit is contained in:
commit
3705a71492
@ -49,7 +49,7 @@ public class GroupQueryBuilder extends QueryBuilder<InternalGroup> {
|
||||
public static final String FIELD_DESCRIPTION = "description";
|
||||
public static final String FIELD_INNAME = "inname";
|
||||
public static final String FIELD_NAME = "name";
|
||||
@Deprecated public static final String FIELD_OWNER = "owner";
|
||||
public static final String FIELD_OWNER = "owner";
|
||||
public static final String FIELD_LIMIT = "limit";
|
||||
|
||||
private static final QueryBuilder.Definition<InternalGroup, GroupQueryBuilder> mydef =
|
||||
@ -109,6 +109,12 @@ public class GroupQueryBuilder extends QueryBuilder<InternalGroup> {
|
||||
return GroupPredicates.name(name);
|
||||
}
|
||||
|
||||
@Operator
|
||||
public Predicate<InternalGroup> owner(String owner) throws QueryParseException {
|
||||
AccountGroup.UUID groupUuid = parseGroup(owner);
|
||||
return GroupPredicates.owner(groupUuid);
|
||||
}
|
||||
|
||||
@Operator
|
||||
public Predicate<InternalGroup> is(String value) throws QueryParseException {
|
||||
if ("visibletoall".equalsIgnoreCase(value)) {
|
||||
@ -127,6 +133,11 @@ public class GroupQueryBuilder extends QueryBuilder<InternalGroup> {
|
||||
if (!Strings.isNullOrEmpty(query)) {
|
||||
preds.add(description(query));
|
||||
}
|
||||
try {
|
||||
preds.add(owner(query));
|
||||
} catch (QueryParseException e) {
|
||||
// Skip.
|
||||
}
|
||||
return Predicate.or(preds);
|
||||
}
|
||||
|
||||
|
@ -245,6 +245,19 @@ public abstract class AbstractQueryGroupsTest extends GerritServerTests {
|
||||
assertQuery("description:\"\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void byOwner() throws Exception {
|
||||
GroupInfo ownerGroup = createGroup(name("owner-group"));
|
||||
GroupInfo group = createGroupWithOwner(name("group"), ownerGroup);
|
||||
createGroup(name("group2"));
|
||||
|
||||
assertQuery("owner:" + group.id);
|
||||
|
||||
// ownerGroup owns itself
|
||||
assertQuery("owner:" + ownerGroup.id, group, ownerGroup);
|
||||
assertQuery("owner:" + ownerGroup.name, group, ownerGroup);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void byIsVisibleToAll() throws Exception {
|
||||
assertQuery("is:visibletoall");
|
||||
|
Loading…
Reference in New Issue
Block a user