Move ChangeKind to PatchSetAttribute
When adding the ChangeKind for JSON data, I added it into PatchSetCreatedEvent which ended up being a pretty lousy place to add it, since it has little to do with the event, and more to do with the PatchSetAttribute itself. This moves the data to the PatchSet JSON structure, alongside the draft attribute. Change-Id: Ia3791789af2ddb6efc70d78f38595519b5d6ab5f
This commit is contained in:
@@ -30,7 +30,6 @@ import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.account.AccountCache;
|
||||
import com.google.gerrit.server.account.AccountState;
|
||||
import com.google.gerrit.server.change.ChangeKindCache;
|
||||
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.gerrit.server.config.SitePaths;
|
||||
@@ -210,8 +209,6 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
||||
|
||||
private final AccountCache accountCache;
|
||||
|
||||
private final ChangeKindCache changeKindCache;
|
||||
|
||||
private final EventFactory eventFactory;
|
||||
|
||||
private final SitePaths sitePaths;
|
||||
@@ -239,7 +236,6 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
||||
final SitePaths sitePath,
|
||||
final ProjectCache projectCache,
|
||||
final AccountCache accountCache,
|
||||
final ChangeKindCache changeKindCache,
|
||||
final EventFactory eventFactory,
|
||||
final SitePaths sitePaths,
|
||||
final DynamicSet<ChangeListener> unrestrictedListeners) {
|
||||
@@ -248,7 +244,6 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
||||
this.hookQueue = queue.createQueue(1, "hook");
|
||||
this.projectCache = projectCache;
|
||||
this.accountCache = accountCache;
|
||||
this.changeKindCache = changeKindCache;
|
||||
this.eventFactory = eventFactory;
|
||||
this.sitePaths = sitePath;
|
||||
this.unrestrictedListeners = unrestrictedListeners;
|
||||
@@ -359,13 +354,12 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
||||
event.change = eventFactory.asChangeAttribute(change);
|
||||
event.patchSet = eventFactory.asPatchSetAttribute(patchSet);
|
||||
event.uploader = eventFactory.asAccountAttribute(uploader.getAccount());
|
||||
event.kind = changeKindCache.getChangeKind(db, change, patchSet);
|
||||
fireEvent(change, event, db);
|
||||
|
||||
final List<String> args = new ArrayList<>();
|
||||
addArg(args, "--change", event.change.id);
|
||||
addArg(args, "--is-draft", String.valueOf(patchSet.isDraft()));
|
||||
addArg(args, "--kind", String.valueOf(event.kind));
|
||||
addArg(args, "--kind", String.valueOf(event.patchSet.kind));
|
||||
addArg(args, "--change-url", event.change.url);
|
||||
addArg(args, "--change-owner", getDisplayName(owner.getAccount()));
|
||||
addArg(args, "--project", event.change.project);
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
|
||||
package com.google.gerrit.server.data;
|
||||
|
||||
import com.google.gerrit.server.change.ChangeKind;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PatchSetAttribute {
|
||||
@@ -25,6 +27,7 @@ public class PatchSetAttribute {
|
||||
public Long createdOn;
|
||||
public AccountAttribute author;
|
||||
public boolean isDraft;
|
||||
public ChangeKind kind;
|
||||
|
||||
public List<ApprovalAttribute> approvals;
|
||||
public List<PatchSetCommentAttribute> comments;
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.ApprovalsUtil;
|
||||
import com.google.gerrit.server.GerritPersonIdent;
|
||||
import com.google.gerrit.server.account.AccountCache;
|
||||
import com.google.gerrit.server.change.ChangeKindCache;
|
||||
import com.google.gerrit.server.config.CanonicalWebUrl;
|
||||
import com.google.gerrit.server.data.AccountAttribute;
|
||||
import com.google.gerrit.server.data.ApprovalAttribute;
|
||||
@@ -84,6 +85,7 @@ public class EventFactory {
|
||||
private final Provider<ReviewDb> db;
|
||||
private final ChangeData.Factory changeDataFactory;
|
||||
private final ApprovalsUtil approvalsUtil;
|
||||
private final ChangeKindCache changeKindCache;
|
||||
|
||||
@Inject
|
||||
EventFactory(AccountCache accountCache,
|
||||
@@ -93,7 +95,8 @@ public class EventFactory {
|
||||
@GerritPersonIdent PersonIdent myIdent,
|
||||
Provider<ReviewDb> db,
|
||||
ChangeData.Factory changeDataFactory,
|
||||
ApprovalsUtil approvalsUtil) {
|
||||
ApprovalsUtil approvalsUtil,
|
||||
ChangeKindCache changeKindCache) {
|
||||
this.accountCache = accountCache;
|
||||
this.urlProvider = urlProvider;
|
||||
this.patchListCache = patchListCache;
|
||||
@@ -103,6 +106,7 @@ public class EventFactory {
|
||||
this.db = db;
|
||||
this.changeDataFactory = changeDataFactory;
|
||||
this.approvalsUtil = approvalsUtil;
|
||||
this.changeKindCache = changeKindCache;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -426,6 +430,7 @@ public class EventFactory {
|
||||
p.sizeInsertions += pe.getInsertions();
|
||||
}
|
||||
}
|
||||
p.kind = changeKindCache.getChangeKind(db, change, patchSet);
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
package com.google.gerrit.server.events;
|
||||
|
||||
import com.google.gerrit.server.change.ChangeKind;
|
||||
import com.google.gerrit.server.data.AccountAttribute;
|
||||
import com.google.gerrit.server.data.ChangeAttribute;
|
||||
import com.google.gerrit.server.data.PatchSetAttribute;
|
||||
@@ -24,5 +23,4 @@ public class PatchSetCreatedEvent extends ChangeEvent {
|
||||
public ChangeAttribute change;
|
||||
public PatchSetAttribute patchSet;
|
||||
public AccountAttribute uploader;
|
||||
public ChangeKind kind;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user