Remove most remaining references to ApprovalCategory(Value)
These classes should only be used in code directly interfacing with the ReviewDb layer. For things like map keys, use label names or IDs as appropriate (and document it to avoid confusion). Change-Id: I1471725220eda63b4668d5c623ff7b984fd0a46b
This commit is contained in:
@@ -17,35 +17,30 @@ package com.google.gerrit.client;
|
|||||||
import com.google.gwt.resources.client.CssResource;
|
import com.google.gwt.resources.client.CssResource;
|
||||||
|
|
||||||
public interface GerritCss extends CssResource {
|
public interface GerritCss extends CssResource {
|
||||||
String greenCheckClass();
|
|
||||||
String accountContactOnFile();
|
String accountContactOnFile();
|
||||||
String accountContactPrivacyDetails();
|
String accountContactPrivacyDetails();
|
||||||
String accountDashboard();
|
String accountDashboard();
|
||||||
String accountInfoBlock();
|
String accountInfoBlock();
|
||||||
String accountName();
|
String accountName();
|
||||||
String accountUsername();
|
|
||||||
String accountPassword();
|
String accountPassword();
|
||||||
|
String accountUsername();
|
||||||
String activeRow();
|
String activeRow();
|
||||||
String fileCommentBorder();
|
String addBranch();
|
||||||
String addMemberTextBox();
|
String addMemberTextBox();
|
||||||
String addReviewer();
|
String addReviewer();
|
||||||
String removeReviewer();
|
|
||||||
String removeReviewerCell();
|
|
||||||
String addBranch();
|
|
||||||
String addSshKeyPanel();
|
String addSshKeyPanel();
|
||||||
String addWatchPanel();
|
String addWatchPanel();
|
||||||
String approvalCategoryList();
|
|
||||||
String approvalTable();
|
String approvalTable();
|
||||||
String approvalhint();
|
String approvalhint();
|
||||||
String approvalrole();
|
String approvalrole();
|
||||||
String approvalscore();
|
String approvalscore();
|
||||||
String notVotable();
|
|
||||||
String blockHeader();
|
String blockHeader();
|
||||||
String bottomheader();
|
String bottomheader();
|
||||||
String cAPPROVAL();
|
String cAPPROVAL();
|
||||||
String cLastUpdate();
|
String cLastUpdate();
|
||||||
String cSUBJECT();
|
|
||||||
String cOWNER();
|
String cOWNER();
|
||||||
|
String cSUBJECT();
|
||||||
|
String cellsNextToFileComment();
|
||||||
String changeComments();
|
String changeComments();
|
||||||
String changeInfoBlock();
|
String changeInfoBlock();
|
||||||
String changeInfoTopicPanel();
|
String changeInfoTopicPanel();
|
||||||
@@ -57,25 +52,24 @@ public interface GerritCss extends CssResource {
|
|||||||
String changeTypeCell();
|
String changeTypeCell();
|
||||||
String changeid();
|
String changeid();
|
||||||
String closedstate();
|
String closedstate();
|
||||||
String cellsNextToFileComment();
|
|
||||||
String commentedActionDialog();
|
|
||||||
String commentedActionMessage();
|
|
||||||
String commentCell();
|
String commentCell();
|
||||||
String commentEditorPanel();
|
String commentEditorPanel();
|
||||||
String commentHolder();
|
String commentHolder();
|
||||||
String commentHolderLeftmost();
|
String commentHolderLeftmost();
|
||||||
String commentPanel();
|
String commentPanel();
|
||||||
String commentPanelBorder();
|
|
||||||
String commentPanelAuthorCell();
|
String commentPanelAuthorCell();
|
||||||
|
String commentPanelBorder();
|
||||||
String commentPanelButtons();
|
String commentPanelButtons();
|
||||||
String commentPanelContent();
|
String commentPanelContent();
|
||||||
String commentPanelDateCell();
|
String commentPanelDateCell();
|
||||||
String commentPanelHeader();
|
String commentPanelHeader();
|
||||||
String commentPanelLast();
|
String commentPanelLast();
|
||||||
String commentPanelMessage();
|
|
||||||
String commentPanelMenuBar();
|
String commentPanelMenuBar();
|
||||||
|
String commentPanelMessage();
|
||||||
String commentPanelSummary();
|
String commentPanelSummary();
|
||||||
String commentPanelSummaryCell();
|
String commentPanelSummaryCell();
|
||||||
|
String commentedActionDialog();
|
||||||
|
String commentedActionMessage();
|
||||||
String complexHeader();
|
String complexHeader();
|
||||||
String content();
|
String content();
|
||||||
String contributorAgreementAlreadySubmitted();
|
String contributorAgreementAlreadySubmitted();
|
||||||
@@ -89,29 +83,30 @@ public interface GerritCss extends CssResource {
|
|||||||
String dataHeader();
|
String dataHeader();
|
||||||
String diffLinkCell();
|
String diffLinkCell();
|
||||||
String diffText();
|
String diffText();
|
||||||
String diffTextForBinaryInSideBySide();
|
|
||||||
String diffTextCONTEXT();
|
String diffTextCONTEXT();
|
||||||
String diffTextDELETE();
|
String diffTextDELETE();
|
||||||
String diffTextFileHeader();
|
String diffTextFileHeader();
|
||||||
|
String diffTextForBinaryInSideBySide();
|
||||||
String diffTextHunkHeader();
|
String diffTextHunkHeader();
|
||||||
String diffTextINSERT();
|
String diffTextINSERT();
|
||||||
String diffTextNoLF();
|
String diffTextNoLF();
|
||||||
String downloadLink();
|
String downloadLink();
|
||||||
String downloadLink_Active();
|
|
||||||
String downloadLinkListCell();
|
|
||||||
String downloadLinkCopyLabel();
|
String downloadLinkCopyLabel();
|
||||||
String downloadLinkHeader();
|
String downloadLinkHeader();
|
||||||
String downloadLinkHeaderGap();
|
String downloadLinkHeaderGap();
|
||||||
String downloadLinkList();
|
String downloadLinkList();
|
||||||
|
String downloadLinkListCell();
|
||||||
|
String downloadLink_Active();
|
||||||
String drafts();
|
String drafts();
|
||||||
String emptySection();
|
String emptySection();
|
||||||
String errorDialog();
|
String errorDialog();
|
||||||
String errorDialogGlass();
|
|
||||||
String errorDialogTitle();
|
|
||||||
String errorDialogButtons();
|
String errorDialogButtons();
|
||||||
String errorDialogErrorType();
|
String errorDialogErrorType();
|
||||||
|
String errorDialogGlass();
|
||||||
String errorDialogText();
|
String errorDialogText();
|
||||||
|
String errorDialogTitle();
|
||||||
String fileColumnHeader();
|
String fileColumnHeader();
|
||||||
|
String fileCommentBorder();
|
||||||
String fileLine();
|
String fileLine();
|
||||||
String fileLineCONTEXT();
|
String fileLineCONTEXT();
|
||||||
String fileLineDELETE();
|
String fileLineDELETE();
|
||||||
@@ -119,8 +114,9 @@ public interface GerritCss extends CssResource {
|
|||||||
String fileLineMode();
|
String fileLineMode();
|
||||||
String fileLineNone();
|
String fileLineNone();
|
||||||
String filePathCell();
|
String filePathCell();
|
||||||
String gerritTopMenu();
|
|
||||||
String gerritBody();
|
String gerritBody();
|
||||||
|
String gerritTopMenu();
|
||||||
|
String greenCheckClass();
|
||||||
String groupDescriptionPanel();
|
String groupDescriptionPanel();
|
||||||
String groupExternalNameFilterTextBox();
|
String groupExternalNameFilterTextBox();
|
||||||
String groupIncludesTable();
|
String groupIncludesTable();
|
||||||
@@ -143,6 +139,7 @@ public interface GerritCss extends CssResource {
|
|||||||
String infoTable();
|
String infoTable();
|
||||||
String inputFieldTypeHint();
|
String inputFieldTypeHint();
|
||||||
String keyhelp();
|
String keyhelp();
|
||||||
|
String labelList();
|
||||||
String leftMostCell();
|
String leftMostCell();
|
||||||
String lineHeader();
|
String lineHeader();
|
||||||
String lineNumber();
|
String lineNumber();
|
||||||
@@ -162,17 +159,18 @@ public interface GerritCss extends CssResource {
|
|||||||
String negscore();
|
String negscore();
|
||||||
String noLineLineNumber();
|
String noLineLineNumber();
|
||||||
String noborder();
|
String noborder();
|
||||||
|
String notVotable();
|
||||||
String outdated();
|
String outdated();
|
||||||
String parentsTable();
|
String parentsTable();
|
||||||
String patchBrowserPopup();
|
String patchBrowserPopup();
|
||||||
String patchBrowserPopupBody();
|
String patchBrowserPopupBody();
|
||||||
|
String patchCellReverseDiff();
|
||||||
String patchComments();
|
String patchComments();
|
||||||
String patchContentTable();
|
String patchContentTable();
|
||||||
String patchHistoryTable();
|
String patchHistoryTable();
|
||||||
String patchHistoryTablePatchSetHeader();
|
String patchHistoryTablePatchSetHeader();
|
||||||
String patchNoDifference();
|
String patchNoDifference();
|
||||||
String patchScreenDisplayControls();
|
String patchScreenDisplayControls();
|
||||||
String reviewedPanelBottom();
|
|
||||||
String patchSetActions();
|
String patchSetActions();
|
||||||
String patchSetInfoBlock();
|
String patchSetInfoBlock();
|
||||||
String patchSetLink();
|
String patchSetLink();
|
||||||
@@ -181,15 +179,19 @@ public interface GerritCss extends CssResource {
|
|||||||
String patchSizeCell();
|
String patchSizeCell();
|
||||||
String pluginsTable();
|
String pluginsTable();
|
||||||
String posscore();
|
String posscore();
|
||||||
String projectAdminApprovalCategoryRangeLine();
|
String projectAdminLabelRangeLine();
|
||||||
String projectAdminApprovalCategoryValue();
|
String projectAdminLabelValue();
|
||||||
|
String projectFilterLabel();
|
||||||
|
String projectFilterPanel();
|
||||||
String publishCommentsScreen();
|
String publishCommentsScreen();
|
||||||
String registerScreenExplain();
|
String registerScreenExplain();
|
||||||
String registerScreenNextLinks();
|
String registerScreenNextLinks();
|
||||||
String registerScreenSection();
|
String registerScreenSection();
|
||||||
String rightmost();
|
String removeReviewer();
|
||||||
|
String removeReviewerCell();
|
||||||
|
String reviewedPanelBottom();
|
||||||
String rightBorder();
|
String rightBorder();
|
||||||
String sideBySideTableBinaryHeader();
|
String rightmost();
|
||||||
String rpcStatus();
|
String rpcStatus();
|
||||||
String rpcStatusLoading();
|
String rpcStatusLoading();
|
||||||
String rpcStatusPanel();
|
String rpcStatusPanel();
|
||||||
@@ -198,10 +200,10 @@ public interface GerritCss extends CssResource {
|
|||||||
String screenNoHeader();
|
String screenNoHeader();
|
||||||
String searchPanel();
|
String searchPanel();
|
||||||
String sectionHeader();
|
String sectionHeader();
|
||||||
|
String selectPatchSetOldVersion();
|
||||||
String sideBySideScreenLinkTable();
|
String sideBySideScreenLinkTable();
|
||||||
String sideBySideScreenSideBySideTable();
|
String sideBySideScreenSideBySideTable();
|
||||||
String unifiedTable();
|
String sideBySideTableBinaryHeader();
|
||||||
String unifiedTableHeader();
|
|
||||||
String singleLine();
|
String singleLine();
|
||||||
String skipLine();
|
String skipLine();
|
||||||
String smallHeading();
|
String smallHeading();
|
||||||
@@ -214,20 +216,18 @@ public interface GerritCss extends CssResource {
|
|||||||
String sshHostKeyPanelKnownHostEntry();
|
String sshHostKeyPanelKnownHostEntry();
|
||||||
String sshKeyPanelEncodedKey();
|
String sshKeyPanelEncodedKey();
|
||||||
String sshKeyPanelInvalid();
|
String sshKeyPanelInvalid();
|
||||||
|
String topMostCell();
|
||||||
String topmenu();
|
String topmenu();
|
||||||
String topmenuMenuLeft();
|
String topmenuMenuLeft();
|
||||||
String topmenuMenuRight();
|
String topmenuMenuRight();
|
||||||
String topmenuTDglue();
|
String topmenuTDglue();
|
||||||
String topmenuTDmenu();
|
String topmenuTDmenu();
|
||||||
String topmost();
|
String topmost();
|
||||||
String topMostCell();
|
String unifiedTable();
|
||||||
String useridentity();
|
String unifiedTableHeader();
|
||||||
String userInfoPopup();
|
String userInfoPopup();
|
||||||
|
String useridentity();
|
||||||
String usernameField();
|
String usernameField();
|
||||||
String version();
|
String version();
|
||||||
String watchedProjectFilter();
|
String watchedProjectFilter();
|
||||||
String selectPatchSetOldVersion();
|
|
||||||
String patchCellReverseDiff();
|
|
||||||
String projectFilterPanel();
|
|
||||||
String projectFilterLabel();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ public class PublishCommentScreen extends AccountScreen implements
|
|||||||
body.add(new SmallHeading(label.name() + ":"));
|
body.add(new SmallHeading(label.name() + ":"));
|
||||||
|
|
||||||
VerticalPanel vp = new VerticalPanel();
|
VerticalPanel vp = new VerticalPanel();
|
||||||
vp.setStyleName(Gerrit.RESOURCES.css().approvalCategoryList());
|
vp.setStyleName(Gerrit.RESOURCES.css().labelList());
|
||||||
|
|
||||||
Short prior = null;
|
Short prior = null;
|
||||||
if (label.all() != null) {
|
if (label.all() != null) {
|
||||||
|
|||||||
@@ -1344,10 +1344,10 @@ a:hover.downloadLink {
|
|||||||
width: 45em;
|
width: 45em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.projectAdminApprovalCategoryRangeLine {
|
.projectAdminLabelRangeLine {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
.projectAdminApprovalCategoryValue {
|
.projectAdminLabelValue {
|
||||||
font-family: mono-font;
|
font-family: mono-font;
|
||||||
font-size: small;
|
font-size: small;
|
||||||
}
|
}
|
||||||
@@ -1359,7 +1359,7 @@ a:hover.downloadLink {
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
.publishCommentsScreen .approvalCategoryList {
|
.publishCommentsScreen .labelList {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
background: trimColor;
|
background: trimColor;
|
||||||
@@ -1375,7 +1375,7 @@ a:hover.downloadLink {
|
|||||||
.publishCommentsScreen .coverMessage textarea {
|
.publishCommentsScreen .coverMessage textarea {
|
||||||
font-size: small;
|
font-size: small;
|
||||||
}
|
}
|
||||||
.publishCommentsScreen .approvalCategoryList .gwt-RadioButton {
|
.publishCommentsScreen .labelList .gwt-RadioButton {
|
||||||
font-size: smaller;
|
font-size: smaller;
|
||||||
}
|
}
|
||||||
.publishCommentsScreen .patchComments {
|
.publishCommentsScreen .patchComments {
|
||||||
|
|||||||
@@ -21,8 +21,11 @@ import com.google.gwtorm.client.StringKey;
|
|||||||
/** Types of approvals that can be associated with a {@link Change}. */
|
/** Types of approvals that can be associated with a {@link Change}. */
|
||||||
public final class ApprovalCategory {
|
public final class ApprovalCategory {
|
||||||
/** Id of the special "Submit" action (and category). */
|
/** Id of the special "Submit" action (and category). */
|
||||||
public static final ApprovalCategory.Id SUBMIT =
|
public static final String SUBMIT_ID = "SUBM";
|
||||||
new ApprovalCategory.Id("SUBM");
|
|
||||||
|
public static boolean isSubmit(PatchSetApproval a) {
|
||||||
|
return SUBMIT_ID.equals(a.getCategoryId().get());
|
||||||
|
}
|
||||||
|
|
||||||
public static class Id extends StringKey<Key<?>> {
|
public static class Id extends StringKey<Key<?>> {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|||||||
@@ -14,15 +14,13 @@
|
|||||||
|
|
||||||
package com.google.gerrit.common;
|
package com.google.gerrit.common;
|
||||||
|
|
||||||
|
import com.google.gerrit.common.data.ContributorAgreement;
|
||||||
import com.google.gerrit.common.data.LabelType;
|
import com.google.gerrit.common.data.LabelType;
|
||||||
import com.google.gerrit.common.data.LabelTypes;
|
import com.google.gerrit.common.data.LabelTypes;
|
||||||
import com.google.gerrit.common.data.ContributorAgreement;
|
|
||||||
import com.google.gerrit.extensions.events.LifecycleListener;
|
import com.google.gerrit.extensions.events.LifecycleListener;
|
||||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||||
import com.google.gerrit.lifecycle.LifecycleModule;
|
import com.google.gerrit.lifecycle.LifecycleModule;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.reviewdb.client.ApprovalCategory;
|
|
||||||
import com.google.gerrit.reviewdb.client.ApprovalCategoryValue;
|
|
||||||
import com.google.gerrit.reviewdb.client.Branch;
|
import com.google.gerrit.reviewdb.client.Branch;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
@@ -385,8 +383,8 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void doCommentAddedHook(final Change change, final Account account,
|
public void doCommentAddedHook(final Change change, final Account account,
|
||||||
final PatchSet patchSet, final String comment, final Map<ApprovalCategory.Id,
|
final PatchSet patchSet, final String comment, final Map<String, Short> approvals,
|
||||||
ApprovalCategoryValue.Id> approvals, final ReviewDb db) throws OrmException {
|
final ReviewDb db) throws OrmException {
|
||||||
final CommentAddedEvent event = new CommentAddedEvent();
|
final CommentAddedEvent event = new CommentAddedEvent();
|
||||||
|
|
||||||
event.change = eventFactory.asChangeAttribute(change);
|
event.change = eventFactory.asChangeAttribute(change);
|
||||||
@@ -398,7 +396,7 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
|||||||
if (approvals.size() > 0) {
|
if (approvals.size() > 0) {
|
||||||
event.approvals = new ApprovalAttribute[approvals.size()];
|
event.approvals = new ApprovalAttribute[approvals.size()];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Map.Entry<ApprovalCategory.Id, ApprovalCategoryValue.Id> approval : approvals.entrySet()) {
|
for (Map.Entry<String, Short> approval : approvals.entrySet()) {
|
||||||
event.approvals[i++] = getApprovalAttribute(labelTypes, approval);
|
event.approvals[i++] = getApprovalAttribute(labelTypes, approval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -415,8 +413,11 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
|||||||
addArg(args, "--author", getDisplayName(account));
|
addArg(args, "--author", getDisplayName(account));
|
||||||
addArg(args, "--commit", event.patchSet.revision);
|
addArg(args, "--commit", event.patchSet.revision);
|
||||||
addArg(args, "--comment", comment == null ? "" : comment);
|
addArg(args, "--comment", comment == null ? "" : comment);
|
||||||
for (Map.Entry<ApprovalCategory.Id, ApprovalCategoryValue.Id> approval : approvals.entrySet()) {
|
for (Map.Entry<String, Short> approval : approvals.entrySet()) {
|
||||||
addArg(args, "--" + approval.getKey().get(), Short.toString(approval.getValue().get()));
|
LabelType lt = labelTypes.byLabel(approval.getKey());
|
||||||
|
if (lt != null) {
|
||||||
|
addArg(args, "--" + lt.getId(), Short.toString(approval.getValue()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runHook(change.getProject(), commentAddedHook, args);
|
runHook(change.getProject(), commentAddedHook, args);
|
||||||
@@ -614,14 +615,14 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
|||||||
* @return object suitable for serialization to JSON
|
* @return object suitable for serialization to JSON
|
||||||
*/
|
*/
|
||||||
private ApprovalAttribute getApprovalAttribute(LabelTypes labelTypes,
|
private ApprovalAttribute getApprovalAttribute(LabelTypes labelTypes,
|
||||||
Entry<ApprovalCategory.Id, ApprovalCategoryValue.Id> approval) {
|
Entry<String, Short> approval) {
|
||||||
ApprovalAttribute a = new ApprovalAttribute();
|
ApprovalAttribute a = new ApprovalAttribute();
|
||||||
a.type = approval.getKey().get();
|
a.type = approval.getKey();
|
||||||
LabelType lt = labelTypes.byId(approval.getKey().get());
|
LabelType lt = labelTypes.byLabel(approval.getKey());
|
||||||
if (lt != null) {
|
if (lt != null) {
|
||||||
a.description = lt.getName();
|
a.description = lt.getName();
|
||||||
}
|
}
|
||||||
a.value = Short.toString(approval.getValue().get());
|
a.value = Short.toString(approval.getValue());
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,13 +17,11 @@ package com.google.gerrit.common;
|
|||||||
import com.google.gerrit.common.ChangeHookRunner.HookResult;
|
import com.google.gerrit.common.ChangeHookRunner.HookResult;
|
||||||
import com.google.gerrit.common.data.ContributorAgreement;
|
import com.google.gerrit.common.data.ContributorAgreement;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.reviewdb.client.ApprovalCategory;
|
|
||||||
import com.google.gerrit.reviewdb.client.ApprovalCategoryValue;
|
|
||||||
import com.google.gerrit.reviewdb.client.Branch;
|
import com.google.gerrit.reviewdb.client.Branch;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
import com.google.gerrit.server.IdentifiedUser;
|
import com.google.gerrit.server.IdentifiedUser;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
@@ -65,12 +63,12 @@ public interface ChangeHooks {
|
|||||||
* @param patchSet The patchset this comment is related to.
|
* @param patchSet The patchset this comment is related to.
|
||||||
* @param account The gerrit user who added the comment.
|
* @param account The gerrit user who added the comment.
|
||||||
* @param comment The comment given.
|
* @param comment The comment given.
|
||||||
* @param approvals Map of Approval Categories and Scores
|
* @param approvals Map of label IDs to scores
|
||||||
* @throws OrmException
|
* @throws OrmException
|
||||||
*/
|
*/
|
||||||
public void doCommentAddedHook(Change change, Account account,
|
public void doCommentAddedHook(Change change, Account account,
|
||||||
PatchSet patchSet, String comment,
|
PatchSet patchSet, String comment,
|
||||||
Map<ApprovalCategory.Id, ApprovalCategoryValue.Id> approvals, ReviewDb db)
|
Map<String, Short> approvals, ReviewDb db)
|
||||||
throws OrmException;
|
throws OrmException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -17,11 +17,9 @@ package com.google.gerrit.common;
|
|||||||
import com.google.gerrit.common.ChangeHookRunner.HookResult;
|
import com.google.gerrit.common.ChangeHookRunner.HookResult;
|
||||||
import com.google.gerrit.common.data.ContributorAgreement;
|
import com.google.gerrit.common.data.ContributorAgreement;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.reviewdb.client.ApprovalCategory;
|
import com.google.gerrit.reviewdb.client.Branch.NameKey;
|
||||||
import com.google.gerrit.reviewdb.client.ApprovalCategoryValue;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gerrit.reviewdb.client.Branch.NameKey;
|
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
import com.google.gerrit.server.IdentifiedUser;
|
import com.google.gerrit.server.IdentifiedUser;
|
||||||
@@ -64,7 +62,7 @@ public final class DisabledChangeHooks implements ChangeHooks {
|
|||||||
@Override
|
@Override
|
||||||
public void doCommentAddedHook(Change change, Account account,
|
public void doCommentAddedHook(Change change, Account account,
|
||||||
PatchSet patchSet, String comment,
|
PatchSet patchSet, String comment,
|
||||||
Map<ApprovalCategory.Id, ApprovalCategoryValue.Id> approvals, ReviewDb db) {
|
Map<String, Short> approvals, ReviewDb db) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -86,15 +86,12 @@ public class ApprovalsUtil {
|
|||||||
List<PatchSetApproval> patchSetApprovals =
|
List<PatchSetApproval> patchSetApprovals =
|
||||||
db.patchSetApprovals().byChange(dest.getParentKey()).toList();
|
db.patchSetApprovals().byChange(dest.getParentKey()).toList();
|
||||||
for (PatchSetApproval a : patchSetApprovals) {
|
for (PatchSetApproval a : patchSetApprovals) {
|
||||||
// ApprovalCategory.SUBMIT is still in db but not relevant in git-store
|
LabelType type = labelTypes.byId(a.getCategoryId().get());
|
||||||
if (!ApprovalCategory.SUBMIT.equals(a.getCategoryId())) {
|
if (type != null && a.getPatchSetId().equals(source) &&
|
||||||
final LabelType type = labelTypes.byId(a.getCategoryId().get());
|
type.isCopyMinScore() &&
|
||||||
if (a.getPatchSetId().equals(source) &&
|
type.isMaxNegative(a)) {
|
||||||
type.isCopyMinScore() &&
|
db.patchSetApprovals().insert(
|
||||||
type.isMaxNegative(a)) {
|
Collections.singleton(new PatchSetApproval(dest, a)));
|
||||||
db.patchSetApprovals().insert(
|
|
||||||
Collections.singleton(new PatchSetApproval(dest, a)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return patchSetApprovals;
|
return patchSetApprovals;
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import com.google.gerrit.extensions.restapi.DefaultInput;
|
|||||||
import com.google.gerrit.extensions.restapi.RestModifyView;
|
import com.google.gerrit.extensions.restapi.RestModifyView;
|
||||||
import com.google.gerrit.extensions.restapi.Url;
|
import com.google.gerrit.extensions.restapi.Url;
|
||||||
import com.google.gerrit.reviewdb.client.ApprovalCategory;
|
import com.google.gerrit.reviewdb.client.ApprovalCategory;
|
||||||
import com.google.gerrit.reviewdb.client.ApprovalCategoryValue;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
||||||
import com.google.gerrit.reviewdb.client.Patch;
|
import com.google.gerrit.reviewdb.client.Patch;
|
||||||
@@ -110,8 +109,7 @@ public class PostReview implements RestModifyView<RevisionResource, Input> {
|
|||||||
private Timestamp timestamp;
|
private Timestamp timestamp;
|
||||||
private List<PatchLineComment> comments = Lists.newArrayList();
|
private List<PatchLineComment> comments = Lists.newArrayList();
|
||||||
private List<String> labelDelta = Lists.newArrayList();
|
private List<String> labelDelta = Lists.newArrayList();
|
||||||
@Deprecated private Map<ApprovalCategory.Id, ApprovalCategoryValue.Id> categories
|
private Map<String, Short> categories = Maps.newHashMap();
|
||||||
= Maps.newHashMap();
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
PostReview(ReviewDb db,
|
PostReview(ReviewDb db,
|
||||||
@@ -366,9 +364,7 @@ public class PostReview implements RestModifyView<RevisionResource, Input> {
|
|||||||
c.cache(change);
|
c.cache(change);
|
||||||
upd.add(c);
|
upd.add(c);
|
||||||
labelDelta.add(format(name, c.getValue()));
|
labelDelta.add(format(name, c.getValue()));
|
||||||
categories.put(
|
categories.put(name, c.getValue());
|
||||||
lt.getApprovalCategoryId(),
|
|
||||||
lt.getApprovalCategoryValueId(c.getValue()));
|
|
||||||
} else if (c != null && c.getValue() == ent.getValue()) {
|
} else if (c != null && c.getValue() == ent.getValue()) {
|
||||||
current.put(name, c);
|
current.put(name, c);
|
||||||
} else if (c == null) {
|
} else if (c == null) {
|
||||||
@@ -381,9 +377,7 @@ public class PostReview implements RestModifyView<RevisionResource, Input> {
|
|||||||
c.cache(change);
|
c.cache(change);
|
||||||
ins.add(c);
|
ins.add(c);
|
||||||
labelDelta.add(format(name, c.getValue()));
|
labelDelta.add(format(name, c.getValue()));
|
||||||
categories.put(
|
categories.put(name, c.getValue());
|
||||||
lt.getApprovalCategoryId(),
|
|
||||||
lt.getApprovalCategoryValueId(c.getValue()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -430,7 +424,7 @@ public class PostReview implements RestModifyView<RevisionResource, Input> {
|
|||||||
Map<String, PatchSetApproval> current = Maps.newHashMap();
|
Map<String, PatchSetApproval> current = Maps.newHashMap();
|
||||||
for (PatchSetApproval a : db.patchSetApprovals().byPatchSetUser(
|
for (PatchSetApproval a : db.patchSetApprovals().byPatchSetUser(
|
||||||
rsrc.getPatchSet().getId(), rsrc.getAccountId())) {
|
rsrc.getPatchSet().getId(), rsrc.getAccountId())) {
|
||||||
if (ApprovalCategory.SUBMIT.equals(a.getCategoryId())) {
|
if (ApprovalCategory.SUBMIT_ID.equals(a.getCategoryId().get())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ public class Submit implements RestModifyView<RevisionResource, Input> {
|
|||||||
new Predicate<PatchSetApproval>() {
|
new Predicate<PatchSetApproval>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(PatchSetApproval input) {
|
public boolean apply(PatchSetApproval input) {
|
||||||
return ApprovalCategory.SUBMIT.equals(input.getCategoryId());
|
return ApprovalCategory.SUBMIT_ID.equals(input.getCategoryId().get());
|
||||||
}
|
}
|
||||||
}), null);
|
}), null);
|
||||||
if (submit == null) {
|
if (submit == null) {
|
||||||
@@ -195,7 +195,7 @@ public class Submit implements RestModifyView<RevisionResource, Input> {
|
|||||||
new PatchSetApproval.Key(
|
new PatchSetApproval.Key(
|
||||||
rev.getId(),
|
rev.getId(),
|
||||||
caller.getAccountId(),
|
caller.getAccountId(),
|
||||||
ApprovalCategory.SUBMIT),
|
new ApprovalCategory.Id(ApprovalCategory.SUBMIT_ID)),
|
||||||
(short) 1);
|
(short) 1);
|
||||||
}
|
}
|
||||||
submit.setValue((short) 1);
|
submit.setValue((short) 1);
|
||||||
|
|||||||
@@ -939,7 +939,7 @@ public class MergeOp {
|
|||||||
}
|
}
|
||||||
for (PatchSetApproval a : approvals) {
|
for (PatchSetApproval a : approvals) {
|
||||||
if (a.getValue() > 0
|
if (a.getValue() > 0
|
||||||
&& ApprovalCategory.SUBMIT.equals(a.getCategoryId())
|
&& ApprovalCategory.SUBMIT_ID.equals(a.getCategoryId().get())
|
||||||
&& a.getPatchSetId().equals(merged)) {
|
&& a.getPatchSetId().equals(merged)) {
|
||||||
if (submitter == null
|
if (submitter == null
|
||||||
|| a.getGranted().compareTo(submitter.getGranted()) > 0) {
|
|| a.getGranted().compareTo(submitter.getGranted()) > 0) {
|
||||||
|
|||||||
@@ -82,10 +82,8 @@ public class MergeUtil {
|
|||||||
private static final String R_HEADS_MASTER =
|
private static final String R_HEADS_MASTER =
|
||||||
Constants.R_HEADS + Constants.MASTER;
|
Constants.R_HEADS + Constants.MASTER;
|
||||||
|
|
||||||
private static final ApprovalCategory.Id CRVW = //
|
private static final String CRVW = "CRVW";
|
||||||
new ApprovalCategory.Id("CRVW");
|
private static final String VRIF = "VRIF";
|
||||||
private static final ApprovalCategory.Id VRIF = //
|
|
||||||
new ApprovalCategory.Id("VRIF");
|
|
||||||
|
|
||||||
private static final FooterKey REVIEWED_ON = new FooterKey("Reviewed-on");
|
private static final FooterKey REVIEWED_ON = new FooterKey("Reviewed-on");
|
||||||
private static final FooterKey CHANGE_ID = new FooterKey("Change-Id");
|
private static final FooterKey CHANGE_ID = new FooterKey("Change-Id");
|
||||||
@@ -173,8 +171,7 @@ public class MergeUtil {
|
|||||||
final List<PatchSetApproval> approvals =
|
final List<PatchSetApproval> approvals =
|
||||||
reviewDb.patchSetApprovals().byPatchSet(c).toList();
|
reviewDb.patchSetApprovals().byPatchSet(c).toList();
|
||||||
for (PatchSetApproval a : approvals) {
|
for (PatchSetApproval a : approvals) {
|
||||||
if (a.getValue() > 0
|
if (a.getValue() > 0 && ApprovalCategory.isSubmit(a)) {
|
||||||
&& ApprovalCategory.SUBMIT.equals(a.getCategoryId())) {
|
|
||||||
if (submitter == null
|
if (submitter == null
|
||||||
|| a.getGranted().compareTo(submitter.getGranted()) > 0) {
|
|| a.getGranted().compareTo(submitter.getGranted()) > 0) {
|
||||||
submitter = a;
|
submitter = a;
|
||||||
@@ -260,7 +257,7 @@ public class MergeUtil {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ApprovalCategory.SUBMIT.equals(a.getCategoryId())) {
|
if (ApprovalCategory.isSubmit(a)) {
|
||||||
// Submit is treated specially, below (becomes committer)
|
// Submit is treated specially, below (becomes committer)
|
||||||
//
|
//
|
||||||
if (submitAudit == null
|
if (submitAudit == null
|
||||||
@@ -297,9 +294,9 @@ public class MergeUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final String tag;
|
final String tag;
|
||||||
if (CRVW.equals(a.getCategoryId())) {
|
if (CRVW.equals(a.getCategoryId().get())) {
|
||||||
tag = "Reviewed-by";
|
tag = "Reviewed-by";
|
||||||
} else if (VRIF.equals(a.getCategoryId())) {
|
} else if (VRIF.equals(a.getCategoryId().get())) {
|
||||||
tag = "Tested-by";
|
tag = "Tested-by";
|
||||||
} else {
|
} else {
|
||||||
final LabelType lt =
|
final LabelType lt =
|
||||||
|
|||||||
Reference in New Issue
Block a user