Rename ApprovalType(s) to LabelType(s)

Change-Id: Icb860eb84d481d519aa0facbef99392b45784843
This commit is contained in:
Dave Borowitz
2013-02-05 17:20:55 -08:00
parent 41f909fa98
commit 0557fc43c3
40 changed files with 286 additions and 293 deletions

View File

@@ -46,7 +46,7 @@ public class GerritConfig implements Cloneable {
protected String sshdAddress; protected String sshdAddress;
protected String editFullNameUrl; protected String editFullNameUrl;
protected Project.NameKey wildProject; protected Project.NameKey wildProject;
protected ApprovalTypes approvalTypes; protected LabelTypes labelTypes;
protected Set<Account.FieldName> editableAccountFields; protected Set<Account.FieldName> editableAccountFields;
protected List<RegexFindReplace> commentLinks; protected List<RegexFindReplace> commentLinks;
protected boolean documentationAvailable; protected boolean documentationAvailable;
@@ -196,12 +196,12 @@ public class GerritConfig implements Cloneable {
wildProject = wp; wildProject = wp;
} }
public ApprovalTypes getApprovalTypes() { public LabelTypes getLabelTypes() {
return approvalTypes; return labelTypes;
} }
public void setApprovalTypes(final ApprovalTypes at) { public void setLabelTypes(final LabelTypes at) {
approvalTypes = at; labelTypes = at;
} }
public boolean canEdit(final Account.FieldName f) { public boolean canEdit(final Account.FieldName f) {

View File

@@ -25,29 +25,29 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public class ApprovalType { public class LabelType {
public static ApprovalType fromApprovalCategory(ApprovalCategory ac, public static LabelType fromApprovalCategory(ApprovalCategory ac,
List<ApprovalCategoryValue> acvs) { List<ApprovalCategoryValue> acvs) {
List<LabelValue> values = new ArrayList<LabelValue>(acvs.size()); List<LabelValue> values = new ArrayList<LabelValue>(acvs.size());
for (ApprovalCategoryValue acv : acvs) { for (ApprovalCategoryValue acv : acvs) {
values.add( values.add(
new LabelValue(acv.getValue(), acv.getName())); new LabelValue(acv.getValue(), acv.getName()));
} }
ApprovalType at = LabelType lt = new LabelType(ac.getId().get(), ac.getLabelName(), values);
new ApprovalType(ac.getId().get(), ac.getLabelName(), values); lt.setAbbreviatedName(ac.getAbbreviatedName());
at.setAbbreviatedName(ac.getAbbreviatedName()); lt.setFunctionName(ac.getFunctionName());
at.setFunctionName(ac.getFunctionName()); lt.setCopyMinScore(ac.isCopyMinScore());
at.setCopyMinScore(ac.isCopyMinScore()); lt.setPosition(ac.getPosition());
at.setPosition(ac.getPosition()); return lt;
return at;
} }
public static ApprovalType withDefaultValues(String id, String name) { public static LabelType withDefaultValues(String id, String name) {
checkId(id);
checkName(name); checkName(name);
List<LabelValue> values = new ArrayList<LabelValue>(2); List<LabelValue> values = new ArrayList<LabelValue>(2);
values.add(new LabelValue((short) 0, "Rejected")); values.add(new LabelValue((short) 0, "Rejected"));
values.add(new LabelValue((short) 1, "Approved")); values.add(new LabelValue((short) 1, "Approved"));
return new ApprovalType(id, name, values); return new LabelType(id, name, values);
} }
private static String checkId(String id) { private static String checkId(String id) {
@@ -101,10 +101,10 @@ public class ApprovalType {
private transient List<Integer> intList; private transient List<Integer> intList;
private transient Map<Short, LabelValue> byValue; private transient Map<Short, LabelValue> byValue;
protected ApprovalType() { protected LabelType() {
} }
public ApprovalType(String id, String name, List<LabelValue> valueList) { public LabelType(String id, String name, List<LabelValue> valueList) {
this.id = checkId(id); this.id = checkId(id);
this.name = checkName(name); this.name = checkName(name);
values = new ArrayList<LabelValue>(valueList); values = new ArrayList<LabelValue>(valueList);

View File

@@ -18,32 +18,32 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public class ApprovalTypes { public class LabelTypes {
protected List<ApprovalType> approvalTypes; protected List<LabelType> labelTypes;
private transient Map<String, ApprovalType> byId; private transient Map<String, LabelType> byId;
private transient Map<String, ApprovalType> byLabel; private transient Map<String, LabelType> byLabel;
protected ApprovalTypes() { protected LabelTypes() {
} }
public ApprovalTypes(final List<ApprovalType> approvals) { public LabelTypes(final List<LabelType> approvals) {
approvalTypes = approvals; labelTypes = approvals;
byId(); byId();
} }
public List<ApprovalType> getApprovalTypes() { public List<LabelType> getLabelTypes() {
return approvalTypes; return labelTypes;
} }
public ApprovalType byId(String id) { public LabelType byId(String id) {
return byId().get(id); return byId().get(id);
} }
private Map<String, ApprovalType> byId() { private Map<String, LabelType> byId() {
if (byId == null) { if (byId == null) {
byId = new HashMap<String, ApprovalType>(); byId = new HashMap<String, LabelType>();
if (approvalTypes != null) { if (labelTypes != null) {
for (final ApprovalType t : approvalTypes) { for (final LabelType t : labelTypes) {
byId.put(t.getId(), t); byId.put(t.getId(), t);
} }
} }
@@ -51,15 +51,15 @@ public class ApprovalTypes {
return byId; return byId;
} }
public ApprovalType byLabel(String labelName) { public LabelType byLabel(String labelName) {
return byLabel().get(labelName.toLowerCase()); return byLabel().get(labelName.toLowerCase());
} }
private Map<String, ApprovalType> byLabel() { private Map<String, LabelType> byLabel() {
if (byLabel == null) { if (byLabel == null) {
byLabel = new HashMap<String, ApprovalType>(); byLabel = new HashMap<String, LabelType>();
if (approvalTypes != null) { if (labelTypes != null) {
for (ApprovalType t : approvalTypes) { for (LabelType t : labelTypes) {
byLabel.put(t.getName().toLowerCase(), t); byLabel.put(t.getName().toLowerCase(), t);
} }
} }

View File

@@ -16,7 +16,7 @@ package com.google.gerrit.client.admin;
import com.google.gerrit.client.Gerrit; import com.google.gerrit.client.Gerrit;
import com.google.gerrit.common.data.AccessSection; import com.google.gerrit.common.data.AccessSection;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.Permission; import com.google.gerrit.common.data.Permission;
import com.google.gerrit.common.data.ProjectAccess; import com.google.gerrit.common.data.ProjectAccess;
import com.google.gerrit.common.data.RefConfigSection; import com.google.gerrit.common.data.RefConfigSection;
@@ -226,8 +226,7 @@ public class AccessSectionEditor extends Composite implements
addPermission(varName, perms); addPermission(varName, perms);
} }
} else if (RefConfigSection.isValid(value.getName())) { } else if (RefConfigSection.isValid(value.getName())) {
for (ApprovalType t : Gerrit.getConfig().getApprovalTypes() for (LabelType t : Gerrit.getConfig().getLabelTypes().getLabelTypes()) {
.getApprovalTypes()) {
addPermission(Permission.LABEL + t.getName(), perms); addPermission(Permission.LABEL + t.getName(), perms);
} }
for (String varName : Util.C.permissionNames().keySet()) { for (String varName : Util.C.permissionNames().keySet()) {

View File

@@ -18,7 +18,7 @@ import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.rpc.GerritCallback; import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.ui.SuggestUtil; import com.google.gerrit.client.ui.SuggestUtil;
import com.google.gerrit.common.data.AccessSection; import com.google.gerrit.common.data.AccessSection;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.GlobalCapability; import com.google.gerrit.common.data.GlobalCapability;
import com.google.gerrit.common.data.GroupReference; import com.google.gerrit.common.data.GroupReference;
import com.google.gerrit.common.data.Permission; import com.google.gerrit.common.data.Permission;
@@ -260,12 +260,12 @@ public class PermissionEditor extends Composite implements Editor<Permission>,
this.value = value; this.value = value;
if (value.isLabel()) { if (value.isLabel()) {
ApprovalType at = Gerrit.getConfig().getApprovalTypes().byLabel(value.getLabel()); LabelType lt = Gerrit.getConfig().getLabelTypes().byLabel(value.getLabel());
if (at != null) { if (lt != null) {
validRange = new PermissionRange.WithDefaults( validRange = new PermissionRange.WithDefaults(
value.getName(), value.getName(),
at.getMin().getValue(), at.getMax().getValue(), lt.getMin().getValue(), lt.getMax().getValue(),
at.getMin().getValue(), at.getMax().getValue()); lt.getMin().getValue(), lt.getMax().getValue());
} }
} else if (GlobalCapability.isCapability(value.getName())) { } else if (GlobalCapability.isCapability(value.getName())) {
validRange = GlobalCapability.getRange(value.getName()); validRange = GlobalCapability.getRange(value.getName());

View File

@@ -30,8 +30,8 @@ import com.google.gerrit.client.ui.AccountLink;
import com.google.gerrit.client.ui.AddMemberBox; import com.google.gerrit.client.ui.AddMemberBox;
import com.google.gerrit.client.ui.ReviewerSuggestOracle; import com.google.gerrit.client.ui.ReviewerSuggestOracle;
import com.google.gerrit.common.data.ApprovalDetail; import com.google.gerrit.common.data.ApprovalDetail;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.ApprovalTypes; import com.google.gerrit.common.data.LabelTypes;
import com.google.gerrit.common.data.SubmitRecord; import com.google.gerrit.common.data.SubmitRecord;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Change;
@@ -62,14 +62,7 @@ import java.util.Set;
/** Displays a table of {@link ApprovalDetail} objects for a change record. */ /** Displays a table of {@link ApprovalDetail} objects for a change record. */
public class ApprovalTable extends Composite { public class ApprovalTable extends Composite {
static short parseLabelValue(String value) { private final LabelTypes types;
if (value.charAt(0) == ' ' || value.charAt(0) == '+') {
value = value.substring(1);
}
return Short.parseShort(value);
}
private final ApprovalTypes types;
private final Grid table; private final Grid table;
private final Widget missing; private final Widget missing;
private final Panel addReviewer; private final Panel addReviewer;
@@ -80,7 +73,7 @@ public class ApprovalTable extends Composite {
public ApprovalTable() { public ApprovalTable() {
rows = new HashMap<Integer, Integer>(); rows = new HashMap<Integer, Integer>();
types = Gerrit.getConfig().getApprovalTypes(); types = Gerrit.getConfig().getLabelTypes();
table = new Grid(1, 3); table = new Grid(1, 3);
table.addStyleName(Gerrit.RESOURCES.css().infoTable()); table.addStyleName(Gerrit.RESOURCES.css().infoTable());
@@ -371,8 +364,7 @@ public class ApprovalTable extends Composite {
table.setWidget(row, col, new Image(Gerrit.RESOURCES.greenCheck())); table.setWidget(row, col, new Image(Gerrit.RESOURCES.greenCheck()));
} else { } else {
// TODO: support arbitrary labels. LabelType legacyType = types.byLabel(labelName);
ApprovalType legacyType = types.byLabel(labelName);
if (legacyType == null) { if (legacyType == null) {
table.clearCell(row, col); table.clearCell(row, col);
col++; col++;

View File

@@ -31,7 +31,7 @@ import com.google.gerrit.common.data.AccountInfo;
import com.google.gerrit.common.data.AccountInfoCache; import com.google.gerrit.common.data.AccountInfoCache;
import com.google.gerrit.common.data.ApprovalSummary; import com.google.gerrit.common.data.ApprovalSummary;
import com.google.gerrit.common.data.ApprovalSummarySet; import com.google.gerrit.common.data.ApprovalSummarySet;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.ChangeInfo; import com.google.gerrit.common.data.ChangeInfo;
import com.google.gerrit.common.data.LabelValue; import com.google.gerrit.common.data.LabelValue;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
@@ -68,7 +68,7 @@ public class ChangeTable extends NavigationTable<ChangeInfo> {
private final List<Section> sections; private final List<Section> sections;
private AccountInfoCache accountCache = AccountInfoCache.empty(); private AccountInfoCache accountCache = AccountInfoCache.empty();
private final List<ApprovalType> approvalTypes; private final List<LabelType> labelTypes;
private final int columns; private final int columns;
public ChangeTable() { public ChangeTable() {
@@ -77,9 +77,9 @@ public class ChangeTable extends NavigationTable<ChangeInfo> {
public ChangeTable(boolean showApprovals) { public ChangeTable(boolean showApprovals) {
super(Util.C.changeItemHelp()); super(Util.C.changeItemHelp());
approvalTypes = Gerrit.getConfig().getApprovalTypes().getApprovalTypes(); labelTypes = Gerrit.getConfig().getLabelTypes().getLabelTypes();
if (showApprovals) { if (showApprovals) {
columns = BASE_COLUMNS + approvalTypes.size(); columns = BASE_COLUMNS + labelTypes.size();
} else { } else {
columns = BASE_COLUMNS; columns = BASE_COLUMNS;
} }
@@ -96,7 +96,7 @@ public class ChangeTable extends NavigationTable<ChangeInfo> {
table.setText(0, C_BRANCH, Util.C.changeTableColumnBranch()); table.setText(0, C_BRANCH, Util.C.changeTableColumnBranch());
table.setText(0, C_LAST_UPDATE, Util.C.changeTableColumnLastUpdate()); table.setText(0, C_LAST_UPDATE, Util.C.changeTableColumnLastUpdate());
for (int i = BASE_COLUMNS; i < columns; i++) { for (int i = BASE_COLUMNS; i < columns; i++) {
final ApprovalType type = approvalTypes.get(i - BASE_COLUMNS); final LabelType type = labelTypes.get(i - BASE_COLUMNS);
String text = type.getAbbreviatedName(); String text = type.getAbbreviatedName();
if (text == null) { if (text == null) {
text = type.getName(); text = type.getName();
@@ -294,7 +294,7 @@ public class ChangeTable extends NavigationTable<ChangeInfo> {
} }
} }
for (final ApprovalType type : approvalTypes) { for (final LabelType type : labelTypes) {
final PatchSetApproval ca = approvals.get(type.getId()); final PatchSetApproval ca = approvals.get(type.getId());
fmt.removeStyleName(row, col, Gerrit.RESOURCES.css().negscore()); fmt.removeStyleName(row, col, Gerrit.RESOURCES.css().negscore());

View File

@@ -14,8 +14,6 @@
package com.google.gerrit.client.changes; package com.google.gerrit.client.changes;
import static com.google.gerrit.client.changes.ApprovalTable.parseLabelValue;
import com.google.gerrit.client.Gerrit; import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.changes.ChangeInfo.ApprovalInfo; import com.google.gerrit.client.changes.ChangeInfo.ApprovalInfo;
import com.google.gerrit.client.changes.ChangeInfo.LabelInfo; import com.google.gerrit.client.changes.ChangeInfo.LabelInfo;
@@ -466,7 +464,11 @@ public class PublishCommentScreen extends AccountScreen implements
} }
short parseValue() { short parseValue() {
return parseLabelValue(value); String value = this.value;
if (value.startsWith(" ") || value.startsWith("+")) {
value = value.substring(1);
}
return Short.parseShort(value);
} }
} }

View File

@@ -14,7 +14,7 @@
package com.google.gerrit.httpd; package com.google.gerrit.httpd;
import com.google.gerrit.common.data.ApprovalTypes; import com.google.gerrit.common.data.LabelTypes;
import com.google.gerrit.common.data.GerritConfig; import com.google.gerrit.common.data.GerritConfig;
import com.google.gerrit.common.data.GitwebConfig; import com.google.gerrit.common.data.GitwebConfig;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
@@ -52,7 +52,7 @@ class GerritConfigProvider implements Provider<GerritConfig> {
private final GitWebConfig gitWebConfig; private final GitWebConfig gitWebConfig;
private final AllProjectsName wildProject; private final AllProjectsName wildProject;
private final SshInfo sshInfo; private final SshInfo sshInfo;
private final ApprovalTypes approvalTypes; private final LabelTypes labelTypes;
private EmailSender emailSender; private EmailSender emailSender;
private final ContactStore contactStore; private final ContactStore contactStore;
@@ -62,7 +62,7 @@ class GerritConfigProvider implements Provider<GerritConfig> {
@Inject @Inject
GerritConfigProvider(final Realm r, @GerritServerConfig final Config gsc, GerritConfigProvider(final Realm r, @GerritServerConfig final Config gsc,
final AuthConfig ac, final GitWebConfig gwc, final AllProjectsName wp, final AuthConfig ac, final GitWebConfig gwc, final AllProjectsName wp,
final SshInfo si, final ApprovalTypes at, final ContactStore cs, final SshInfo si, final LabelTypes at, final ContactStore cs,
final ServletContext sc, final DownloadConfig dc, final ServletContext sc, final DownloadConfig dc,
final @AnonymousCowardName String acn) { final @AnonymousCowardName String acn) {
realm = r; realm = r;
@@ -72,7 +72,7 @@ class GerritConfigProvider implements Provider<GerritConfig> {
gitWebConfig = gwc; gitWebConfig = gwc;
sshInfo = si; sshInfo = si;
wildProject = wp; wildProject = wp;
approvalTypes = at; labelTypes = at;
contactStore = cs; contactStore = cs;
servletContext = sc; servletContext = sc;
anonymousCowardName = acn; anonymousCowardName = acn;
@@ -123,7 +123,7 @@ class GerritConfigProvider implements Provider<GerritConfig> {
config.setDownloadCommands(downloadConfig.getDownloadCommands()); config.setDownloadCommands(downloadConfig.getDownloadCommands());
config.setAuthType(authConfig.getAuthType()); config.setAuthType(authConfig.getAuthType());
config.setWildProject(wildProject); config.setWildProject(wildProject);
config.setApprovalTypes(approvalTypes); config.setLabelTypes(labelTypes);
config.setDocumentationAvailable(servletContext config.setDocumentationAvailable(servletContext
.getResource("/Documentation/index.html") != null); .getResource("/Documentation/index.html") != null);
config.setTestChangeMerge(cfg.getBoolean("changeMerge", config.setTestChangeMerge(cfg.getBoolean("changeMerge",

View File

@@ -14,8 +14,8 @@
package com.google.gerrit.httpd.rpc.changedetail; package com.google.gerrit.httpd.rpc.changedetail;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.ApprovalTypes; import com.google.gerrit.common.data.LabelTypes;
import com.google.gerrit.common.data.PatchSetPublishDetail; import com.google.gerrit.common.data.PatchSetPublishDetail;
import com.google.gerrit.common.data.PermissionRange; import com.google.gerrit.common.data.PermissionRange;
import com.google.gerrit.common.data.SubmitRecord; import com.google.gerrit.common.data.SubmitRecord;
@@ -47,7 +47,7 @@ final class PatchSetPublishDetailFactory extends Handler<PatchSetPublishDetail>
private final PatchSetInfoFactory infoFactory; private final PatchSetInfoFactory infoFactory;
private final ReviewDb db; private final ReviewDb db;
private final ChangeControl.Factory changeControlFactory; private final ChangeControl.Factory changeControlFactory;
private final ApprovalTypes approvalTypes; private final LabelTypes labelTypes;
private final AccountInfoCacheFactory aic; private final AccountInfoCacheFactory aic;
private final IdentifiedUser user; private final IdentifiedUser user;
@@ -62,12 +62,12 @@ final class PatchSetPublishDetailFactory extends Handler<PatchSetPublishDetail>
final ReviewDb db, final ReviewDb db,
final AccountInfoCacheFactory.Factory accountInfoCacheFactory, final AccountInfoCacheFactory.Factory accountInfoCacheFactory,
final ChangeControl.Factory changeControlFactory, final ChangeControl.Factory changeControlFactory,
final ApprovalTypes approvalTypes, final LabelTypes labelTypes,
final IdentifiedUser user, @Assisted final PatchSet.Id patchSetId) { final IdentifiedUser user, @Assisted final PatchSet.Id patchSetId) {
this.infoFactory = infoFactory; this.infoFactory = infoFactory;
this.db = db; this.db = db;
this.changeControlFactory = changeControlFactory; this.changeControlFactory = changeControlFactory;
this.approvalTypes = approvalTypes; this.labelTypes = labelTypes;
this.aic = accountInfoCacheFactory.create(); this.aic = accountInfoCacheFactory.create();
this.user = user; this.user = user;
@@ -124,8 +124,8 @@ final class PatchSetPublishDetailFactory extends Handler<PatchSetPublishDetail>
boolean canMakeOk = false; boolean canMakeOk = false;
PermissionRange range = rangeByName.get(lbl.label); PermissionRange range = rangeByName.get(lbl.label);
if (range != null) { if (range != null) {
ApprovalType at = approvalTypes.byLabel(lbl.label); LabelType lt = labelTypes.byLabel(lbl.label);
if (at == null || at.getMax().getValue() == range.getMax()) { if (lt == null || lt.getMax().getValue() == range.getMax()) {
canMakeOk = true; canMakeOk = true;
} }
} }

View File

@@ -16,7 +16,7 @@ package com.google.gerrit.httpd.rpc.patch;
import com.google.gerrit.common.data.ApprovalSummary; import com.google.gerrit.common.data.ApprovalSummary;
import com.google.gerrit.common.data.ApprovalSummarySet; import com.google.gerrit.common.data.ApprovalSummarySet;
import com.google.gerrit.common.data.ApprovalTypes; import com.google.gerrit.common.data.LabelTypes;
import com.google.gerrit.common.data.ChangeDetail; import com.google.gerrit.common.data.ChangeDetail;
import com.google.gerrit.common.data.PatchDetailService; import com.google.gerrit.common.data.PatchDetailService;
import com.google.gerrit.common.data.PatchScript; import com.google.gerrit.common.data.PatchScript;
@@ -56,7 +56,7 @@ import java.util.Set;
class PatchDetailServiceImpl extends BaseServiceImplementation implements class PatchDetailServiceImpl extends BaseServiceImplementation implements
PatchDetailService { PatchDetailService {
private final ApprovalTypes approvalTypes; private final LabelTypes labelTypes;
private final AccountInfoCacheFactory.Factory accountInfoCacheFactory; private final AccountInfoCacheFactory.Factory accountInfoCacheFactory;
private final ChangeControl.Factory changeControlFactory; private final ChangeControl.Factory changeControlFactory;
@@ -69,7 +69,7 @@ class PatchDetailServiceImpl extends BaseServiceImplementation implements
@Inject @Inject
PatchDetailServiceImpl(final Provider<ReviewDb> schema, PatchDetailServiceImpl(final Provider<ReviewDb> schema,
final Provider<CurrentUser> currentUser, final Provider<CurrentUser> currentUser,
final ApprovalTypes approvalTypes, final LabelTypes labelTypes,
final AccountInfoCacheFactory.Factory accountInfoCacheFactory, final AccountInfoCacheFactory.Factory accountInfoCacheFactory,
final ChangeControl.Factory changeControlFactory, final ChangeControl.Factory changeControlFactory,
final DeleteDraftPatchSet.Factory deleteDraftPatchSetFactory, final DeleteDraftPatchSet.Factory deleteDraftPatchSetFactory,
@@ -78,7 +78,7 @@ class PatchDetailServiceImpl extends BaseServiceImplementation implements
final SaveDraft.Factory saveDraftFactory, final SaveDraft.Factory saveDraftFactory,
final ChangeDetailFactory.Factory changeDetailFactory) { final ChangeDetailFactory.Factory changeDetailFactory) {
super(schema, currentUser); super(schema, currentUser);
this.approvalTypes = approvalTypes; this.labelTypes = labelTypes;
this.accountInfoCacheFactory = accountInfoCacheFactory; this.accountInfoCacheFactory = accountInfoCacheFactory;
this.changeControlFactory = changeControlFactory; this.changeControlFactory = changeControlFactory;
@@ -189,7 +189,7 @@ class PatchDetailServiceImpl extends BaseServiceImplementation implements
continue; continue;
} }
if (change.getStatus().isOpen()) { if (change.getStatus().isOpen()) {
fs.normalize(approvalTypes.byId(category.get()), ca); fs.normalize(labelTypes.byId(category.get()), ca);
} }
if (ca.getValue() == 0) { if (ca.getValue() == 0) {
continue; continue;
@@ -235,7 +235,7 @@ class PatchDetailServiceImpl extends BaseServiceImplementation implements
continue; continue;
} }
if (change.getStatus().isOpen()) { if (change.getStatus().isOpen()) {
fs.normalize(approvalTypes.byId(category.get()), ca); fs.normalize(labelTypes.byId(category.get()), ca);
} }
if (ca.getValue() == 0) { if (ca.getValue() == 0) {
continue; continue;

View File

@@ -14,8 +14,8 @@
package com.google.gerrit.common; package com.google.gerrit.common;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.ApprovalTypes; import com.google.gerrit.common.data.LabelTypes;
import com.google.gerrit.common.data.ContributorAgreement; 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;
@@ -206,7 +206,7 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
private final AccountCache accountCache; private final AccountCache accountCache;
private final ApprovalTypes approvalTypes; private final LabelTypes labelTypes;
private final EventFactory eventFactory; private final EventFactory eventFactory;
@@ -233,7 +233,7 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
final @GerritServerConfig Config config, final @GerritServerConfig Config config,
final @AnonymousCowardName String anonymousCowardName, final @AnonymousCowardName String anonymousCowardName,
final SitePaths sitePath, final ProjectCache projectCache, final SitePaths sitePath, final ProjectCache projectCache,
final AccountCache accountCache, final ApprovalTypes approvalTypes, final AccountCache accountCache, final LabelTypes labelTypes,
final EventFactory eventFactory, final SitePaths sitePaths, final EventFactory eventFactory, final SitePaths sitePaths,
final DynamicSet<ChangeListener> unrestrictedListeners) { final DynamicSet<ChangeListener> unrestrictedListeners) {
this.anonymousCowardName = anonymousCowardName; this.anonymousCowardName = anonymousCowardName;
@@ -241,7 +241,7 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
this.hookQueue = queue.createQueue(1, "hook"); this.hookQueue = queue.createQueue(1, "hook");
this.projectCache = projectCache; this.projectCache = projectCache;
this.accountCache = accountCache; this.accountCache = accountCache;
this.approvalTypes = approvalTypes; this.labelTypes = labelTypes;
this.eventFactory = eventFactory; this.eventFactory = eventFactory;
this.sitePaths = sitePath; this.sitePaths = sitePath;
this.unrestrictedListeners = unrestrictedListeners; this.unrestrictedListeners = unrestrictedListeners;
@@ -616,9 +616,9 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
Entry<ApprovalCategory.Id, ApprovalCategoryValue.Id> approval) { Entry<ApprovalCategory.Id, ApprovalCategoryValue.Id> approval) {
ApprovalAttribute a = new ApprovalAttribute(); ApprovalAttribute a = new ApprovalAttribute();
a.type = approval.getKey().get(); a.type = approval.getKey().get();
ApprovalType at = approvalTypes.byId(approval.getKey().get()); LabelType lt = labelTypes.byId(approval.getKey().get());
if (at != null) { if (lt != null) {
a.description = at.getName(); a.description = lt.getName();
} }
a.value = Short.toString(approval.getValue().get()); a.value = Short.toString(approval.getValue().get());
return a; return a;

View File

@@ -17,8 +17,8 @@ package com.google.gerrit.server;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.ApprovalTypes; import com.google.gerrit.common.data.LabelTypes;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Account.Id; import com.google.gerrit.reviewdb.client.Account.Id;
import com.google.gerrit.reviewdb.client.ApprovalCategory; import com.google.gerrit.reviewdb.client.ApprovalCategory;
@@ -46,12 +46,12 @@ import java.util.Set;
*/ */
public class ApprovalsUtil { public class ApprovalsUtil {
private final ReviewDb db; private final ReviewDb db;
private final ApprovalTypes approvalTypes; private final LabelTypes labelTypes;
@Inject @Inject
public ApprovalsUtil(ReviewDb db, ApprovalTypes approvalTypes) { public ApprovalsUtil(ReviewDb db, LabelTypes labelTypes) {
this.db = db; this.db = db;
this.approvalTypes = approvalTypes; this.labelTypes = labelTypes;
} }
/** /**
@@ -91,7 +91,7 @@ public class ApprovalsUtil {
for (PatchSetApproval a : patchSetApprovals) { for (PatchSetApproval a : patchSetApprovals) {
// ApprovalCategory.SUBMIT is still in db but not relevant in git-store // ApprovalCategory.SUBMIT is still in db but not relevant in git-store
if (!ApprovalCategory.SUBMIT.equals(a.getCategoryId())) { if (!ApprovalCategory.SUBMIT.equals(a.getCategoryId())) {
final ApprovalType type = approvalTypes.byId(a.getCategoryId().get()); final LabelType type = labelTypes.byId(a.getCategoryId().get());
if (a.getPatchSetId().equals(source) && if (a.getPatchSetId().equals(source) &&
type.isCopyMinScore() && type.isCopyMinScore() &&
type.isMaxNegative(a)) { type.isMaxNegative(a)) {
@@ -106,7 +106,7 @@ public class ApprovalsUtil {
public void addReviewers(ReviewDb db, Change change, PatchSet ps, public void addReviewers(ReviewDb db, Change change, PatchSet ps,
PatchSetInfo info, Set<Id> wantReviewers, PatchSetInfo info, Set<Id> wantReviewers,
Set<Account.Id> existingReviewers) throws OrmException { Set<Account.Id> existingReviewers) throws OrmException {
List<ApprovalType> allTypes = approvalTypes.getApprovalTypes(); List<LabelType> allTypes = labelTypes.getLabelTypes();
if (allTypes.isEmpty()) { if (allTypes.isEmpty()) {
return; return;
} }

View File

@@ -35,8 +35,8 @@ import com.google.common.collect.Maps;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.gerrit.common.changes.ListChangesOption; import com.google.gerrit.common.changes.ListChangesOption;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.ApprovalTypes; import com.google.gerrit.common.data.LabelTypes;
import com.google.gerrit.common.data.LabelValue; import com.google.gerrit.common.data.LabelValue;
import com.google.gerrit.common.data.Permission; import com.google.gerrit.common.data.Permission;
import com.google.gerrit.common.data.PermissionRange; import com.google.gerrit.common.data.PermissionRange;
@@ -114,7 +114,7 @@ public class ChangeJson {
} }
private final Provider<ReviewDb> db; private final Provider<ReviewDb> db;
private final ApprovalTypes approvalTypes; private final LabelTypes labelTypes;
private final FunctionState.Factory functionState; private final FunctionState.Factory functionState;
private final CurrentUser user; private final CurrentUser user;
private final AnonymousUser anonymous; private final AnonymousUser anonymous;
@@ -134,7 +134,7 @@ public class ChangeJson {
@Inject @Inject
ChangeJson( ChangeJson(
Provider<ReviewDb> db, Provider<ReviewDb> db,
ApprovalTypes at, LabelTypes at,
FunctionState.Factory fs, FunctionState.Factory fs,
CurrentUser u, CurrentUser u,
AnonymousUser au, AnonymousUser au,
@@ -146,7 +146,7 @@ public class ChangeJson {
@CanonicalWebUrl Provider<String> curl, @CanonicalWebUrl Provider<String> curl,
Urls urls) { Urls urls) {
this.db = db; this.db = db;
this.approvalTypes = at; this.labelTypes = at;
this.functionState = fs; this.functionState = fs;
this.user = u; this.user = u;
this.anonymous = au; this.anonymous = au;
@@ -338,7 +338,7 @@ public class ChangeJson {
setAllApprovals(cd, labels); setAllApprovals(cd, labels);
} }
for (Map.Entry<String, LabelInfo> e : labels.entrySet()) { for (Map.Entry<String, LabelInfo> e : labels.entrySet()) {
ApprovalType type = approvalTypes.byLabel(e.getKey()); LabelType type = labelTypes.byLabel(e.getKey());
if (type == null) { if (type == null) {
continue; // TODO: Support arbitrary labels. continue; // TODO: Support arbitrary labels.
} }
@@ -356,7 +356,7 @@ public class ChangeJson {
throws OrmException { throws OrmException {
// Don't use Maps.newTreeMap(Comparator) due to OpenJDK bug 100167. // Don't use Maps.newTreeMap(Comparator) due to OpenJDK bug 100167.
Map<String, LabelInfo> labels = Map<String, LabelInfo> labels =
new TreeMap<String, LabelInfo>(LabelOrdering.create(approvalTypes)); new TreeMap<String, LabelInfo>(LabelOrdering.create(labelTypes));
for (SubmitRecord rec : submitRecords(cd)) { for (SubmitRecord rec : submitRecords(cd)) {
if (rec.labels == null) { if (rec.labels == null) {
continue; continue;
@@ -387,7 +387,7 @@ public class ChangeJson {
return labels; return labels;
} }
private void setRecommendedAndDisliked(ChangeData cd, ApprovalType type, private void setRecommendedAndDisliked(ChangeData cd, LabelType type,
LabelInfo label) throws OrmException { LabelInfo label) throws OrmException {
if (label.approved != null || label.rejected != null) { if (label.approved != null || label.rejected != null) {
return; return;
@@ -428,25 +428,25 @@ public class ChangeJson {
Collection<PatchSetApproval> approvals = cd.currentApprovals(db); Collection<PatchSetApproval> approvals = cd.currentApprovals(db);
FunctionState fs = FunctionState fs =
functionState.create(ctl, cd.change(db).currentPatchSetId(), approvals); functionState.create(ctl, cd.change(db).currentPatchSetId(), approvals);
for (ApprovalType at : approvalTypes.getApprovalTypes()) { for (LabelType lt : labelTypes.getLabelTypes()) {
CategoryFunction.forType(at).run(at, fs); CategoryFunction.forType(lt).run(lt, fs);
} }
Multimap<Account.Id, String> existing = Multimap<Account.Id, String> existing =
HashMultimap.create(approvals.size(), labels.size()); HashMultimap.create(approvals.size(), labels.size());
for (PatchSetApproval psa : approvals) { for (PatchSetApproval psa : approvals) {
ApprovalType at = approvalTypes.byId(psa.getCategoryId().get()); LabelType lt = labelTypes.byId(psa.getCategoryId().get());
if (at == null) { if (lt == null) {
continue; continue;
} }
LabelInfo p = labels.get(at.getName()); LabelInfo p = labels.get(lt.getName());
if (p == null) { if (p == null) {
continue; // TODO: support arbitrary labels. continue; // TODO: support arbitrary labels.
} }
if (!getRange(ctl, psa.getAccountId(), at.getName()).isEmpty()) { if (!getRange(ctl, psa.getAccountId(), lt.getName()).isEmpty()) {
p.addApproval(approvalInfo(psa.getAccountId(), psa.getValue())); p.addApproval(approvalInfo(psa.getAccountId(), psa.getValue()));
} }
existing.put(psa.getAccountId(), at.getName()); existing.put(psa.getAccountId(), lt.getName());
} }
// Add dummy approvals for all permitted labels for each user even if they // Add dummy approvals for all permitted labels for each user even if they
@@ -475,9 +475,9 @@ public class ChangeJson {
// //
// Don't use Maps.newTreeMap(Comparator) due to OpenJDK bug 100167. // Don't use Maps.newTreeMap(Comparator) due to OpenJDK bug 100167.
Map<String, LabelInfo> labels = Map<String, LabelInfo> labels =
new TreeMap<String, LabelInfo>(LabelOrdering.create(approvalTypes)); new TreeMap<String, LabelInfo>(LabelOrdering.create(labelTypes));
for (PatchSetApproval psa : cd.currentApprovals(db)) { for (PatchSetApproval psa : cd.currentApprovals(db)) {
ApprovalType type = approvalTypes.byId(psa.getCategoryId().get()); LabelType type = labelTypes.byId(psa.getCategoryId().get());
if (type == null) { if (type == null) {
continue; continue;
} }
@@ -537,7 +537,7 @@ public class ChangeJson {
return values.isEmpty() || (values.size() == 1 && values.contains(" 0")); return values.isEmpty() || (values.size() == 1 && values.contains(" 0"));
} }
private void setLabelValues(ApprovalType type, LabelInfo label) { private void setLabelValues(LabelType type, LabelInfo label) {
label.values = Maps.newLinkedHashMap(); label.values = Maps.newLinkedHashMap();
for (LabelValue v : type.getValues()) { for (LabelValue v : type.getValues()) {
label.values.put(v.formatValue(), v.getText()); label.values.put(v.formatValue(), v.getText());
@@ -556,7 +556,7 @@ public class ChangeJson {
continue; continue;
} }
for (SubmitRecord.Label r : rec.labels) { for (SubmitRecord.Label r : rec.labels) {
ApprovalType type = approvalTypes.byLabel(r.label); LabelType type = labelTypes.byLabel(r.label);
if (type == null) { if (type == null) {
continue; // TODO: Support arbitrary labels. continue; // TODO: Support arbitrary labels.
} }

View File

@@ -16,17 +16,17 @@ package com.google.gerrit.server.change;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.Ordering; import com.google.common.collect.Ordering;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.ApprovalTypes; import com.google.gerrit.common.data.LabelTypes;
class LabelOrdering { class LabelOrdering {
public static Ordering<String> create(final ApprovalTypes approvalTypes) { public static Ordering<String> create(final LabelTypes labelTypes) {
return Ordering.natural().nullsLast().onResultOf( return Ordering.natural().nullsLast().onResultOf(
new Function<String, Short>() { new Function<String, Short>() {
@Override @Override
public Short apply(String n) { public Short apply(String n) {
ApprovalType at = approvalTypes.byLabel(n); LabelType lt = labelTypes.byLabel(n);
return at != null ? at.getPosition() : null; return lt != null ? lt.getPosition() : null;
} }
}).compound(Ordering.natural()); }).compound(Ordering.natural());
} }

View File

@@ -19,8 +19,8 @@ import com.google.common.base.Strings;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.gerrit.common.ChangeHooks; import com.google.gerrit.common.ChangeHooks;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.ApprovalTypes; import com.google.gerrit.common.data.LabelTypes;
import com.google.gerrit.common.data.Permission; import com.google.gerrit.common.data.Permission;
import com.google.gerrit.common.data.PermissionRange; import com.google.gerrit.common.data.PermissionRange;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
@@ -102,7 +102,7 @@ public class PostReview implements RestModifyView<RevisionResource, Input> {
} }
private final ReviewDb db; private final ReviewDb db;
private final ApprovalTypes approvalTypes; private final LabelTypes labelTypes;
private final EmailReviewComments.Factory email; private final EmailReviewComments.Factory email;
@Deprecated private final ChangeHooks hooks; @Deprecated private final ChangeHooks hooks;
@@ -116,11 +116,11 @@ public class PostReview implements RestModifyView<RevisionResource, Input> {
@Inject @Inject
PostReview(ReviewDb db, PostReview(ReviewDb db,
ApprovalTypes approvalTypes, LabelTypes labelTypes,
EmailReviewComments.Factory email, EmailReviewComments.Factory email,
ChangeHooks hooks) { ChangeHooks hooks) {
this.db = db; this.db = db;
this.approvalTypes = approvalTypes; this.labelTypes = labelTypes;
this.email = email; this.email = email;
this.hooks = hooks; this.hooks = hooks;
} }
@@ -180,8 +180,8 @@ public class PostReview implements RestModifyView<RevisionResource, Input> {
Map.Entry<String, Short> ent = itr.next(); Map.Entry<String, Short> ent = itr.next();
// TODO Support more generic label assignments. // TODO Support more generic label assignments.
ApprovalType at = approvalTypes.byLabel(ent.getKey()); LabelType lt = labelTypes.byLabel(ent.getKey());
if (at == null) { if (lt == null) {
if (strict) { if (strict) {
throw new BadRequestException(String.format( throw new BadRequestException(String.format(
"label \"%s\" is not a configured ApprovalCategory", "label \"%s\" is not a configured ApprovalCategory",
@@ -198,7 +198,7 @@ public class PostReview implements RestModifyView<RevisionResource, Input> {
continue; continue;
} }
if (at.getValue(ent.getValue()) == null) { if (lt.getValue(ent.getValue()) == null) {
if (strict) { if (strict) {
throw new BadRequestException(String.format( throw new BadRequestException(String.format(
"label \"%s\": %d is not a valid value", "label \"%s\": %d is not a valid value",
@@ -209,7 +209,7 @@ public class PostReview implements RestModifyView<RevisionResource, Input> {
} }
} }
String name = at.getName(); String name = lt.getName();
PermissionRange range = ctl.getRange(Permission.forLabel(name)); PermissionRange range = ctl.getRange(Permission.forLabel(name));
if (range == null || !range.contains(ent.getValue())) { if (range == null || !range.contains(ent.getValue())) {
if (strict) { if (strict) {
@@ -345,8 +345,8 @@ public class PostReview implements RestModifyView<RevisionResource, Input> {
for (Map.Entry<String, Short> ent : labels.entrySet()) { for (Map.Entry<String, Short> ent : labels.entrySet()) {
// TODO Support arbitrary label names. // TODO Support arbitrary label names.
ApprovalType at = approvalTypes.byLabel(ent.getKey()); LabelType lt = labelTypes.byLabel(ent.getKey());
String name = at.getName(); String name = lt.getName();
if (change.getStatus().isClosed()) { if (change.getStatus().isClosed()) {
// TODO Allow updating some labels even when closed. // TODO Allow updating some labels even when closed.
continue; continue;
@@ -368,23 +368,23 @@ public class PostReview implements RestModifyView<RevisionResource, Input> {
upd.add(c); upd.add(c);
labelDelta.add(format(name, c.getValue())); labelDelta.add(format(name, c.getValue()));
categories.put( categories.put(
at.getApprovalCategoryId(), lt.getApprovalCategoryId(),
at.getApprovalCategoryValueId(c.getValue())); 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) {
c = new PatchSetApproval(new PatchSetApproval.Key( c = new PatchSetApproval(new PatchSetApproval.Key(
rsrc.getPatchSet().getId(), rsrc.getPatchSet().getId(),
rsrc.getAccountId(), rsrc.getAccountId(),
at.getApprovalCategoryId()), lt.getApprovalCategoryId()),
ent.getValue()); ent.getValue());
c.setGranted(timestamp); c.setGranted(timestamp);
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(
at.getApprovalCategoryId(), lt.getApprovalCategoryId(),
at.getApprovalCategoryValueId(c.getValue())); lt.getApprovalCategoryValueId(c.getValue()));
} }
} }
@@ -402,11 +402,11 @@ public class PostReview implements RestModifyView<RevisionResource, Input> {
// TODO Find another way to link reviewers to changes. // TODO Find another way to link reviewers to changes.
if (del.isEmpty()) { if (del.isEmpty()) {
// If no existing label is being set to 0, hack in the caller // If no existing label is being set to 0, hack in the caller
// as a reviewer by picking the first server-wide ApprovalType. // as a reviewer by picking the first server-wide LabelType.
PatchSetApproval c = new PatchSetApproval(new PatchSetApproval.Key( PatchSetApproval c = new PatchSetApproval(new PatchSetApproval.Key(
rsrc.getPatchSet().getId(), rsrc.getPatchSet().getId(),
rsrc.getAccountId(), rsrc.getAccountId(),
approvalTypes.getApprovalTypes().get(0).getApprovalCategoryId()), labelTypes.getLabelTypes().get(0).getApprovalCategoryId()),
(short) 0); (short) 0);
c.setGranted(timestamp); c.setGranted(timestamp);
c.cache(change); c.cache(change);
@@ -433,9 +433,9 @@ public class PostReview implements RestModifyView<RevisionResource, Input> {
continue; continue;
} }
ApprovalType at = approvalTypes.byId(a.getCategoryId().get()); LabelType lt = labelTypes.byId(a.getCategoryId().get());
if (at != null) { if (lt != null) {
current.put(at.getName(), a); current.put(lt.getName(), a);
} else { } else {
del.add(a); del.add(a);
} }

View File

@@ -21,9 +21,9 @@ import com.google.common.collect.Iterables;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.gerrit.common.ChangeHooks; import com.google.gerrit.common.ChangeHooks;
import com.google.gerrit.common.data.ApprovalTypes;
import com.google.gerrit.common.data.GroupDescription; import com.google.gerrit.common.data.GroupDescription;
import com.google.gerrit.common.data.GroupDescriptions; import com.google.gerrit.common.data.GroupDescriptions;
import com.google.gerrit.common.data.LabelTypes;
import com.google.gerrit.common.errors.EmailException; import com.google.gerrit.common.errors.EmailException;
import com.google.gerrit.common.errors.NoSuchGroupException; import com.google.gerrit.common.errors.NoSuchGroupException;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
@@ -98,7 +98,7 @@ public class PostReviewers implements RestModifyView<ChangeResource, Input> {
Provider<ReviewDb> db, Provider<ReviewDb> db,
IdentifiedUser currentUser, IdentifiedUser currentUser,
IdentifiedUser.GenericFactory identifiedUserFactory, IdentifiedUser.GenericFactory identifiedUserFactory,
ApprovalTypes approvalTypes, LabelTypes labelTypes,
@GerritServerConfig Config cfg, @GerritServerConfig Config cfg,
ChangeHooks hooks, ChangeHooks hooks,
AccountCache accountCache, AccountCache accountCache,
@@ -117,7 +117,7 @@ public class PostReviewers implements RestModifyView<ChangeResource, Input> {
this.accountCache = accountCache; this.accountCache = accountCache;
this.json = json; this.json = json;
this.addReviewerCategoryId = Iterables.getLast(approvalTypes.getApprovalTypes()) this.addReviewerCategoryId = Iterables.getLast(labelTypes.getLabelTypes())
.getApprovalCategoryId(); .getApprovalCategoryId();
} }

View File

@@ -18,8 +18,8 @@ import static com.google.gerrit.common.data.LabelValue.formatValue;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.ApprovalTypes; import com.google.gerrit.common.data.LabelTypes;
import com.google.gerrit.common.data.Permission; import com.google.gerrit.common.data.Permission;
import com.google.gerrit.common.data.PermissionRange; import com.google.gerrit.common.data.PermissionRange;
import com.google.gerrit.common.data.SubmitRecord; import com.google.gerrit.common.data.SubmitRecord;
@@ -42,17 +42,17 @@ import java.util.TreeMap;
public class ReviewerJson { public class ReviewerJson {
private final Provider<ReviewDb> db; private final Provider<ReviewDb> db;
private final ApprovalTypes approvalTypes; private final LabelTypes labelTypes;
private final FunctionState.Factory functionState; private final FunctionState.Factory functionState;
private final AccountInfo.Loader.Factory accountLoaderFactory; private final AccountInfo.Loader.Factory accountLoaderFactory;
@Inject @Inject
ReviewerJson(Provider<ReviewDb> db, ReviewerJson(Provider<ReviewDb> db,
ApprovalTypes approvalTypes, LabelTypes labelTypes,
FunctionState.Factory functionState, FunctionState.Factory functionState,
AccountInfo.Loader.Factory accountLoaderFactory) { AccountInfo.Loader.Factory accountLoaderFactory) {
this.db = db; this.db = db;
this.approvalTypes = approvalTypes; this.labelTypes = labelTypes;
this.functionState = functionState; this.functionState = functionState;
this.accountLoaderFactory = accountLoaderFactory; this.accountLoaderFactory = accountLoaderFactory;
} }
@@ -84,18 +84,18 @@ public class ReviewerJson {
} }
FunctionState fs = functionState.create(ctl, psId, approvals); FunctionState fs = functionState.create(ctl, psId, approvals);
for (ApprovalType at : approvalTypes.getApprovalTypes()) { for (LabelType at : labelTypes.getLabelTypes()) {
CategoryFunction.forType(at).run(at, fs); CategoryFunction.forType(at).run(at, fs);
} }
// Don't use Maps.newTreeMap(Comparator) due to OpenJDK bug 100167. // Don't use Maps.newTreeMap(Comparator) due to OpenJDK bug 100167.
out.approvals = new TreeMap<String,String>(LabelOrdering.create( out.approvals = new TreeMap<String,String>(LabelOrdering.create(
approvalTypes)); labelTypes));
for (PatchSetApproval ca : approvals) { for (PatchSetApproval ca : approvals) {
for (PermissionRange pr : ctl.getLabelRanges()) { for (PermissionRange pr : ctl.getLabelRanges()) {
if (!pr.isEmpty()) { if (!pr.isEmpty()) {
// TODO: Support arbitrary labels. // TODO: Support arbitrary labels.
ApprovalType at = approvalTypes.byId(ca.getCategoryId().get()); LabelType at = labelTypes.byId(ca.getCategoryId().get());
if (at != null) { if (at != null) {
out.approvals.put(at.getName(), formatValue(ca.getValue())); } out.approvals.put(at.getName(), formatValue(ca.getValue())); }
} }

View File

@@ -19,7 +19,7 @@ import static com.google.inject.Scopes.SINGLETON;
import com.google.common.cache.Cache; import com.google.common.cache.Cache;
import com.google.gerrit.audit.AuditModule; import com.google.gerrit.audit.AuditModule;
import com.google.gerrit.common.ChangeListener; import com.google.gerrit.common.ChangeListener;
import com.google.gerrit.common.data.ApprovalTypes; import com.google.gerrit.common.data.LabelTypes;
import com.google.gerrit.extensions.events.GitReferenceUpdatedListener; import com.google.gerrit.extensions.events.GitReferenceUpdatedListener;
import com.google.gerrit.extensions.events.NewProjectCreatedListener; import com.google.gerrit.extensions.events.NewProjectCreatedListener;
import com.google.gerrit.extensions.registration.DynamicItem; import com.google.gerrit.extensions.registration.DynamicItem;
@@ -140,7 +140,7 @@ public class GerritGlobalModule extends FactoryModule {
break; break;
} }
bind(ApprovalTypes.class).toProvider(ApprovalTypesProvider.class).in( bind(LabelTypes.class).toProvider(LabelTypesProvider.class).in(
SINGLETON); SINGLETON);
bind(EmailExpander.class).toProvider(EmailExpanderProvider.class).in( bind(EmailExpander.class).toProvider(EmailExpanderProvider.class).in(
SINGLETON); SINGLETON);

View File

@@ -14,8 +14,8 @@
package com.google.gerrit.server.config; package com.google.gerrit.server.config;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.ApprovalTypes; import com.google.gerrit.common.data.LabelTypes;
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.ApprovalCategoryValue;
import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.reviewdb.server.ReviewDb;
@@ -29,17 +29,17 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
public class ApprovalTypesProvider implements Provider<ApprovalTypes> { public class LabelTypesProvider implements Provider<LabelTypes> {
private final SchemaFactory<ReviewDb> schema; private final SchemaFactory<ReviewDb> schema;
@Inject @Inject
ApprovalTypesProvider(final SchemaFactory<ReviewDb> sf) { LabelTypesProvider(final SchemaFactory<ReviewDb> sf) {
schema = sf; schema = sf;
} }
@Override @Override
public ApprovalTypes get() { public LabelTypes get() {
List<ApprovalType> types = new ArrayList<ApprovalType>(2); List<LabelType> types = new ArrayList<LabelType>(2);
try { try {
final ReviewDb db = schema.open(); final ReviewDb db = schema.open();
@@ -47,7 +47,7 @@ public class ApprovalTypesProvider implements Provider<ApprovalTypes> {
for (final ApprovalCategory c : db.approvalCategories().all()) { for (final ApprovalCategory c : db.approvalCategories().all()) {
final List<ApprovalCategoryValue> values = final List<ApprovalCategoryValue> values =
db.approvalCategoryValues().byCategory(c.getId()).toList(); db.approvalCategoryValues().byCategory(c.getId()).toList();
types.add(ApprovalType.fromApprovalCategory(c, values)); types.add(LabelType.fromApprovalCategory(c, values));
} }
} finally { } finally {
db.close(); db.close();
@@ -56,6 +56,6 @@ public class ApprovalTypesProvider implements Provider<ApprovalTypes> {
throw new ProvisionException("Cannot query approval categories", e); throw new ProvisionException("Cannot query approval categories", e);
} }
return new ApprovalTypes(Collections.unmodifiableList(types)); return new LabelTypes(Collections.unmodifiableList(types));
} }
} }

View File

@@ -14,8 +14,8 @@
package com.google.gerrit.server.events; package com.google.gerrit.server.events;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.ApprovalTypes; import com.google.gerrit.common.data.LabelTypes;
import com.google.gerrit.common.data.SubmitRecord; import com.google.gerrit.common.data.SubmitRecord;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Branch; import com.google.gerrit.reviewdb.client.Branch;
@@ -62,7 +62,7 @@ public class EventFactory {
private static final Logger log = LoggerFactory.getLogger(EventFactory.class); private static final Logger log = LoggerFactory.getLogger(EventFactory.class);
private final AccountCache accountCache; private final AccountCache accountCache;
private final Provider<String> urlProvider; private final Provider<String> urlProvider;
private final ApprovalTypes approvalTypes; private final LabelTypes labelTypes;
private final PatchListCache patchListCache; private final PatchListCache patchListCache;
private final SchemaFactory<ReviewDb> schema; private final SchemaFactory<ReviewDb> schema;
private final PatchSetInfoFactory psInfoFactory; private final PatchSetInfoFactory psInfoFactory;
@@ -71,13 +71,13 @@ public class EventFactory {
@Inject @Inject
EventFactory(AccountCache accountCache, EventFactory(AccountCache accountCache,
@CanonicalWebUrl @Nullable Provider<String> urlProvider, @CanonicalWebUrl @Nullable Provider<String> urlProvider,
ApprovalTypes approvalTypes, LabelTypes labelTypes,
final PatchSetInfoFactory psif, final PatchSetInfoFactory psif,
PatchListCache patchListCache, SchemaFactory<ReviewDb> schema, PatchListCache patchListCache, SchemaFactory<ReviewDb> schema,
@GerritPersonIdent PersonIdent myIdent) { @GerritPersonIdent PersonIdent myIdent) {
this.accountCache = accountCache; this.accountCache = accountCache;
this.urlProvider = urlProvider; this.urlProvider = urlProvider;
this.approvalTypes = approvalTypes; this.labelTypes = labelTypes;
this.patchListCache = patchListCache; this.patchListCache = patchListCache;
this.schema = schema; this.schema = schema;
this.psInfoFactory = psif; this.psInfoFactory = psif;
@@ -460,9 +460,9 @@ public class EventFactory {
a.by = asAccountAttribute(approval.getAccountId()); a.by = asAccountAttribute(approval.getAccountId());
a.grantedOn = approval.getGranted().getTime() / 1000L; a.grantedOn = approval.getGranted().getTime() / 1000L;
ApprovalType at = approvalTypes.byId(approval.getCategoryId().get()); LabelType lt = labelTypes.byId(approval.getCategoryId().get());
if (at != null) { if (lt != null) {
a.description = at.getName(); a.description = lt.getName();
} }
return a; return a;
} }

View File

@@ -24,7 +24,7 @@ import static com.google.gerrit.server.git.MergeUtil.mergeOneCommit;
import static com.google.gerrit.server.git.MergeUtil.getApprovalsForCommit; import static com.google.gerrit.server.git.MergeUtil.getApprovalsForCommit;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.gerrit.common.data.ApprovalTypes; import com.google.gerrit.common.data.LabelTypes;
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.PatchSetAncestor; import com.google.gerrit.reviewdb.client.PatchSetAncestor;
@@ -53,19 +53,19 @@ import java.util.Map;
public class CherryPick extends SubmitStrategy { public class CherryPick extends SubmitStrategy {
private final PatchSetInfoFactory patchSetInfoFactory; private final PatchSetInfoFactory patchSetInfoFactory;
private final Provider<String> urlProvider; private final Provider<String> urlProvider;
private final ApprovalTypes approvalTypes; private final LabelTypes labelTypes;
private final GitReferenceUpdated gitRefUpdated; private final GitReferenceUpdated gitRefUpdated;
private final Map<Change.Id, CodeReviewCommit> newCommits; private final Map<Change.Id, CodeReviewCommit> newCommits;
CherryPick(final SubmitStrategy.Arguments args, CherryPick(final SubmitStrategy.Arguments args,
final PatchSetInfoFactory patchSetInfoFactory, final PatchSetInfoFactory patchSetInfoFactory,
final Provider<String> urlProvider, final ApprovalTypes approvalTypes, final Provider<String> urlProvider, final LabelTypes labelTypes,
final GitReferenceUpdated gitRefUpdated) { final GitReferenceUpdated gitRefUpdated) {
super(args); super(args);
this.patchSetInfoFactory = patchSetInfoFactory; this.patchSetInfoFactory = patchSetInfoFactory;
this.urlProvider = urlProvider; this.urlProvider = urlProvider;
this.approvalTypes = approvalTypes; this.labelTypes = labelTypes;
this.gitRefUpdated = gitRefUpdated; this.gitRefUpdated = gitRefUpdated;
this.newCommits = new HashMap<Change.Id, CodeReviewCommit>(); this.newCommits = new HashMap<Change.Id, CodeReviewCommit>();
} }
@@ -163,7 +163,7 @@ public class CherryPick extends SubmitStrategy {
} }
final String cherryPickCmtMsg = final String cherryPickCmtMsg =
createCherryPickCommitMessage(n, approvalTypes, urlProvider, args.db, createCherryPickCommitMessage(n, labelTypes, urlProvider, args.db,
args.identifiedUserFactory); args.identifiedUserFactory);
final CodeReviewCommit newCommit = final CodeReviewCommit newCommit =

View File

@@ -26,8 +26,8 @@ import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.ListMultimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.ChangeHooks; import com.google.gerrit.common.ChangeHooks;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.ApprovalTypes; import com.google.gerrit.common.data.LabelTypes;
import com.google.gerrit.common.data.Capable; import com.google.gerrit.common.data.Capable;
import com.google.gerrit.common.data.SubmitTypeRecord; import com.google.gerrit.common.data.SubmitTypeRecord;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
@@ -130,7 +130,7 @@ public class MergeOp {
private final GitReferenceUpdated gitRefUpdated; private final GitReferenceUpdated gitRefUpdated;
private final MergedSender.Factory mergedSenderFactory; private final MergedSender.Factory mergedSenderFactory;
private final MergeFailSender.Factory mergeFailSenderFactory; private final MergeFailSender.Factory mergeFailSenderFactory;
private final ApprovalTypes approvalTypes; private final LabelTypes labelTypes;
private final PatchSetInfoFactory patchSetInfoFactory; private final PatchSetInfoFactory patchSetInfoFactory;
private final IdentifiedUser.GenericFactory identifiedUserFactory; private final IdentifiedUser.GenericFactory identifiedUserFactory;
private final ChangeControl.GenericFactory changeControlFactory; private final ChangeControl.GenericFactory changeControlFactory;
@@ -164,7 +164,7 @@ public class MergeOp {
final ProjectCache pc, final FunctionState.Factory fs, final ProjectCache pc, final FunctionState.Factory fs,
final GitReferenceUpdated gru, final MergedSender.Factory msf, final GitReferenceUpdated gru, final MergedSender.Factory msf,
final MergeFailSender.Factory mfsf, final MergeFailSender.Factory mfsf,
final ApprovalTypes approvalTypes, final PatchSetInfoFactory psif, final LabelTypes labelTypes, final PatchSetInfoFactory psif,
final IdentifiedUser.GenericFactory iuf, final IdentifiedUser.GenericFactory iuf,
final ChangeControl.GenericFactory changeControlFactory, final ChangeControl.GenericFactory changeControlFactory,
final MergeQueue mergeQueue, @Assisted final Branch.NameKey branch, final MergeQueue mergeQueue, @Assisted final Branch.NameKey branch,
@@ -182,7 +182,7 @@ public class MergeOp {
gitRefUpdated = gru; gitRefUpdated = gru;
mergedSenderFactory = msf; mergedSenderFactory = msf;
mergeFailSenderFactory = mfsf; mergeFailSenderFactory = mfsf;
this.approvalTypes = approvalTypes; this.labelTypes = labelTypes;
patchSetInfoFactory = psif; patchSetInfoFactory = psif;
identifiedUserFactory = iuf; identifiedUserFactory = iuf;
this.changeControlFactory = changeControlFactory; this.changeControlFactory = changeControlFactory;
@@ -936,8 +936,8 @@ public class MergeOp {
c, c,
identifiedUserFactory.create(c.getOwner())), identifiedUserFactory.create(c.getOwner())),
merged, approvals); merged, approvals);
for (ApprovalType at : approvalTypes.getApprovalTypes()) { for (LabelType lt : labelTypes.getLabelTypes()) {
CategoryFunction.forType(at).run(at, fs); CategoryFunction.forType(lt).run(lt, fs);
} }
for (PatchSetApproval a : approvals) { for (PatchSetApproval a : approvals) {
if (a.getValue() > 0 if (a.getValue() > 0

View File

@@ -14,8 +14,8 @@
package com.google.gerrit.server.git; package com.google.gerrit.server.git;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.ApprovalTypes; import com.google.gerrit.common.data.LabelTypes;
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.ApprovalCategory;
import com.google.gerrit.reviewdb.client.Branch; import com.google.gerrit.reviewdb.client.Branch;
@@ -165,7 +165,7 @@ public class MergeUtil {
} }
public static String createCherryPickCommitMessage(final CodeReviewCommit n, public static String createCherryPickCommitMessage(final CodeReviewCommit n,
final ApprovalTypes approvalTypes, final Provider<String> urlProvider, final LabelTypes labelTypes, final Provider<String> urlProvider,
final ReviewDb db, final IdentifiedUser.GenericFactory identifiedUserFactory) { final ReviewDb db, final IdentifiedUser.GenericFactory identifiedUserFactory) {
final List<FooterLine> footers = n.getFooterLines(); final List<FooterLine> footers = n.getFooterLines();
final StringBuilder msgbuf = new StringBuilder(); final StringBuilder msgbuf = new StringBuilder();
@@ -254,12 +254,12 @@ public class MergeUtil {
} else if (VRIF.equals(a.getCategoryId())) { } else if (VRIF.equals(a.getCategoryId())) {
tag = "Tested-by"; tag = "Tested-by";
} else { } else {
final ApprovalType at = approvalTypes.byId(a.getCategoryId().get()); final LabelType lt = labelTypes.byId(a.getCategoryId().get());
if (at == null) { if (lt == null) {
// TODO: Support arbitrary labels. // TODO: Support arbitrary labels.
continue; continue;
} }
tag = at.getName(); tag = lt.getName();
} }
if (!contains(footers, new FooterKey(tag), identbuf.toString())) { if (!contains(footers, new FooterKey(tag), identbuf.toString())) {

View File

@@ -14,7 +14,7 @@
package com.google.gerrit.server.git; package com.google.gerrit.server.git;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
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;
@@ -51,7 +51,7 @@ class ReviewNoteHeaderFormatter {
sb.append("Change-Id: ").append(changeKey.get()).append("\n"); sb.append("Change-Id: ").append(changeKey.get()).append("\n");
} }
void appendApproval(ApprovalType type, short value, Account user) { void appendApproval(LabelType type, short value, Account user) {
sb.append(type.getName()); sb.append(type.getName());
sb.append(value < 0 ? "-" : "+").append(Math.abs(value)).append(": "); sb.append(value < 0 ? "-" : "+").append(Math.abs(value)).append(": ");
appendUserData(user); appendUserData(user);

View File

@@ -14,7 +14,7 @@
package com.google.gerrit.server.git; package com.google.gerrit.server.git;
import com.google.gerrit.common.data.ApprovalTypes; import com.google.gerrit.common.data.LabelTypes;
import com.google.gerrit.reviewdb.client.Branch; import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.reviewdb.client.Project.SubmitType; import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.reviewdb.server.ReviewDb;
@@ -49,7 +49,7 @@ public class SubmitStrategyFactory {
private final PersonIdent myIdent; private final PersonIdent myIdent;
private final PatchSetInfoFactory patchSetInfoFactory; private final PatchSetInfoFactory patchSetInfoFactory;
private final Provider<String> urlProvider; private final Provider<String> urlProvider;
private final ApprovalTypes approvalTypes; private final LabelTypes labelTypes;
private final GitReferenceUpdated gitRefUpdated; private final GitReferenceUpdated gitRefUpdated;
private final RebaseChange rebaseChange; private final RebaseChange rebaseChange;
@@ -59,13 +59,13 @@ public class SubmitStrategyFactory {
@GerritPersonIdent final PersonIdent myIdent, @GerritPersonIdent final PersonIdent myIdent,
final PatchSetInfoFactory patchSetInfoFactory, final PatchSetInfoFactory patchSetInfoFactory,
@CanonicalWebUrl @Nullable final Provider<String> urlProvider, @CanonicalWebUrl @Nullable final Provider<String> urlProvider,
final ApprovalTypes approvalTypes, final GitReferenceUpdated gitRefUpdated, final LabelTypes labelTypes, final GitReferenceUpdated gitRefUpdated,
final RebaseChange rebaseChange) { final RebaseChange rebaseChange) {
this.identifiedUserFactory = identifiedUserFactory; this.identifiedUserFactory = identifiedUserFactory;
this.myIdent = myIdent; this.myIdent = myIdent;
this.patchSetInfoFactory = patchSetInfoFactory; this.patchSetInfoFactory = patchSetInfoFactory;
this.urlProvider = urlProvider; this.urlProvider = urlProvider;
this.approvalTypes = approvalTypes; this.labelTypes = labelTypes;
this.gitRefUpdated = gitRefUpdated; this.gitRefUpdated = gitRefUpdated;
this.rebaseChange = rebaseChange; this.rebaseChange = rebaseChange;
} }
@@ -82,7 +82,7 @@ public class SubmitStrategyFactory {
switch (submitType) { switch (submitType) {
case CHERRY_PICK: case CHERRY_PICK:
return new CherryPick(args, patchSetInfoFactory, urlProvider, return new CherryPick(args, patchSetInfoFactory, urlProvider,
approvalTypes, gitRefUpdated); labelTypes, gitRefUpdated);
case FAST_FORWARD_ONLY: case FAST_FORWARD_ONLY:
return new FastForwardOnly(args); return new FastForwardOnly(args);
case MERGE_ALWAYS: case MERGE_ALWAYS:

View File

@@ -16,8 +16,8 @@ package com.google.gerrit.server.mail;
import com.google.common.collect.HashBasedTable; import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table; import com.google.common.collect.Table;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.ApprovalTypes; import com.google.gerrit.common.data.LabelTypes;
import com.google.gerrit.common.data.LabelValue; import com.google.gerrit.common.data.LabelValue;
import com.google.gerrit.common.errors.EmailException; import com.google.gerrit.common.errors.EmailException;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
@@ -34,12 +34,12 @@ public class MergedSender extends ReplyToChangeSender {
public MergedSender create(Change change); public MergedSender create(Change change);
} }
private final ApprovalTypes approvalTypes; private final LabelTypes labelTypes;
@Inject @Inject
public MergedSender(EmailArguments ea, ApprovalTypes at, @Assisted Change c) { public MergedSender(EmailArguments ea, LabelTypes lt, @Assisted Change c) {
super(ea, c, "merged"); super(ea, c, "merged");
approvalTypes = at; labelTypes = lt;
} }
@Override @Override
@@ -63,7 +63,7 @@ public class MergedSender extends ReplyToChangeSender {
Table<Account.Id, String, PatchSetApproval> neg = HashBasedTable.create(); Table<Account.Id, String, PatchSetApproval> neg = HashBasedTable.create();
for (PatchSetApproval ca : args.db.get().patchSetApprovals() for (PatchSetApproval ca : args.db.get().patchSetApprovals()
.byPatchSet(patchSet.getId())) { .byPatchSet(patchSet.getId())) {
ApprovalType lt = approvalTypes.byId(ca.getCategoryId().get()); LabelType lt = labelTypes.byId(ca.getCategoryId().get());
if (lt == null) { if (lt == null) {
continue; continue;
} }
@@ -93,7 +93,7 @@ public class MergedSender extends ReplyToChangeSender {
txt.append(getNameFor(id)); txt.append(getNameFor(id));
txt.append(": "); txt.append(": ");
boolean first = true; boolean first = true;
for (ApprovalType lt : approvalTypes.getApprovalTypes()) { for (LabelType lt : labelTypes.getLabelTypes()) {
PatchSetApproval ca = approvals.get(id, lt.getName()); PatchSetApproval ca = approvals.get(id, lt.getName());
if (ca == null) { if (ca == null) {
continue; continue;

View File

@@ -15,7 +15,7 @@
package com.google.gerrit.server.query.change; package com.google.gerrit.server.query.change;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.gerrit.common.data.ApprovalTypes; import com.google.gerrit.common.data.LabelTypes;
import com.google.gerrit.common.data.GroupReference; import com.google.gerrit.common.data.GroupReference;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.AccountGroup;
@@ -110,7 +110,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
final ChangeControl.GenericFactory changeControlGenericFactory; final ChangeControl.GenericFactory changeControlGenericFactory;
final AccountResolver accountResolver; final AccountResolver accountResolver;
final GroupBackend groupBackend; final GroupBackend groupBackend;
final ApprovalTypes approvalTypes; final LabelTypes labelTypes;
final AllProjectsName allProjectsName; final AllProjectsName allProjectsName;
final PatchListCache patchListCache; final PatchListCache patchListCache;
final GitRepositoryManager repoManager; final GitRepositoryManager repoManager;
@@ -124,7 +124,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
ChangeControl.GenericFactory changeControlGenericFactory, ChangeControl.GenericFactory changeControlGenericFactory,
AccountResolver accountResolver, AccountResolver accountResolver,
GroupBackend groupBackend, GroupBackend groupBackend,
ApprovalTypes approvalTypes, LabelTypes labelTypes,
AllProjectsName allProjectsName, AllProjectsName allProjectsName,
PatchListCache patchListCache, PatchListCache patchListCache,
GitRepositoryManager repoManager, GitRepositoryManager repoManager,
@@ -136,7 +136,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
this.changeControlGenericFactory = changeControlGenericFactory; this.changeControlGenericFactory = changeControlGenericFactory;
this.accountResolver = accountResolver; this.accountResolver = accountResolver;
this.groupBackend = groupBackend; this.groupBackend = groupBackend;
this.approvalTypes = approvalTypes; this.labelTypes = labelTypes;
this.allProjectsName = allProjectsName; this.allProjectsName = allProjectsName;
this.patchListCache = patchListCache; this.patchListCache = patchListCache;
this.repoManager = repoManager; this.repoManager = repoManager;
@@ -302,7 +302,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
@Operator @Operator
public Predicate<ChangeData> label(String name) { public Predicate<ChangeData> label(String name) {
return new LabelPredicate(args.changeControlGenericFactory, return new LabelPredicate(args.changeControlGenericFactory,
args.userFactory, args.dbProvider, args.approvalTypes, name); args.userFactory, args.dbProvider, args.labelTypes, name);
} }
@Operator @Operator

View File

@@ -14,8 +14,8 @@
package com.google.gerrit.server.query.change; package com.google.gerrit.server.query.change;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.ApprovalTypes; import com.google.gerrit.common.data.LabelTypes;
import com.google.gerrit.common.data.Permission; import com.google.gerrit.common.data.Permission;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Change;
@@ -57,7 +57,7 @@ class LabelPredicate extends OperatorPredicate<ChangeData> {
abstract boolean match(int psValue, int expValue); abstract boolean match(int psValue, int expValue);
} }
private static ApprovalType type(ApprovalTypes types, String toFind) { private 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);
} }
@@ -66,19 +66,19 @@ class LabelPredicate extends OperatorPredicate<ChangeData> {
return types.byId(toFind); return types.byId(toFind);
} }
for (ApprovalType at : types.getApprovalTypes()) { for (LabelType lt : types.getLabelTypes()) {
if (toFind.equalsIgnoreCase(at.getName())) { if (toFind.equalsIgnoreCase(lt.getName())) {
return at; return lt;
} }
} }
for (ApprovalType at : types.getApprovalTypes()) { for (LabelType lt : types.getLabelTypes()) {
if (toFind.equalsIgnoreCase(at.getAbbreviatedName())) { if (toFind.equalsIgnoreCase(lt.getAbbreviatedName())) {
return at; return lt;
} }
} }
return ApprovalType.withDefaultValues(toFind.substring(0, 4), toFind); return LabelType.withDefaultValues(toFind.substring(0, 4), toFind);
} }
private static Test op(String op) { private static Test op(String op) {
@@ -107,13 +107,13 @@ class LabelPredicate extends OperatorPredicate<ChangeData> {
private final IdentifiedUser.GenericFactory userFactory; private final IdentifiedUser.GenericFactory userFactory;
private final Provider<ReviewDb> dbProvider; private final Provider<ReviewDb> dbProvider;
private final Test test; private final Test test;
private final ApprovalType type; private final LabelType type;
private final String permissionName; private final String permissionName;
private final int expVal; private final int expVal;
LabelPredicate(ChangeControl.GenericFactory ccFactory, LabelPredicate(ChangeControl.GenericFactory ccFactory,
IdentifiedUser.GenericFactory userFactory, Provider<ReviewDb> dbProvider, IdentifiedUser.GenericFactory userFactory, Provider<ReviewDb> dbProvider,
ApprovalTypes types, String value) { LabelTypes types, String value) {
super(ChangeQueryBuilder.FIELD_LABEL, value); super(ChangeQueryBuilder.FIELD_LABEL, value);
this.ccFactory = ccFactory; this.ccFactory = ccFactory;
this.userFactory = userFactory; this.userFactory = userFactory;

View File

@@ -14,7 +14,7 @@
package com.google.gerrit.server.workflow; package com.google.gerrit.server.workflow;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.reviewdb.client.ApprovalCategory; import com.google.gerrit.reviewdb.client.ApprovalCategory;
import com.google.gerrit.reviewdb.client.PatchSetApproval; import com.google.gerrit.reviewdb.client.PatchSetApproval;
@@ -43,7 +43,7 @@ public abstract class CategoryFunction {
* @return the function implementation; {@link NoOpFunction} if the function * @return the function implementation; {@link NoOpFunction} if the function
* is not known to Gerrit and thus cannot be executed. * is not known to Gerrit and thus cannot be executed.
*/ */
public static CategoryFunction forType(ApprovalType type) { public static CategoryFunction forType(LabelType type) {
CategoryFunction r = all.get(type.getFunctionName()); CategoryFunction r = all.get(type.getFunctionName());
return r != null ? r : new NoOpFunction(); return r != null ? r : new NoOpFunction();
} }
@@ -85,9 +85,9 @@ public abstract class CategoryFunction {
* state.valid(at, !neg &amp;&amp; pos); * state.valid(at, !neg &amp;&amp; pos);
* </pre> * </pre>
* *
* @param at the cached category description to process. * @param lt the cached category description to process.
* @param state state to read approvals and project rights from, and to update * @param state state to read approvals and project rights from, and to update
* the valid status into. * the valid status into.
*/ */
public abstract void run(ApprovalType at, FunctionState state); public abstract void run(LabelType lt, FunctionState state);
} }

View File

@@ -14,8 +14,8 @@
package com.google.gerrit.server.workflow; package com.google.gerrit.server.workflow;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.ApprovalTypes; import com.google.gerrit.common.data.LabelTypes;
import com.google.gerrit.common.data.LabelValue; import com.google.gerrit.common.data.LabelValue;
import com.google.gerrit.common.data.Permission; import com.google.gerrit.common.data.Permission;
import com.google.gerrit.common.data.PermissionRange; import com.google.gerrit.common.data.PermissionRange;
@@ -42,7 +42,7 @@ public class FunctionState {
Collection<PatchSetApproval> all); Collection<PatchSetApproval> all);
} }
private final ApprovalTypes approvalTypes; private final LabelTypes labelTypes;
private final IdentifiedUser.GenericFactory userFactory; private final IdentifiedUser.GenericFactory userFactory;
private final Map<String, Collection<PatchSetApproval>> approvals = private final Map<String, Collection<PatchSetApproval>> approvals =
@@ -52,11 +52,11 @@ public class FunctionState {
private final Change change; private final Change change;
@Inject @Inject
FunctionState(final ApprovalTypes approvalTypes, FunctionState(final LabelTypes labelTypes,
final IdentifiedUser.GenericFactory userFactory, final IdentifiedUser.GenericFactory userFactory,
@Assisted final ChangeControl c, @Assisted final PatchSet.Id psId, @Assisted final ChangeControl c, @Assisted final PatchSet.Id psId,
@Assisted final Collection<PatchSetApproval> all) { @Assisted final Collection<PatchSetApproval> all) {
this.approvalTypes = approvalTypes; this.labelTypes = labelTypes;
this.userFactory = userFactory; this.userFactory = userFactory;
callerChangeControl = c; callerChangeControl = c;
@@ -68,10 +68,10 @@ public class FunctionState {
approvals.get(ca.getCategoryId().get()); approvals.get(ca.getCategoryId().get());
if (l == null) { if (l == null) {
l = new ArrayList<PatchSetApproval>(); l = new ArrayList<PatchSetApproval>();
ApprovalType at = approvalTypes.byId(ca.getCategoryId().get()); LabelType lt = labelTypes.byId(ca.getCategoryId().get());
if (at != null) { if (lt != null) {
// TODO: Support arbitrary labels // TODO: Support arbitrary labels
approvals.put(at.getName(), l); approvals.put(lt.getName(), l);
} }
} }
l.add(ca); l.add(ca);
@@ -79,20 +79,20 @@ public class FunctionState {
} }
} }
List<ApprovalType> getApprovalTypes() { List<LabelType> getLabelTypes() {
return approvalTypes.getApprovalTypes(); return labelTypes.getLabelTypes();
} }
Change getChange() { Change getChange() {
return change; return change;
} }
public void valid(final ApprovalType at, final boolean v) { public void valid(final LabelType lt, final boolean v) {
valid.put(id(at), v); valid.put(id(lt), v);
} }
public boolean isValid(final ApprovalType at) { public boolean isValid(final LabelType lt) {
return isValid(at.getName()); return isValid(lt.getName());
} }
public boolean isValid(final String labelName) { public boolean isValid(final String labelName) {
@@ -100,8 +100,8 @@ public class FunctionState {
return b != null && b; return b != null && b;
} }
public Collection<PatchSetApproval> getApprovals(final ApprovalType at) { public Collection<PatchSetApproval> getApprovals(final LabelType lt) {
return getApprovals(at.getName()); return getApprovals(lt.getName());
} }
public Collection<PatchSetApproval> getApprovals(final String labelName) { public Collection<PatchSetApproval> getApprovals(final String labelName) {
@@ -114,14 +114,14 @@ public class FunctionState {
* case the type was modified since the approval was originally granted. * case the type was modified since the approval was originally granted.
* <p> * <p>
*/ */
private void applyTypeFloor(final ApprovalType at, final PatchSetApproval a) { private void applyTypeFloor(final LabelType lt, final PatchSetApproval a) {
final LabelValue atMin = at.getMin(); final LabelValue atMin = lt.getMin();
if (atMin != null && a.getValue() < atMin.getValue()) { if (atMin != null && a.getValue() < atMin.getValue()) {
a.setValue(atMin.getValue()); a.setValue(atMin.getValue());
} }
final LabelValue atMax = at.getMax(); final LabelValue atMax = lt.getMax();
if (atMax != null && a.getValue() > atMax.getValue()) { if (atMax != null && a.getValue() > atMax.getValue()) {
a.setValue(atMax.getValue()); a.setValue(atMax.getValue());
} }
@@ -136,8 +136,8 @@ public class FunctionState {
* of them is used. * of them is used.
* <p> * <p>
*/ */
private void applyRightFloor(final ApprovalType at, final PatchSetApproval a) { private void applyRightFloor(final LabelType lt, final PatchSetApproval a) {
final String permission = Permission.forLabel(at.getName()); final String permission = Permission.forLabel(lt.getName());
final IdentifiedUser user = userFactory.create(a.getAccountId()); final IdentifiedUser user = userFactory.create(a.getAccountId());
final PermissionRange range = controlFor(user).getRange(permission); final PermissionRange range = controlFor(user).getRange(permission);
a.setValue((short) range.squash(a.getValue())); a.setValue((short) range.squash(a.getValue()));
@@ -148,12 +148,12 @@ public class FunctionState {
} }
/** Run <code>applyTypeFloor</code>, <code>applyRightFloor</code>. */ /** Run <code>applyTypeFloor</code>, <code>applyRightFloor</code>. */
public void normalize(final ApprovalType at, final PatchSetApproval ca) { public void normalize(final LabelType lt, final PatchSetApproval ca) {
applyTypeFloor(at, ca); applyTypeFloor(lt, ca);
applyRightFloor(at, ca); applyRightFloor(lt, ca);
} }
private static String id(final ApprovalType at) { private static String id(final LabelType lt) {
return at.getId(); return lt.getId();
} }
} }

View File

@@ -14,7 +14,7 @@
package com.google.gerrit.server.workflow; package com.google.gerrit.server.workflow;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.reviewdb.client.ApprovalCategory; import com.google.gerrit.reviewdb.client.ApprovalCategory;
import com.google.gerrit.reviewdb.client.PatchSetApproval; import com.google.gerrit.reviewdb.client.PatchSetApproval;
@@ -33,16 +33,16 @@ public class MaxNoBlock extends CategoryFunction {
public static String NAME = "MaxNoBlock"; public static String NAME = "MaxNoBlock";
@Override @Override
public void run(final ApprovalType at, final FunctionState state) { public void run(final LabelType lt, final FunctionState state) {
boolean passed = false; boolean passed = false;
for (final PatchSetApproval a : state.getApprovals(at)) { for (final PatchSetApproval a : state.getApprovals(lt)) {
state.normalize(at, a); state.normalize(lt, a);
passed |= at.isMaxPositive(a); passed |= lt.isMaxPositive(a);
} }
// The type must have at least one max positive (a full accept). // The type must have at least one max positive (a full accept).
// //
state.valid(at, passed); state.valid(lt, passed);
} }
} }

View File

@@ -14,7 +14,7 @@
package com.google.gerrit.server.workflow; package com.google.gerrit.server.workflow;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.reviewdb.client.ApprovalCategory; import com.google.gerrit.reviewdb.client.ApprovalCategory;
import com.google.gerrit.reviewdb.client.PatchSetApproval; import com.google.gerrit.reviewdb.client.PatchSetApproval;
@@ -45,19 +45,19 @@ public class MaxWithBlock extends CategoryFunction {
public static String NAME = "MaxWithBlock"; public static String NAME = "MaxWithBlock";
@Override @Override
public void run(final ApprovalType at, final FunctionState state) { public void run(final LabelType lt, final FunctionState state) {
boolean rejected = false; boolean rejected = false;
boolean passed = false; boolean passed = false;
for (final PatchSetApproval a : state.getApprovals(at)) { for (final PatchSetApproval a : state.getApprovals(lt)) {
state.normalize(at, a); state.normalize(lt, a);
rejected |= at.isMaxNegative(a); rejected |= lt.isMaxNegative(a);
passed |= at.isMaxPositive(a); passed |= lt.isMaxPositive(a);
} }
// The type must not have had its max negative (a forceful reject) // The type must not have had its max negative (a forceful reject)
// and must have at least one max positive (a full accept). // and must have at least one max positive (a full accept).
// //
state.valid(at, !rejected && passed); state.valid(lt, !rejected && passed);
} }
} }

View File

@@ -14,14 +14,14 @@
package com.google.gerrit.server.workflow; package com.google.gerrit.server.workflow;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
/** A function that does nothing. */ /** A function that does nothing. */
public class NoBlock extends CategoryFunction { public class NoBlock extends CategoryFunction {
public static String NAME = "NoBlock"; public static String NAME = "NoBlock";
@Override @Override
public void run(final ApprovalType at, final FunctionState state) { public void run(final LabelType lt, final FunctionState state) {
state.valid(at, true); state.valid(lt, true);
} }
} }

View File

@@ -14,13 +14,13 @@
package com.google.gerrit.server.workflow; package com.google.gerrit.server.workflow;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
/** A function that does nothing. */ /** A function that does nothing. */
public class NoOpFunction extends CategoryFunction { public class NoOpFunction extends CategoryFunction {
public static String NAME = "NoOp"; public static String NAME = "NoOp";
@Override @Override
public void run(final ApprovalType at, final FunctionState state) { public void run(final LabelType lt, final FunctionState state) {
} }
} }

View File

@@ -2,8 +2,8 @@
package gerrit; package gerrit;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.ApprovalTypes; import com.google.gerrit.common.data.LabelTypes;
import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.PatchSetApproval; import com.google.gerrit.reviewdb.client.PatchSetApproval;
import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.reviewdb.server.ReviewDb;
@@ -46,7 +46,7 @@ class PRED__load_commit_labels_1 extends Predicate.P1 {
ReviewDb db = StoredValues.REVIEW_DB.get(engine); ReviewDb db = StoredValues.REVIEW_DB.get(engine);
PatchSet patchSet = StoredValues.PATCH_SET.get(engine); PatchSet patchSet = StoredValues.PATCH_SET.get(engine);
ChangeData cd = StoredValues.CHANGE_DATA.getOrNull(engine); ChangeData cd = StoredValues.CHANGE_DATA.getOrNull(engine);
ApprovalTypes types = env.getInjector().getInstance(ApprovalTypes.class); LabelTypes types = env.getInjector().getInstance(LabelTypes.class);
Iterable<PatchSetApproval> approvals; Iterable<PatchSetApproval> approvals;
if (cd != null) { if (cd != null) {
@@ -60,7 +60,7 @@ class PRED__load_commit_labels_1 extends Predicate.P1 {
continue; continue;
} }
ApprovalType t = types.byId(a.getCategoryId().get()); LabelType t = types.byId(a.getCategoryId().get());
if (t == null) { if (t == null) {
continue; continue;
} }

View File

@@ -14,8 +14,8 @@
package gerrit; package gerrit;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.ApprovalTypes; import com.google.gerrit.common.data.LabelTypes;
import com.google.gerrit.rules.PrologEnvironment; import com.google.gerrit.rules.PrologEnvironment;
import com.googlecode.prolog_cafe.lang.IntegerTerm; import com.googlecode.prolog_cafe.lang.IntegerTerm;
@@ -54,9 +54,9 @@ class PRED_get_legacy_approval_types_1 extends Predicate.P1 {
Term a1 = arg1.dereference(); Term a1 = arg1.dereference();
PrologEnvironment env = (PrologEnvironment) engine.control; PrologEnvironment env = (PrologEnvironment) engine.control;
ApprovalTypes types = env.getInjector().getInstance(ApprovalTypes.class); LabelTypes types = env.getInjector().getInstance(LabelTypes.class);
List<ApprovalType> list = types.getApprovalTypes(); List<LabelType> list = types.getLabelTypes();
Term head = Prolog.Nil; Term head = Prolog.Nil;
for (int idx = list.size() - 1; 0 <= idx; idx--) { for (int idx = list.size() - 1; 0 <= idx; idx--) {
head = new ListTerm(export(list.get(idx)), head); head = new ListTerm(export(list.get(idx)), head);
@@ -71,7 +71,7 @@ class PRED_get_legacy_approval_types_1 extends Predicate.P1 {
static final SymbolTerm symApprovalType = SymbolTerm.intern( static final SymbolTerm symApprovalType = SymbolTerm.intern(
"approval_type", 5); "approval_type", 5);
static Term export(ApprovalType type) { static Term export(LabelType type) {
return new StructureTerm(symApprovalType, return new StructureTerm(symApprovalType,
SymbolTerm.intern(type.getName()), SymbolTerm.intern(type.getName()),
SymbolTerm.intern(type.getId()), SymbolTerm.intern(type.getId()),

View File

@@ -14,8 +14,8 @@
package com.google.gerrit.rules; package com.google.gerrit.rules;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.ApprovalTypes; import com.google.gerrit.common.data.LabelTypes;
import com.google.gerrit.common.data.LabelValue; import com.google.gerrit.common.data.LabelValue;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
@@ -26,7 +26,7 @@ public class GerritCommonTest extends PrologTestCase {
public void setUp() throws Exception { public void setUp() throws Exception {
super.setUp(); super.setUp();
final ApprovalTypes types = new ApprovalTypes(Arrays.asList( final LabelTypes types = new LabelTypes(Arrays.asList(
category(0, "CRVW", "Code-Review", category(0, "CRVW", "Code-Review",
value(2, "Looks good to me, approved"), value(2, "Looks good to me, approved"),
value(1, "Looks good to me, but someone else must approve"), value(1, "Looks good to me, but someone else must approve"),
@@ -42,7 +42,7 @@ public class GerritCommonTest extends PrologTestCase {
load("gerrit", "gerrit_common_test.pl", new AbstractModule() { load("gerrit", "gerrit_common_test.pl", new AbstractModule() {
@Override @Override
protected void configure() { protected void configure() {
bind(ApprovalTypes.class).toInstance(types); bind(LabelTypes.class).toInstance(types);
} }
}); });
} }
@@ -51,9 +51,9 @@ public class GerritCommonTest extends PrologTestCase {
return new LabelValue((short) value, text); return new LabelValue((short) value, text);
} }
private static ApprovalType category(int pos, String id, String name, private static LabelType category(int pos, String id, String name,
LabelValue... values) { LabelValue... values) {
ApprovalType type = new ApprovalType(id, name, Arrays.asList(values)); LabelType type = new LabelType(id, name, Arrays.asList(values));
type.setPosition((short) pos); type.setPosition((short) pos);
return type; return type;
} }

View File

@@ -14,7 +14,7 @@
package com.google.gerrit.sshd.commands; package com.google.gerrit.sshd.commands;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.LabelValue; import com.google.gerrit.common.data.LabelValue;
import org.kohsuke.args4j.CmdLineException; import org.kohsuke.args4j.CmdLineException;
@@ -30,11 +30,11 @@ import java.lang.annotation.Annotation;
final class ApproveOption implements Option, Setter<Short> { final class ApproveOption implements Option, Setter<Short> {
private final String name; private final String name;
private final String usage; private final String usage;
private final ApprovalType type; private final LabelType type;
private Short value; private Short value;
ApproveOption(final String name, final String usage, final ApprovalType type) { ApproveOption(final String name, final String usage, final LabelType type) {
this.name = name; this.name = name;
this.usage = usage; this.usage = usage;
this.type = type; this.type = type;

View File

@@ -16,8 +16,8 @@ package com.google.gerrit.sshd.commands;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.gerrit.common.data.ApprovalType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.ApprovalTypes; import com.google.gerrit.common.data.LabelTypes;
import com.google.gerrit.common.data.LabelValue; import com.google.gerrit.common.data.LabelValue;
import com.google.gerrit.common.data.ReviewResult; import com.google.gerrit.common.data.ReviewResult;
import com.google.gerrit.common.data.ReviewResult.Error.Type; import com.google.gerrit.common.data.ReviewResult.Error.Type;
@@ -116,7 +116,7 @@ public class ReviewCommand extends SshCommand {
private ReviewDb db; private ReviewDb db;
@Inject @Inject
private ApprovalTypes approvalTypes; private LabelTypes labelTypes;
@Inject @Inject
private DeleteDraftPatchSet.Factory deleteDraftPatchSetFactory; private DeleteDraftPatchSet.Factory deleteDraftPatchSetFactory;
@@ -400,7 +400,7 @@ public class ReviewCommand extends SshCommand {
protected void parseCommandLine() throws UnloggedFailure { protected void parseCommandLine() throws UnloggedFailure {
optionList = new ArrayList<ApproveOption>(); optionList = new ArrayList<ApproveOption>();
for (ApprovalType type : approvalTypes.getApprovalTypes()) { for (LabelType type : labelTypes.getLabelTypes()) {
String usage = ""; String usage = "";
usage = "score for " + type.getName() + "\n"; usage = "score for " + type.getName() + "\n";