Make Predicates more amenable to use by plugins
Make most Predicates and static methods public, make most private fields and methods protected. Change-Id: Id898e835341765d8d0d86ed7dcb3a21ea4c8ef27
This commit is contained in:
@@ -18,10 +18,10 @@ import java.util.Collection;
|
|||||||
|
|
||||||
/** Predicate to filter a field by matching value. */
|
/** Predicate to filter a field by matching value. */
|
||||||
public abstract class OperatorPredicate<T> extends Predicate<T> {
|
public abstract class OperatorPredicate<T> extends Predicate<T> {
|
||||||
private final String name;
|
protected final String name;
|
||||||
private final String value;
|
protected final String value;
|
||||||
|
|
||||||
protected OperatorPredicate(final String name, final String value) {
|
public OperatorPredicate(final String name, final String value) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ import com.google.gerrit.server.query.IsVisibleToPredicate;
|
|||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
public class AccountIsVisibleToPredicate extends IsVisibleToPredicate<AccountState> {
|
public class AccountIsVisibleToPredicate extends IsVisibleToPredicate<AccountState> {
|
||||||
private final AccountControl accountControl;
|
protected final AccountControl accountControl;
|
||||||
|
|
||||||
AccountIsVisibleToPredicate(AccountControl accountControl) {
|
public AccountIsVisibleToPredicate(AccountControl accountControl) {
|
||||||
super(AccountQueryBuilder.FIELD_VISIBLETO, describe(accountControl.getUser()));
|
super(AccountQueryBuilder.FIELD_VISIBLETO, describe(accountControl.getUser()));
|
||||||
this.accountControl = accountControl;
|
this.accountControl = accountControl;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import com.google.gerrit.server.query.QueryParseException;
|
|||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
public class AddedPredicate extends IntegerRangeChangePredicate {
|
public class AddedPredicate extends IntegerRangeChangePredicate {
|
||||||
AddedPredicate(String value) throws QueryParseException {
|
public AddedPredicate(String value) throws QueryParseException {
|
||||||
super(ChangeField.ADDED, value);
|
super(ChangeField.ADDED, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ import com.google.gwtorm.server.OrmException;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class AfterPredicate extends TimestampRangeChangePredicate {
|
public class AfterPredicate extends TimestampRangeChangePredicate {
|
||||||
private final Date cut;
|
protected final Date cut;
|
||||||
|
|
||||||
AfterPredicate(String value) throws QueryParseException {
|
public AfterPredicate(String value) throws QueryParseException {
|
||||||
super(ChangeField.UPDATED, ChangeQueryBuilder.FIELD_BEFORE, value);
|
super(ChangeField.UPDATED, ChangeQueryBuilder.FIELD_BEFORE, value);
|
||||||
cut = parse(value);
|
cut = parse(value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ import com.google.gwtorm.server.OrmException;
|
|||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
|
||||||
public class AgePredicate extends TimestampRangeChangePredicate {
|
public class AgePredicate extends TimestampRangeChangePredicate {
|
||||||
private final long cut;
|
protected final long cut;
|
||||||
|
|
||||||
AgePredicate(String value) {
|
public AgePredicate(String value) {
|
||||||
super(ChangeField.UPDATED, ChangeQueryBuilder.FIELD_AGE, value);
|
super(ChangeField.UPDATED, ChangeQueryBuilder.FIELD_AGE, value);
|
||||||
|
|
||||||
long s = ConfigUtil.getTimeUnit(getValue(), 0, SECONDS);
|
long s = ConfigUtil.getTimeUnit(getValue(), 0, SECONDS);
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ import com.google.gerrit.reviewdb.client.Account;
|
|||||||
import com.google.gerrit.server.index.change.ChangeField;
|
import com.google.gerrit.server.index.change.ChangeField;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
class AssigneePredicate extends ChangeIndexPredicate {
|
public class AssigneePredicate extends ChangeIndexPredicate {
|
||||||
private final Account.Id id;
|
protected final Account.Id id;
|
||||||
|
|
||||||
AssigneePredicate(Account.Id id) {
|
public AssigneePredicate(Account.Id id) {
|
||||||
super(ChangeField.ASSIGNEE, id.toString());
|
super(ChangeField.ASSIGNEE, id.toString());
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import com.google.gwtorm.server.OrmException;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class AuthorPredicate extends ChangeIndexPredicate {
|
public class AuthorPredicate extends ChangeIndexPredicate {
|
||||||
AuthorPredicate(String value) {
|
public AuthorPredicate(String value) {
|
||||||
super(AUTHOR, FIELD_AUTHOR, value.toLowerCase());
|
super(AUTHOR, FIELD_AUTHOR, value.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ import com.google.gwtorm.server.OrmException;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class BeforePredicate extends TimestampRangeChangePredicate {
|
public class BeforePredicate extends TimestampRangeChangePredicate {
|
||||||
private final Date cut;
|
protected final Date cut;
|
||||||
|
|
||||||
BeforePredicate(String value) throws QueryParseException {
|
public BeforePredicate(String value) throws QueryParseException {
|
||||||
super(ChangeField.UPDATED, ChangeQueryBuilder.FIELD_BEFORE, value);
|
super(ChangeField.UPDATED, ChangeQueryBuilder.FIELD_BEFORE, value);
|
||||||
cut = parse(value);
|
cut = parse(value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ import com.google.gerrit.server.index.FieldDef;
|
|||||||
import com.google.gerrit.server.index.FieldDef.FillArgs;
|
import com.google.gerrit.server.index.FieldDef.FillArgs;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
class BooleanPredicate extends ChangeIndexPredicate {
|
public class BooleanPredicate extends ChangeIndexPredicate {
|
||||||
private final FillArgs args;
|
protected final FillArgs args;
|
||||||
|
|
||||||
BooleanPredicate(FieldDef<ChangeData, String> field, FillArgs args) {
|
public BooleanPredicate(FieldDef<ChangeData, String> field, FillArgs args) {
|
||||||
super(field, "1");
|
super(field, "1");
|
||||||
this.args = args;
|
this.args = args;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ import com.google.gerrit.server.index.change.ChangeField;
|
|||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
/** Predicate over Change-Id strings (aka Change.Key). */
|
/** Predicate over Change-Id strings (aka Change.Key). */
|
||||||
class ChangeIdPredicate extends ChangeIndexPredicate {
|
public class ChangeIdPredicate extends ChangeIndexPredicate {
|
||||||
ChangeIdPredicate(String id) {
|
public ChangeIdPredicate(String id) {
|
||||||
super(ChangeField.ID, ChangeQueryBuilder.FIELD_CHANGE, id);
|
super(ChangeField.ID, ChangeQueryBuilder.FIELD_CHANGE, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,13 +24,13 @@ import com.google.gerrit.server.query.IsVisibleToPredicate;
|
|||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
|
|
||||||
class ChangeIsVisibleToPredicate extends IsVisibleToPredicate<ChangeData> {
|
public class ChangeIsVisibleToPredicate extends IsVisibleToPredicate<ChangeData> {
|
||||||
private final Provider<ReviewDb> db;
|
protected final Provider<ReviewDb> db;
|
||||||
private final ChangeNotes.Factory notesFactory;
|
protected final ChangeNotes.Factory notesFactory;
|
||||||
private final ChangeControl.GenericFactory changeControl;
|
protected final ChangeControl.GenericFactory changeControl;
|
||||||
private final CurrentUser user;
|
protected final CurrentUser user;
|
||||||
|
|
||||||
ChangeIsVisibleToPredicate(
|
public ChangeIsVisibleToPredicate(
|
||||||
Provider<ReviewDb> db,
|
Provider<ReviewDb> db,
|
||||||
ChangeNotes.Factory notesFactory,
|
ChangeNotes.Factory notesFactory,
|
||||||
ChangeControl.GenericFactory changeControlFactory,
|
ChangeControl.GenericFactory changeControlFactory,
|
||||||
|
|||||||
@@ -36,9 +36,9 @@ import java.util.TreeMap;
|
|||||||
* <p>Status names are looked up by prefix case-insensitively.
|
* <p>Status names are looked up by prefix case-insensitively.
|
||||||
*/
|
*/
|
||||||
public final class ChangeStatusPredicate extends ChangeIndexPredicate {
|
public final class ChangeStatusPredicate extends ChangeIndexPredicate {
|
||||||
private static final TreeMap<String, Predicate<ChangeData>> PREDICATES;
|
protected static final TreeMap<String, Predicate<ChangeData>> PREDICATES;
|
||||||
private static final Predicate<ChangeData> CLOSED;
|
protected static final Predicate<ChangeData> CLOSED;
|
||||||
private static final Predicate<ChangeData> OPEN;
|
protected static final Predicate<ChangeData> OPEN;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
PREDICATES = new TreeMap<>();
|
PREDICATES = new TreeMap<>();
|
||||||
@@ -84,9 +84,9 @@ public final class ChangeStatusPredicate extends ChangeIndexPredicate {
|
|||||||
return CLOSED;
|
return CLOSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Change.Status status;
|
protected final Change.Status status;
|
||||||
|
|
||||||
ChangeStatusPredicate(Change.Status status) {
|
public ChangeStatusPredicate(Change.Status status) {
|
||||||
super(ChangeField.STATUS, canonicalize(status));
|
super(ChangeField.STATUS, canonicalize(status));
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ import com.google.gerrit.server.index.change.ChangeField;
|
|||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
class CommentByPredicate extends ChangeIndexPredicate {
|
public class CommentByPredicate extends ChangeIndexPredicate {
|
||||||
private final Account.Id id;
|
protected final Account.Id id;
|
||||||
|
|
||||||
CommentByPredicate(Account.Id id) {
|
public CommentByPredicate(Account.Id id) {
|
||||||
super(ChangeField.COMMENTBY, id.toString());
|
super(ChangeField.COMMENTBY, id.toString());
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ import com.google.gerrit.server.query.Predicate;
|
|||||||
import com.google.gerrit.server.query.QueryParseException;
|
import com.google.gerrit.server.query.QueryParseException;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
class CommentPredicate extends ChangeIndexPredicate {
|
public class CommentPredicate extends ChangeIndexPredicate {
|
||||||
private final ChangeIndex index;
|
protected final ChangeIndex index;
|
||||||
|
|
||||||
CommentPredicate(ChangeIndex index, String value) {
|
public CommentPredicate(ChangeIndex index, String value) {
|
||||||
super(ChangeField.COMMENT, value);
|
super(ChangeField.COMMENT, value);
|
||||||
this.index = index;
|
this.index = index;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import com.google.gerrit.reviewdb.client.PatchSet;
|
|||||||
import com.google.gerrit.server.index.FieldDef;
|
import com.google.gerrit.server.index.FieldDef;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
class CommitPredicate extends ChangeIndexPredicate {
|
public class CommitPredicate extends ChangeIndexPredicate {
|
||||||
static FieldDef<ChangeData, ?> commitField(String id) {
|
static FieldDef<ChangeData, ?> commitField(String id) {
|
||||||
if (id.length() == OBJECT_ID_STRING_LENGTH) {
|
if (id.length() == OBJECT_ID_STRING_LENGTH) {
|
||||||
return EXACT_COMMIT;
|
return EXACT_COMMIT;
|
||||||
@@ -30,7 +30,7 @@ class CommitPredicate extends ChangeIndexPredicate {
|
|||||||
return COMMIT;
|
return COMMIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommitPredicate(String id) {
|
public CommitPredicate(String id) {
|
||||||
super(commitField(id), id);
|
super(commitField(id), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ class CommitPredicate extends ChangeIndexPredicate {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean equals(PatchSet p, String id) {
|
protected boolean equals(PatchSet p, String id) {
|
||||||
boolean exact = getField() == EXACT_COMMIT;
|
boolean exact = getField() == EXACT_COMMIT;
|
||||||
String rev = p.getRevision() != null ? p.getRevision().get() : null;
|
String rev = p.getRevision() != null ? p.getRevision().get() : null;
|
||||||
return (exact && id.equals(rev)) || (!exact && rev != null && rev.startsWith(id));
|
return (exact && id.equals(rev)) || (!exact && rev != null && rev.startsWith(id));
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import com.google.gwtorm.server.OrmException;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class CommitterPredicate extends ChangeIndexPredicate {
|
public class CommitterPredicate extends ChangeIndexPredicate {
|
||||||
CommitterPredicate(String value) {
|
public CommitterPredicate(String value) {
|
||||||
super(COMMITTER, FIELD_COMMITTER, value.toLowerCase());
|
super(COMMITTER, FIELD_COMMITTER, value.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,19 +45,19 @@ import org.eclipse.jgit.revwalk.filter.RevFilter;
|
|||||||
import org.eclipse.jgit.treewalk.TreeWalk;
|
import org.eclipse.jgit.treewalk.TreeWalk;
|
||||||
import org.eclipse.jgit.treewalk.filter.TreeFilter;
|
import org.eclipse.jgit.treewalk.filter.TreeFilter;
|
||||||
|
|
||||||
class ConflictsPredicate extends OrPredicate<ChangeData> {
|
public class ConflictsPredicate extends OrPredicate<ChangeData> {
|
||||||
// UI code may depend on this string, so use caution when changing.
|
// UI code may depend on this string, so use caution when changing.
|
||||||
private static final String TOO_MANY_FILES = "too many files to find conflicts";
|
protected static final String TOO_MANY_FILES = "too many files to find conflicts";
|
||||||
|
|
||||||
private final String value;
|
protected final String value;
|
||||||
|
|
||||||
ConflictsPredicate(Arguments args, String value, List<Change> changes)
|
public ConflictsPredicate(Arguments args, String value, List<Change> changes)
|
||||||
throws QueryParseException, OrmException {
|
throws QueryParseException, OrmException {
|
||||||
super(predicates(args, value, changes));
|
super(predicates(args, value, changes));
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Predicate<ChangeData>> predicates(
|
public static List<Predicate<ChangeData>> predicates(
|
||||||
final Arguments args, String value, List<Change> changes)
|
final Arguments args, String value, List<Change> changes)
|
||||||
throws QueryParseException, OrmException {
|
throws QueryParseException, OrmException {
|
||||||
int indexTerms = 0;
|
int indexTerms = 0;
|
||||||
@@ -160,7 +160,7 @@ class ConflictsPredicate extends OrPredicate<ChangeData> {
|
|||||||
return changePredicates;
|
return changePredicates;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<String> listFiles(Change c, Arguments args, ChangeDataCache changeDataCache)
|
public static List<String> listFiles(Change c, Arguments args, ChangeDataCache changeDataCache)
|
||||||
throws OrmException {
|
throws OrmException {
|
||||||
try (Repository repo = args.repoManager.openRepository(c.getProject());
|
try (Repository repo = args.repoManager.openRepository(c.getProject());
|
||||||
RevWalk rw = new RevWalk(repo)) {
|
RevWalk rw = new RevWalk(repo)) {
|
||||||
@@ -200,17 +200,17 @@ class ConflictsPredicate extends OrPredicate<ChangeData> {
|
|||||||
return ChangeQueryBuilder.FIELD_CONFLICTS + ":" + value;
|
return ChangeQueryBuilder.FIELD_CONFLICTS + ":" + value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ChangeDataCache {
|
public static class ChangeDataCache {
|
||||||
private final Change change;
|
protected final Change change;
|
||||||
private final Provider<ReviewDb> db;
|
protected final Provider<ReviewDb> db;
|
||||||
private final ChangeData.Factory changeDataFactory;
|
protected final ChangeData.Factory changeDataFactory;
|
||||||
private final ProjectCache projectCache;
|
protected final ProjectCache projectCache;
|
||||||
|
|
||||||
private ObjectId testAgainst;
|
protected ObjectId testAgainst;
|
||||||
private ProjectState projectState;
|
protected ProjectState projectState;
|
||||||
private Iterable<ObjectId> alreadyAccepted;
|
protected Iterable<ObjectId> alreadyAccepted;
|
||||||
|
|
||||||
ChangeDataCache(
|
public ChangeDataCache(
|
||||||
Change change,
|
Change change,
|
||||||
Provider<ReviewDb> db,
|
Provider<ReviewDb> db,
|
||||||
ChangeData.Factory changeDataFactory,
|
ChangeData.Factory changeDataFactory,
|
||||||
@@ -221,7 +221,7 @@ class ConflictsPredicate extends OrPredicate<ChangeData> {
|
|||||||
this.projectCache = projectCache;
|
this.projectCache = projectCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectId getTestAgainst() throws OrmException {
|
protected ObjectId getTestAgainst() throws OrmException {
|
||||||
if (testAgainst == null) {
|
if (testAgainst == null) {
|
||||||
testAgainst =
|
testAgainst =
|
||||||
ObjectId.fromString(
|
ObjectId.fromString(
|
||||||
@@ -230,7 +230,7 @@ class ConflictsPredicate extends OrPredicate<ChangeData> {
|
|||||||
return testAgainst;
|
return testAgainst;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectState getProjectState() {
|
protected ProjectState getProjectState() {
|
||||||
if (projectState == null) {
|
if (projectState == null) {
|
||||||
projectState = projectCache.get(change.getProject());
|
projectState = projectCache.get(change.getProject());
|
||||||
if (projectState == null) {
|
if (projectState == null) {
|
||||||
@@ -240,7 +240,7 @@ class ConflictsPredicate extends OrPredicate<ChangeData> {
|
|||||||
return projectState;
|
return projectState;
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterable<ObjectId> getAlreadyAccepted(Repository repo) throws IOException {
|
protected Iterable<ObjectId> getAlreadyAccepted(Repository repo) throws IOException {
|
||||||
if (alreadyAccepted == null) {
|
if (alreadyAccepted == null) {
|
||||||
alreadyAccepted = SubmitDryRun.getAlreadyAccepted(repo);
|
alreadyAccepted = SubmitDryRun.getAlreadyAccepted(repo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import com.google.gerrit.server.query.QueryParseException;
|
|||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
public class DeletedPredicate extends IntegerRangeChangePredicate {
|
public class DeletedPredicate extends IntegerRangeChangePredicate {
|
||||||
DeletedPredicate(String value) throws QueryParseException {
|
public DeletedPredicate(String value) throws QueryParseException {
|
||||||
super(ChangeField.DELETED, value);
|
super(ChangeField.DELETED, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import com.google.gerrit.server.query.QueryParseException;
|
|||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
public class DeltaPredicate extends IntegerRangeChangePredicate {
|
public class DeltaPredicate extends IntegerRangeChangePredicate {
|
||||||
DeltaPredicate(String value) throws QueryParseException {
|
public DeltaPredicate(String value) throws QueryParseException {
|
||||||
super(ChangeField.DELTA, value);
|
super(ChangeField.DELTA, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ import com.google.gerrit.reviewdb.client.Change;
|
|||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
class DestinationPredicate extends ChangeOperatorPredicate {
|
public class DestinationPredicate extends ChangeOperatorPredicate {
|
||||||
Set<Branch.NameKey> destinations;
|
protected Set<Branch.NameKey> destinations;
|
||||||
|
|
||||||
DestinationPredicate(Set<Branch.NameKey> destinations, String value) {
|
public DestinationPredicate(Set<Branch.NameKey> destinations, String value) {
|
||||||
super(ChangeQueryBuilder.FIELD_DESTINATION, value);
|
super(ChangeQueryBuilder.FIELD_DESTINATION, value);
|
||||||
this.destinations = destinations;
|
this.destinations = destinations;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ import com.google.gerrit.reviewdb.client.Account;
|
|||||||
import com.google.gerrit.server.index.change.ChangeField;
|
import com.google.gerrit.server.index.change.ChangeField;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
class EditByPredicate extends ChangeIndexPredicate {
|
public class EditByPredicate extends ChangeIndexPredicate {
|
||||||
private final Account.Id id;
|
protected final Account.Id id;
|
||||||
|
|
||||||
EditByPredicate(Account.Id id) {
|
public EditByPredicate(Account.Id id) {
|
||||||
super(ChangeField.EDITBY, id.toString());
|
super(ChangeField.EDITBY, id.toString());
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ import com.google.gerrit.server.query.Predicate;
|
|||||||
import com.google.gerrit.server.query.change.ChangeQueryBuilder.Arguments;
|
import com.google.gerrit.server.query.change.ChangeQueryBuilder.Arguments;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
class EqualsFilePredicate extends ChangeIndexPredicate {
|
public class EqualsFilePredicate extends ChangeIndexPredicate {
|
||||||
static Predicate<ChangeData> create(Arguments args, String value) {
|
public static Predicate<ChangeData> create(Arguments args, String value) {
|
||||||
Predicate<ChangeData> eqPath = new EqualsPathPredicate(ChangeQueryBuilder.FIELD_FILE, value);
|
Predicate<ChangeData> eqPath = new EqualsPathPredicate(ChangeQueryBuilder.FIELD_FILE, value);
|
||||||
if (!args.getSchema().hasField(ChangeField.FILE_PART)) {
|
if (!args.getSchema().hasField(ChangeField.FILE_PART)) {
|
||||||
return eqPath;
|
return eqPath;
|
||||||
@@ -28,7 +28,7 @@ class EqualsFilePredicate extends ChangeIndexPredicate {
|
|||||||
return Predicate.or(eqPath, new EqualsFilePredicate(value));
|
return Predicate.or(eqPath, new EqualsFilePredicate(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String value;
|
protected final String value;
|
||||||
|
|
||||||
private EqualsFilePredicate(String value) {
|
private EqualsFilePredicate(String value) {
|
||||||
super(ChangeField.FILE_PART, ChangeQueryBuilder.FIELD_FILE, value);
|
super(ChangeField.FILE_PART, ChangeQueryBuilder.FIELD_FILE, value);
|
||||||
|
|||||||
@@ -31,17 +31,18 @@ import com.google.gerrit.server.project.ProjectState;
|
|||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
|
|
||||||
class EqualsLabelPredicate extends ChangeIndexPredicate {
|
public class EqualsLabelPredicate extends ChangeIndexPredicate {
|
||||||
private final ProjectCache projectCache;
|
protected final ProjectCache projectCache;
|
||||||
private final PermissionBackend permissionBackend;
|
protected final PermissionBackend permissionBackend;
|
||||||
private final IdentifiedUser.GenericFactory userFactory;
|
protected final IdentifiedUser.GenericFactory userFactory;
|
||||||
private final Provider<ReviewDb> dbProvider;
|
protected final Provider<ReviewDb> dbProvider;
|
||||||
private final String label;
|
protected final String label;
|
||||||
private final int expVal;
|
protected final int expVal;
|
||||||
private final Account.Id account;
|
protected final Account.Id account;
|
||||||
private final AccountGroup.UUID group;
|
protected final AccountGroup.UUID group;
|
||||||
|
|
||||||
EqualsLabelPredicate(LabelPredicate.Args args, String label, int expVal, Account.Id account) {
|
public EqualsLabelPredicate(
|
||||||
|
LabelPredicate.Args args, String label, int expVal, Account.Id account) {
|
||||||
super(ChangeField.LABEL, ChangeField.formatLabel(label, expVal, account));
|
super(ChangeField.LABEL, ChangeField.formatLabel(label, expVal, account));
|
||||||
this.permissionBackend = args.permissionBackend;
|
this.permissionBackend = args.permissionBackend;
|
||||||
this.projectCache = args.projectCache;
|
this.projectCache = args.projectCache;
|
||||||
@@ -91,7 +92,7 @@ class EqualsLabelPredicate extends ChangeIndexPredicate {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static LabelType type(LabelTypes types, String toFind) {
|
protected static LabelType type(LabelTypes types, String toFind) {
|
||||||
if (types.byLabel(toFind) != null) {
|
if (types.byLabel(toFind) != null) {
|
||||||
return types.byLabel(toFind);
|
return types.byLabel(toFind);
|
||||||
}
|
}
|
||||||
@@ -104,7 +105,7 @@ class EqualsLabelPredicate extends ChangeIndexPredicate {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean match(ChangeData cd, short value, Account.Id approver, LabelType type) {
|
protected boolean match(ChangeData cd, short value, Account.Id approver, LabelType type) {
|
||||||
if (value != expVal) {
|
if (value != expVal) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ import com.google.gwtorm.server.OrmException;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
class EqualsPathPredicate extends ChangeIndexPredicate {
|
public class EqualsPathPredicate extends ChangeIndexPredicate {
|
||||||
private final String value;
|
protected final String value;
|
||||||
|
|
||||||
EqualsPathPredicate(String fieldName, String value) {
|
public EqualsPathPredicate(String fieldName, String value) {
|
||||||
super(ChangeField.PATH, fieldName, value);
|
super(ChangeField.PATH, fieldName, value);
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ import static com.google.gerrit.server.index.change.ChangeField.EXACT_TOPIC;
|
|||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
class ExactTopicPredicate extends ChangeIndexPredicate {
|
public class ExactTopicPredicate extends ChangeIndexPredicate {
|
||||||
ExactTopicPredicate(String topic) {
|
public ExactTopicPredicate(String topic) {
|
||||||
super(EXACT_TOPIC, topic);
|
super(EXACT_TOPIC, topic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ import com.google.gerrit.server.query.Predicate;
|
|||||||
import com.google.gerrit.server.query.QueryParseException;
|
import com.google.gerrit.server.query.QueryParseException;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
class FuzzyTopicPredicate extends ChangeIndexPredicate {
|
public class FuzzyTopicPredicate extends ChangeIndexPredicate {
|
||||||
private final ChangeIndex index;
|
protected final ChangeIndex index;
|
||||||
|
|
||||||
FuzzyTopicPredicate(String topic, ChangeIndex index) {
|
public FuzzyTopicPredicate(String topic, ChangeIndex index) {
|
||||||
super(FUZZY_TOPIC, topic);
|
super(FUZZY_TOPIC, topic);
|
||||||
this.index = index;
|
this.index = index;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ import com.google.gerrit.server.index.change.ChangeField;
|
|||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
class GroupPredicate extends ChangeIndexPredicate {
|
public class GroupPredicate extends ChangeIndexPredicate {
|
||||||
GroupPredicate(String group) {
|
public GroupPredicate(String group) {
|
||||||
super(ChangeField.GROUP, group);
|
super(ChangeField.GROUP, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ import com.google.gerrit.reviewdb.client.Account;
|
|||||||
import com.google.gerrit.server.index.change.ChangeField;
|
import com.google.gerrit.server.index.change.ChangeField;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
class HasDraftByPredicate extends ChangeIndexPredicate {
|
public class HasDraftByPredicate extends ChangeIndexPredicate {
|
||||||
private final Account.Id accountId;
|
protected final Account.Id accountId;
|
||||||
|
|
||||||
HasDraftByPredicate(Account.Id accountId) {
|
public HasDraftByPredicate(Account.Id accountId) {
|
||||||
super(ChangeField.DRAFTBY, accountId.toString());
|
super(ChangeField.DRAFTBY, accountId.toString());
|
||||||
this.accountId = accountId;
|
this.accountId = accountId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ import com.google.gerrit.server.index.change.ChangeField;
|
|||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
public class HasStarsPredicate extends ChangeIndexPredicate {
|
public class HasStarsPredicate extends ChangeIndexPredicate {
|
||||||
private final Account.Id accountId;
|
protected final Account.Id accountId;
|
||||||
|
|
||||||
HasStarsPredicate(Account.Id accountId) {
|
public HasStarsPredicate(Account.Id accountId) {
|
||||||
super(ChangeField.STARBY, accountId.toString());
|
super(ChangeField.STARBY, accountId.toString());
|
||||||
this.accountId = accountId;
|
this.accountId = accountId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ import com.google.gerrit.server.change.HashtagsUtil;
|
|||||||
import com.google.gerrit.server.index.change.ChangeField;
|
import com.google.gerrit.server.index.change.ChangeField;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
class HashtagPredicate extends ChangeIndexPredicate {
|
public class HashtagPredicate extends ChangeIndexPredicate {
|
||||||
HashtagPredicate(String hashtag) {
|
public HashtagPredicate(String hashtag) {
|
||||||
super(ChangeField.HASHTAG, HashtagsUtil.cleanupHashtag(hashtag));
|
super(ChangeField.HASHTAG, HashtagsUtil.cleanupHashtag(hashtag));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import org.eclipse.jgit.revwalk.RevCommit;
|
|||||||
import org.eclipse.jgit.revwalk.RevWalk;
|
import org.eclipse.jgit.revwalk.RevWalk;
|
||||||
|
|
||||||
public class IsMergePredicate extends ChangeOperatorPredicate {
|
public class IsMergePredicate extends ChangeOperatorPredicate {
|
||||||
private final Arguments args;
|
protected final Arguments args;
|
||||||
|
|
||||||
public IsMergePredicate(Arguments args, String value) {
|
public IsMergePredicate(Arguments args, String value) {
|
||||||
super(ChangeQueryBuilder.FIELD_MERGE, value);
|
super(ChangeQueryBuilder.FIELD_MERGE, value);
|
||||||
|
|||||||
@@ -25,14 +25,14 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
class IsReviewedPredicate extends ChangeIndexPredicate {
|
public class IsReviewedPredicate extends ChangeIndexPredicate {
|
||||||
private static final Account.Id NOT_REVIEWED = new Account.Id(ChangeField.NOT_REVIEWED);
|
protected static final Account.Id NOT_REVIEWED = new Account.Id(ChangeField.NOT_REVIEWED);
|
||||||
|
|
||||||
static Predicate<ChangeData> create() {
|
public static Predicate<ChangeData> create() {
|
||||||
return Predicate.not(new IsReviewedPredicate(NOT_REVIEWED));
|
return Predicate.not(new IsReviewedPredicate(NOT_REVIEWED));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Predicate<ChangeData> create(Collection<Account.Id> ids) {
|
public static Predicate<ChangeData> create(Collection<Account.Id> ids) {
|
||||||
List<Predicate<ChangeData>> predicates = new ArrayList<>(ids.size());
|
List<Predicate<ChangeData>> predicates = new ArrayList<>(ids.size());
|
||||||
for (Account.Id id : ids) {
|
for (Account.Id id : ids) {
|
||||||
predicates.add(new IsReviewedPredicate(id));
|
predicates.add(new IsReviewedPredicate(id));
|
||||||
@@ -40,7 +40,7 @@ class IsReviewedPredicate extends ChangeIndexPredicate {
|
|||||||
return Predicate.or(predicates);
|
return Predicate.or(predicates);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Account.Id id;
|
protected final Account.Id id;
|
||||||
|
|
||||||
private IsReviewedPredicate(Account.Id id) {
|
private IsReviewedPredicate(Account.Id id) {
|
||||||
super(REVIEWEDBY, Integer.toString(id.get()));
|
super(REVIEWEDBY, Integer.toString(id.get()));
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ import com.google.gerrit.server.query.QueryParseException;
|
|||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
public class IsUnresolvedPredicate extends IntegerRangeChangePredicate {
|
public class IsUnresolvedPredicate extends IntegerRangeChangePredicate {
|
||||||
IsUnresolvedPredicate() throws QueryParseException {
|
public IsUnresolvedPredicate() throws QueryParseException {
|
||||||
this(">0");
|
this(">0");
|
||||||
}
|
}
|
||||||
|
|
||||||
IsUnresolvedPredicate(String value) throws QueryParseException {
|
public IsUnresolvedPredicate(String value) throws QueryParseException {
|
||||||
super(ChangeField.UNRESOLVED_COMMENT_COUNT, value);
|
super(ChangeField.UNRESOLVED_COMMENT_COUNT, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,23 +26,23 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
class IsWatchedByPredicate extends AndPredicate<ChangeData> {
|
public class IsWatchedByPredicate extends AndPredicate<ChangeData> {
|
||||||
private static String describe(CurrentUser user) {
|
protected static String describe(CurrentUser user) {
|
||||||
if (user.isIdentifiedUser()) {
|
if (user.isIdentifiedUser()) {
|
||||||
return user.getAccountId().toString();
|
return user.getAccountId().toString();
|
||||||
}
|
}
|
||||||
return user.toString();
|
return user.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final CurrentUser user;
|
protected final CurrentUser user;
|
||||||
|
|
||||||
IsWatchedByPredicate(ChangeQueryBuilder.Arguments args, boolean checkIsVisible)
|
public IsWatchedByPredicate(ChangeQueryBuilder.Arguments args, boolean checkIsVisible)
|
||||||
throws QueryParseException {
|
throws QueryParseException {
|
||||||
super(filters(args, checkIsVisible));
|
super(filters(args, checkIsVisible));
|
||||||
this.user = args.getUser();
|
this.user = args.getUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Predicate<ChangeData>> filters(
|
protected static List<Predicate<ChangeData>> filters(
|
||||||
ChangeQueryBuilder.Arguments args, boolean checkIsVisible) throws QueryParseException {
|
ChangeQueryBuilder.Arguments args, boolean checkIsVisible) throws QueryParseException {
|
||||||
List<Predicate<ChangeData>> r = new ArrayList<>();
|
List<Predicate<ChangeData>> r = new ArrayList<>();
|
||||||
ChangeQueryBuilder builder = new ChangeQueryBuilder(args);
|
ChangeQueryBuilder builder = new ChangeQueryBuilder(args);
|
||||||
@@ -89,7 +89,7 @@ class IsWatchedByPredicate extends AndPredicate<ChangeData> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Collection<ProjectWatchKey> getWatches(ChangeQueryBuilder.Arguments args)
|
protected static Collection<ProjectWatchKey> getWatches(ChangeQueryBuilder.Arguments args)
|
||||||
throws QueryParseException {
|
throws QueryParseException {
|
||||||
CurrentUser user = args.getUser();
|
CurrentUser user = args.getUser();
|
||||||
if (user.isIdentifiedUser()) {
|
if (user.isIdentifiedUser()) {
|
||||||
@@ -98,7 +98,7 @@ class IsWatchedByPredicate extends AndPredicate<ChangeData> {
|
|||||||
return Collections.<ProjectWatchKey>emptySet();
|
return Collections.<ProjectWatchKey>emptySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Predicate<ChangeData>> none() {
|
protected static List<Predicate<ChangeData>> none() {
|
||||||
Predicate<ChangeData> any = any();
|
Predicate<ChangeData> any = any();
|
||||||
return ImmutableList.of(not(any));
|
return ImmutableList.of(not(any));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,19 +33,19 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class LabelPredicate extends OrPredicate<ChangeData> {
|
public class LabelPredicate extends OrPredicate<ChangeData> {
|
||||||
private static final int MAX_LABEL_VALUE = 4;
|
protected static final int MAX_LABEL_VALUE = 4;
|
||||||
|
|
||||||
static class Args {
|
protected static class Args {
|
||||||
final ProjectCache projectCache;
|
protected final ProjectCache projectCache;
|
||||||
final PermissionBackend permissionBackend;
|
protected final PermissionBackend permissionBackend;
|
||||||
final ChangeControl.GenericFactory ccFactory;
|
protected final ChangeControl.GenericFactory ccFactory;
|
||||||
final IdentifiedUser.GenericFactory userFactory;
|
protected final IdentifiedUser.GenericFactory userFactory;
|
||||||
final Provider<ReviewDb> dbProvider;
|
protected final Provider<ReviewDb> dbProvider;
|
||||||
final String value;
|
protected final String value;
|
||||||
final Set<Account.Id> accounts;
|
protected final Set<Account.Id> accounts;
|
||||||
final AccountGroup.UUID group;
|
protected final AccountGroup.UUID group;
|
||||||
|
|
||||||
private Args(
|
protected Args(
|
||||||
ProjectCache projectCache,
|
ProjectCache projectCache,
|
||||||
PermissionBackend permissionBackend,
|
PermissionBackend permissionBackend,
|
||||||
ChangeControl.GenericFactory ccFactory,
|
ChangeControl.GenericFactory ccFactory,
|
||||||
@@ -65,21 +65,21 @@ public class LabelPredicate extends OrPredicate<ChangeData> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Parsed {
|
protected static class Parsed {
|
||||||
private final String label;
|
protected final String label;
|
||||||
private final String test;
|
protected final String test;
|
||||||
private final int expVal;
|
protected final int expVal;
|
||||||
|
|
||||||
private Parsed(String label, String test, int expVal) {
|
protected Parsed(String label, String test, int expVal) {
|
||||||
this.label = label;
|
this.label = label;
|
||||||
this.test = test;
|
this.test = test;
|
||||||
this.expVal = expVal;
|
this.expVal = expVal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String value;
|
protected final String value;
|
||||||
|
|
||||||
LabelPredicate(
|
public LabelPredicate(
|
||||||
ChangeQueryBuilder.Arguments a,
|
ChangeQueryBuilder.Arguments a,
|
||||||
String value,
|
String value,
|
||||||
Set<Account.Id> accounts,
|
Set<Account.Id> accounts,
|
||||||
@@ -98,7 +98,7 @@ public class LabelPredicate extends OrPredicate<ChangeData> {
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Predicate<ChangeData>> predicates(Args args) {
|
protected static List<Predicate<ChangeData>> predicates(Args args) {
|
||||||
String v = args.value;
|
String v = args.value;
|
||||||
Parsed parsed = null;
|
Parsed parsed = null;
|
||||||
|
|
||||||
@@ -138,14 +138,14 @@ public class LabelPredicate extends OrPredicate<ChangeData> {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Predicate<ChangeData> onePredicate(Args args, String label, int expVal) {
|
protected static Predicate<ChangeData> onePredicate(Args args, String label, int expVal) {
|
||||||
if (expVal != 0) {
|
if (expVal != 0) {
|
||||||
return equalsLabelPredicate(args, label, expVal);
|
return equalsLabelPredicate(args, label, expVal);
|
||||||
}
|
}
|
||||||
return noLabelQuery(args, label);
|
return noLabelQuery(args, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Predicate<ChangeData> noLabelQuery(Args args, String label) {
|
protected static Predicate<ChangeData> noLabelQuery(Args args, String label) {
|
||||||
List<Predicate<ChangeData>> r = Lists.newArrayListWithCapacity(2 * MAX_LABEL_VALUE);
|
List<Predicate<ChangeData>> r = Lists.newArrayListWithCapacity(2 * MAX_LABEL_VALUE);
|
||||||
for (int i = 1; i <= MAX_LABEL_VALUE; i++) {
|
for (int i = 1; i <= MAX_LABEL_VALUE; i++) {
|
||||||
r.add(equalsLabelPredicate(args, label, i));
|
r.add(equalsLabelPredicate(args, label, i));
|
||||||
@@ -154,7 +154,7 @@ public class LabelPredicate extends OrPredicate<ChangeData> {
|
|||||||
return not(or(r));
|
return not(or(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Predicate<ChangeData> equalsLabelPredicate(Args args, String label, int expVal) {
|
protected static Predicate<ChangeData> equalsLabelPredicate(Args args, String label, int expVal) {
|
||||||
if (args.accounts == null || args.accounts.isEmpty()) {
|
if (args.accounts == null || args.accounts.isEmpty()) {
|
||||||
return new EqualsLabelPredicate(args, label, expVal, null);
|
return new EqualsLabelPredicate(args, label, expVal, null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import com.google.gerrit.reviewdb.client.Change;
|
|||||||
|
|
||||||
/** Predicate over change number (aka legacy ID or Change.Id). */
|
/** Predicate over change number (aka legacy ID or Change.Id). */
|
||||||
public class LegacyChangeIdPredicate extends ChangeIndexPredicate {
|
public class LegacyChangeIdPredicate extends ChangeIndexPredicate {
|
||||||
private final Change.Id id;
|
protected final Change.Id id;
|
||||||
|
|
||||||
public LegacyChangeIdPredicate(Change.Id id) {
|
public LegacyChangeIdPredicate(Change.Id id) {
|
||||||
super(LEGACY_ID, ChangeQueryBuilder.FIELD_CHANGE, id.toString());
|
super(LEGACY_ID, ChangeQueryBuilder.FIELD_CHANGE, id.toString());
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ import com.google.gerrit.server.query.QueryParseException;
|
|||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
/** Predicate to match changes that contains specified text in commit messages body. */
|
/** Predicate to match changes that contains specified text in commit messages body. */
|
||||||
class MessagePredicate extends ChangeIndexPredicate {
|
public class MessagePredicate extends ChangeIndexPredicate {
|
||||||
private final ChangeIndex index;
|
protected final ChangeIndex index;
|
||||||
|
|
||||||
MessagePredicate(ChangeIndex index, String value) {
|
public MessagePredicate(ChangeIndex index, String value) {
|
||||||
super(ChangeField.COMMIT_MESSAGE, value);
|
super(ChangeField.COMMIT_MESSAGE, value);
|
||||||
this.index = index;
|
this.index = index;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,15 +19,15 @@ import com.google.gerrit.reviewdb.client.Change;
|
|||||||
import com.google.gerrit.server.index.change.ChangeField;
|
import com.google.gerrit.server.index.change.ChangeField;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
class OwnerPredicate extends ChangeIndexPredicate {
|
public class OwnerPredicate extends ChangeIndexPredicate {
|
||||||
private final Account.Id id;
|
protected final Account.Id id;
|
||||||
|
|
||||||
OwnerPredicate(Account.Id id) {
|
public OwnerPredicate(Account.Id id) {
|
||||||
super(ChangeField.OWNER, id.toString());
|
super(ChangeField.OWNER, id.toString());
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
Account.Id getAccountId() {
|
protected Account.Id getAccountId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,17 +19,17 @@ import com.google.gerrit.reviewdb.client.Change;
|
|||||||
import com.google.gerrit.server.IdentifiedUser;
|
import com.google.gerrit.server.IdentifiedUser;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
class OwnerinPredicate extends ChangeOperatorPredicate {
|
public class OwnerinPredicate extends ChangeOperatorPredicate {
|
||||||
private final IdentifiedUser.GenericFactory userFactory;
|
protected final IdentifiedUser.GenericFactory userFactory;
|
||||||
private final AccountGroup.UUID uuid;
|
protected final AccountGroup.UUID uuid;
|
||||||
|
|
||||||
OwnerinPredicate(IdentifiedUser.GenericFactory userFactory, AccountGroup.UUID uuid) {
|
public OwnerinPredicate(IdentifiedUser.GenericFactory userFactory, AccountGroup.UUID uuid) {
|
||||||
super(ChangeQueryBuilder.FIELD_OWNERIN, uuid.toString());
|
super(ChangeQueryBuilder.FIELD_OWNERIN, uuid.toString());
|
||||||
this.userFactory = userFactory;
|
this.userFactory = userFactory;
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountGroup.UUID getAccountGroupUUID() {
|
protected AccountGroup.UUID getAccountGroupUUID() {
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,10 +28,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
class ParentProjectPredicate extends OrPredicate<ChangeData> {
|
public class ParentProjectPredicate extends OrPredicate<ChangeData> {
|
||||||
private final String value;
|
protected final String value;
|
||||||
|
|
||||||
ParentProjectPredicate(
|
public ParentProjectPredicate(
|
||||||
ProjectCache projectCache,
|
ProjectCache projectCache,
|
||||||
Provider<ListChildProjects> listChildProjects,
|
Provider<ListChildProjects> listChildProjects,
|
||||||
Provider<CurrentUser> self,
|
Provider<CurrentUser> self,
|
||||||
@@ -40,7 +40,7 @@ class ParentProjectPredicate extends OrPredicate<ChangeData> {
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Predicate<ChangeData>> predicates(
|
protected static List<Predicate<ChangeData>> predicates(
|
||||||
ProjectCache projectCache,
|
ProjectCache projectCache,
|
||||||
Provider<ListChildProjects> listChildProjects,
|
Provider<ListChildProjects> listChildProjects,
|
||||||
Provider<CurrentUser> self,
|
Provider<CurrentUser> self,
|
||||||
|
|||||||
@@ -19,12 +19,12 @@ import com.google.gerrit.reviewdb.client.Project;
|
|||||||
import com.google.gerrit.server.index.change.ChangeField;
|
import com.google.gerrit.server.index.change.ChangeField;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
class ProjectPredicate extends ChangeIndexPredicate {
|
public class ProjectPredicate extends ChangeIndexPredicate {
|
||||||
ProjectPredicate(String id) {
|
public ProjectPredicate(String id) {
|
||||||
super(ChangeField.PROJECT, id);
|
super(ChangeField.PROJECT, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
Project.NameKey getValueKey() {
|
protected Project.NameKey getValueKey() {
|
||||||
return new Project.NameKey(getValue());
|
return new Project.NameKey(getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ import com.google.gerrit.reviewdb.client.Change;
|
|||||||
import com.google.gerrit.server.index.change.ChangeField;
|
import com.google.gerrit.server.index.change.ChangeField;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
class ProjectPrefixPredicate extends ChangeIndexPredicate {
|
public class ProjectPrefixPredicate extends ChangeIndexPredicate {
|
||||||
ProjectPrefixPredicate(String prefix) {
|
public ProjectPrefixPredicate(String prefix) {
|
||||||
super(ChangeField.PROJECTS, prefix);
|
super(ChangeField.PROJECTS, prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ import com.google.gerrit.reviewdb.client.Change;
|
|||||||
import com.google.gerrit.server.index.change.ChangeField;
|
import com.google.gerrit.server.index.change.ChangeField;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
class RefPredicate extends ChangeIndexPredicate {
|
public class RefPredicate extends ChangeIndexPredicate {
|
||||||
RefPredicate(String ref) {
|
public RefPredicate(String ref) {
|
||||||
super(ChangeField.REF, ref);
|
super(ChangeField.REF, ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ import com.google.gerrit.server.util.RegexListSearcher;
|
|||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
class RegexPathPredicate extends ChangeRegexPredicate {
|
public class RegexPathPredicate extends ChangeRegexPredicate {
|
||||||
RegexPathPredicate(String re) {
|
public RegexPathPredicate(String re) {
|
||||||
super(ChangeField.PATH, re);
|
super(ChangeField.PATH, re);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ import com.google.gwtorm.server.OrmException;
|
|||||||
import dk.brics.automaton.RegExp;
|
import dk.brics.automaton.RegExp;
|
||||||
import dk.brics.automaton.RunAutomaton;
|
import dk.brics.automaton.RunAutomaton;
|
||||||
|
|
||||||
class RegexProjectPredicate extends ChangeRegexPredicate {
|
public class RegexProjectPredicate extends ChangeRegexPredicate {
|
||||||
private final RunAutomaton pattern;
|
protected final RunAutomaton pattern;
|
||||||
|
|
||||||
RegexProjectPredicate(String re) {
|
public RegexProjectPredicate(String re) {
|
||||||
super(ChangeField.PROJECT, re);
|
super(ChangeField.PROJECT, re);
|
||||||
|
|
||||||
if (re.startsWith("^")) {
|
if (re.startsWith("^")) {
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ import com.google.gwtorm.server.OrmException;
|
|||||||
import dk.brics.automaton.RegExp;
|
import dk.brics.automaton.RegExp;
|
||||||
import dk.brics.automaton.RunAutomaton;
|
import dk.brics.automaton.RunAutomaton;
|
||||||
|
|
||||||
class RegexRefPredicate extends ChangeRegexPredicate {
|
public class RegexRefPredicate extends ChangeRegexPredicate {
|
||||||
private final RunAutomaton pattern;
|
protected final RunAutomaton pattern;
|
||||||
|
|
||||||
RegexRefPredicate(String re) {
|
public RegexRefPredicate(String re) {
|
||||||
super(ChangeField.REF, re);
|
super(ChangeField.REF, re);
|
||||||
|
|
||||||
if (re.startsWith("^")) {
|
if (re.startsWith("^")) {
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ import com.google.gwtorm.server.OrmException;
|
|||||||
import dk.brics.automaton.RegExp;
|
import dk.brics.automaton.RegExp;
|
||||||
import dk.brics.automaton.RunAutomaton;
|
import dk.brics.automaton.RunAutomaton;
|
||||||
|
|
||||||
class RegexTopicPredicate extends ChangeRegexPredicate {
|
public class RegexTopicPredicate extends ChangeRegexPredicate {
|
||||||
private final RunAutomaton pattern;
|
protected final RunAutomaton pattern;
|
||||||
|
|
||||||
RegexTopicPredicate(String re) {
|
public RegexTopicPredicate(String re) {
|
||||||
super(EXACT_TOPIC, re);
|
super(EXACT_TOPIC, re);
|
||||||
|
|
||||||
if (re.startsWith("^")) {
|
if (re.startsWith("^")) {
|
||||||
|
|||||||
@@ -25,14 +25,14 @@ import com.google.gerrit.server.query.change.ChangeQueryBuilder.Arguments;
|
|||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
class ReviewerPredicate extends ChangeIndexPredicate {
|
public class ReviewerPredicate extends ChangeIndexPredicate {
|
||||||
static Predicate<ChangeData> forState(
|
protected static Predicate<ChangeData> forState(
|
||||||
Arguments args, Account.Id id, ReviewerStateInternal state) {
|
Arguments args, Account.Id id, ReviewerStateInternal state) {
|
||||||
checkArgument(state != ReviewerStateInternal.REMOVED, "can't query by removed reviewer");
|
checkArgument(state != ReviewerStateInternal.REMOVED, "can't query by removed reviewer");
|
||||||
return create(args, new ReviewerPredicate(state, id));
|
return create(args, new ReviewerPredicate(state, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Predicate<ChangeData> reviewer(Arguments args, Account.Id id) {
|
protected static Predicate<ChangeData> reviewer(Arguments args, Account.Id id) {
|
||||||
Predicate<ChangeData> p;
|
Predicate<ChangeData> p;
|
||||||
if (args.notesMigration.readChanges()) {
|
if (args.notesMigration.readChanges()) {
|
||||||
// With NoteDb, Reviewer/CC are clearly distinct states, so only choose reviewer.
|
// With NoteDb, Reviewer/CC are clearly distinct states, so only choose reviewer.
|
||||||
@@ -45,14 +45,14 @@ class ReviewerPredicate extends ChangeIndexPredicate {
|
|||||||
return create(args, p);
|
return create(args, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Predicate<ChangeData> cc(Arguments args, Account.Id id) {
|
protected static Predicate<ChangeData> cc(Arguments args, Account.Id id) {
|
||||||
// As noted above, CC is nebulous without NoteDb, but it certainly doesn't make sense to return
|
// As noted above, CC is nebulous without NoteDb, but it certainly doesn't make sense to return
|
||||||
// Reviewers for cc:foo. Most likely this will just not match anything, but let the index sort
|
// Reviewers for cc:foo. Most likely this will just not match anything, but let the index sort
|
||||||
// it out.
|
// it out.
|
||||||
return create(args, new ReviewerPredicate(ReviewerStateInternal.CC, id));
|
return create(args, new ReviewerPredicate(ReviewerStateInternal.CC, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Predicate<ChangeData> anyReviewerState(Account.Id id) {
|
protected static Predicate<ChangeData> anyReviewerState(Account.Id id) {
|
||||||
return Predicate.or(
|
return Predicate.or(
|
||||||
Stream.of(ReviewerStateInternal.values())
|
Stream.of(ReviewerStateInternal.values())
|
||||||
.filter(s -> s != ReviewerStateInternal.REMOVED)
|
.filter(s -> s != ReviewerStateInternal.REMOVED)
|
||||||
@@ -60,8 +60,8 @@ class ReviewerPredicate extends ChangeIndexPredicate {
|
|||||||
.collect(toList()));
|
.collect(toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ReviewerStateInternal state;
|
protected final ReviewerStateInternal state;
|
||||||
private final Account.Id id;
|
protected final Account.Id id;
|
||||||
|
|
||||||
private ReviewerPredicate(ReviewerStateInternal state, Account.Id id) {
|
private ReviewerPredicate(ReviewerStateInternal state, Account.Id id) {
|
||||||
super(ChangeField.REVIEWER, ChangeField.getReviewerFieldValue(state, id));
|
super(ChangeField.REVIEWER, ChangeField.getReviewerFieldValue(state, id));
|
||||||
@@ -69,7 +69,7 @@ class ReviewerPredicate extends ChangeIndexPredicate {
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
Account.Id getAccountId() {
|
protected Account.Id getAccountId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,17 +19,17 @@ import com.google.gerrit.reviewdb.client.AccountGroup;
|
|||||||
import com.google.gerrit.server.IdentifiedUser;
|
import com.google.gerrit.server.IdentifiedUser;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
class ReviewerinPredicate extends ChangeOperatorPredicate {
|
public class ReviewerinPredicate extends ChangeOperatorPredicate {
|
||||||
private final IdentifiedUser.GenericFactory userFactory;
|
protected final IdentifiedUser.GenericFactory userFactory;
|
||||||
private final AccountGroup.UUID uuid;
|
protected final AccountGroup.UUID uuid;
|
||||||
|
|
||||||
ReviewerinPredicate(IdentifiedUser.GenericFactory userFactory, AccountGroup.UUID uuid) {
|
public ReviewerinPredicate(IdentifiedUser.GenericFactory userFactory, AccountGroup.UUID uuid) {
|
||||||
super(ChangeQueryBuilder.FIELD_REVIEWERIN, uuid.toString());
|
super(ChangeQueryBuilder.FIELD_REVIEWERIN, uuid.toString());
|
||||||
this.userFactory = userFactory;
|
this.userFactory = userFactory;
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountGroup.UUID getAccountGroupUUID() {
|
protected AccountGroup.UUID getAccountGroupUUID() {
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ import com.google.gerrit.server.index.change.ChangeField;
|
|||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
public class StarPredicate extends ChangeIndexPredicate {
|
public class StarPredicate extends ChangeIndexPredicate {
|
||||||
private final Account.Id accountId;
|
protected final Account.Id accountId;
|
||||||
private final String label;
|
protected final String label;
|
||||||
|
|
||||||
StarPredicate(Account.Id accountId, String label) {
|
public StarPredicate(Account.Id accountId, String label) {
|
||||||
super(ChangeField.STAR, StarredChangesUtil.StarField.create(accountId, label).toString());
|
super(ChangeField.STAR, StarredChangesUtil.StarField.create(accountId, label).toString());
|
||||||
this.accountId = accountId;
|
this.accountId = accountId;
|
||||||
this.label = label;
|
this.label = label;
|
||||||
|
|||||||
@@ -18,9 +18,8 @@ import com.google.gerrit.reviewdb.client.Change;
|
|||||||
import com.google.gerrit.server.index.change.ChangeField;
|
import com.google.gerrit.server.index.change.ChangeField;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
class SubmissionIdPredicate extends ChangeIndexPredicate {
|
public class SubmissionIdPredicate extends ChangeIndexPredicate {
|
||||||
|
public SubmissionIdPredicate(String changeSet) {
|
||||||
SubmissionIdPredicate(String changeSet) {
|
|
||||||
super(ChangeField.SUBMISSIONID, changeSet);
|
super(ChangeField.SUBMISSIONID, changeSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ import com.google.gerrit.server.query.Predicate;
|
|||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
class SubmitRecordPredicate extends ChangeIndexPredicate {
|
public class SubmitRecordPredicate extends ChangeIndexPredicate {
|
||||||
static Predicate<ChangeData> create(
|
public static Predicate<ChangeData> create(
|
||||||
String label, SubmitRecord.Label.Status status, Set<Account.Id> accounts) {
|
String label, SubmitRecord.Label.Status status, Set<Account.Id> accounts) {
|
||||||
String lowerLabel = label.toLowerCase();
|
String lowerLabel = label.toLowerCase();
|
||||||
if (accounts == null || accounts.isEmpty()) {
|
if (accounts == null || accounts.isEmpty()) {
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ import com.google.gerrit.common.data.SubmitRecord;
|
|||||||
import com.google.gerrit.server.index.change.ChangeField;
|
import com.google.gerrit.server.index.change.ChangeField;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
class SubmittablePredicate extends ChangeIndexPredicate {
|
public class SubmittablePredicate extends ChangeIndexPredicate {
|
||||||
private final SubmitRecord.Status status;
|
protected final SubmitRecord.Status status;
|
||||||
|
|
||||||
SubmittablePredicate(SubmitRecord.Status status) {
|
public SubmittablePredicate(SubmitRecord.Status status) {
|
||||||
super(ChangeField.SUBMIT_RECORD, status.name());
|
super(ChangeField.SUBMIT_RECORD, status.name());
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,12 +24,12 @@ import org.eclipse.jgit.revwalk.FooterLine;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
class TrackingIdPredicate extends ChangeIndexPredicate {
|
public class TrackingIdPredicate extends ChangeIndexPredicate {
|
||||||
private static final Logger log = LoggerFactory.getLogger(TrackingIdPredicate.class);
|
private static final Logger log = LoggerFactory.getLogger(TrackingIdPredicate.class);
|
||||||
|
|
||||||
private final TrackingFooters trackingFooters;
|
protected final TrackingFooters trackingFooters;
|
||||||
|
|
||||||
TrackingIdPredicate(TrackingFooters trackingFooters, String trackingId) {
|
public TrackingIdPredicate(TrackingFooters trackingFooters, String trackingId) {
|
||||||
super(ChangeField.TR, trackingId);
|
super(ChangeField.TR, trackingId);
|
||||||
this.trackingFooters = trackingFooters;
|
this.trackingFooters = trackingFooters;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,10 +23,11 @@ import com.google.gerrit.server.query.account.AccountQueryBuilder;
|
|||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
public class GroupIsVisibleToPredicate extends IsVisibleToPredicate<AccountGroup> {
|
public class GroupIsVisibleToPredicate extends IsVisibleToPredicate<AccountGroup> {
|
||||||
private final GroupControl.GenericFactory groupControlFactory;
|
protected final GroupControl.GenericFactory groupControlFactory;
|
||||||
private final CurrentUser user;
|
protected final CurrentUser user;
|
||||||
|
|
||||||
GroupIsVisibleToPredicate(GroupControl.GenericFactory groupControlFactory, CurrentUser user) {
|
public GroupIsVisibleToPredicate(
|
||||||
|
GroupControl.GenericFactory groupControlFactory, CurrentUser user) {
|
||||||
super(AccountQueryBuilder.FIELD_VISIBLETO, describe(user));
|
super(AccountQueryBuilder.FIELD_VISIBLETO, describe(user));
|
||||||
this.groupControlFactory = groupControlFactory;
|
this.groupControlFactory = groupControlFactory;
|
||||||
this.user = user;
|
this.user = user;
|
||||||
|
|||||||
Reference in New Issue
Block a user