Rename ApprovalType(s) to LabelType(s)
Change-Id: Icb860eb84d481d519aa0facbef99392b45784843
This commit is contained in:
@@ -46,7 +46,7 @@ public class GerritConfig implements Cloneable {
|
||||
protected String sshdAddress;
|
||||
protected String editFullNameUrl;
|
||||
protected Project.NameKey wildProject;
|
||||
protected ApprovalTypes approvalTypes;
|
||||
protected LabelTypes labelTypes;
|
||||
protected Set<Account.FieldName> editableAccountFields;
|
||||
protected List<RegexFindReplace> commentLinks;
|
||||
protected boolean documentationAvailable;
|
||||
@@ -196,12 +196,12 @@ public class GerritConfig implements Cloneable {
|
||||
wildProject = wp;
|
||||
}
|
||||
|
||||
public ApprovalTypes getApprovalTypes() {
|
||||
return approvalTypes;
|
||||
public LabelTypes getLabelTypes() {
|
||||
return labelTypes;
|
||||
}
|
||||
|
||||
public void setApprovalTypes(final ApprovalTypes at) {
|
||||
approvalTypes = at;
|
||||
public void setLabelTypes(final LabelTypes at) {
|
||||
labelTypes = at;
|
||||
}
|
||||
|
||||
public boolean canEdit(final Account.FieldName f) {
|
||||
|
@@ -25,29 +25,29 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ApprovalType {
|
||||
public static ApprovalType fromApprovalCategory(ApprovalCategory ac,
|
||||
public class LabelType {
|
||||
public static LabelType fromApprovalCategory(ApprovalCategory ac,
|
||||
List<ApprovalCategoryValue> acvs) {
|
||||
List<LabelValue> values = new ArrayList<LabelValue>(acvs.size());
|
||||
for (ApprovalCategoryValue acv : acvs) {
|
||||
values.add(
|
||||
new LabelValue(acv.getValue(), acv.getName()));
|
||||
}
|
||||
ApprovalType at =
|
||||
new ApprovalType(ac.getId().get(), ac.getLabelName(), values);
|
||||
at.setAbbreviatedName(ac.getAbbreviatedName());
|
||||
at.setFunctionName(ac.getFunctionName());
|
||||
at.setCopyMinScore(ac.isCopyMinScore());
|
||||
at.setPosition(ac.getPosition());
|
||||
return at;
|
||||
LabelType lt = new LabelType(ac.getId().get(), ac.getLabelName(), values);
|
||||
lt.setAbbreviatedName(ac.getAbbreviatedName());
|
||||
lt.setFunctionName(ac.getFunctionName());
|
||||
lt.setCopyMinScore(ac.isCopyMinScore());
|
||||
lt.setPosition(ac.getPosition());
|
||||
return lt;
|
||||
}
|
||||
|
||||
public static ApprovalType withDefaultValues(String id, String name) {
|
||||
public static LabelType withDefaultValues(String id, String name) {
|
||||
checkId(id);
|
||||
checkName(name);
|
||||
List<LabelValue> values = new ArrayList<LabelValue>(2);
|
||||
values.add(new LabelValue((short) 0, "Rejected"));
|
||||
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) {
|
||||
@@ -101,10 +101,10 @@ public class ApprovalType {
|
||||
private transient List<Integer> intList;
|
||||
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.name = checkName(name);
|
||||
values = new ArrayList<LabelValue>(valueList);
|
@@ -18,32 +18,32 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ApprovalTypes {
|
||||
protected List<ApprovalType> approvalTypes;
|
||||
private transient Map<String, ApprovalType> byId;
|
||||
private transient Map<String, ApprovalType> byLabel;
|
||||
public class LabelTypes {
|
||||
protected List<LabelType> labelTypes;
|
||||
private transient Map<String, LabelType> byId;
|
||||
private transient Map<String, LabelType> byLabel;
|
||||
|
||||
protected ApprovalTypes() {
|
||||
protected LabelTypes() {
|
||||
}
|
||||
|
||||
public ApprovalTypes(final List<ApprovalType> approvals) {
|
||||
approvalTypes = approvals;
|
||||
public LabelTypes(final List<LabelType> approvals) {
|
||||
labelTypes = approvals;
|
||||
byId();
|
||||
}
|
||||
|
||||
public List<ApprovalType> getApprovalTypes() {
|
||||
return approvalTypes;
|
||||
public List<LabelType> getLabelTypes() {
|
||||
return labelTypes;
|
||||
}
|
||||
|
||||
public ApprovalType byId(String id) {
|
||||
public LabelType byId(String id) {
|
||||
return byId().get(id);
|
||||
}
|
||||
|
||||
private Map<String, ApprovalType> byId() {
|
||||
private Map<String, LabelType> byId() {
|
||||
if (byId == null) {
|
||||
byId = new HashMap<String, ApprovalType>();
|
||||
if (approvalTypes != null) {
|
||||
for (final ApprovalType t : approvalTypes) {
|
||||
byId = new HashMap<String, LabelType>();
|
||||
if (labelTypes != null) {
|
||||
for (final LabelType t : labelTypes) {
|
||||
byId.put(t.getId(), t);
|
||||
}
|
||||
}
|
||||
@@ -51,15 +51,15 @@ public class ApprovalTypes {
|
||||
return byId;
|
||||
}
|
||||
|
||||
public ApprovalType byLabel(String labelName) {
|
||||
public LabelType byLabel(String labelName) {
|
||||
return byLabel().get(labelName.toLowerCase());
|
||||
}
|
||||
|
||||
private Map<String, ApprovalType> byLabel() {
|
||||
private Map<String, LabelType> byLabel() {
|
||||
if (byLabel == null) {
|
||||
byLabel = new HashMap<String, ApprovalType>();
|
||||
if (approvalTypes != null) {
|
||||
for (ApprovalType t : approvalTypes) {
|
||||
byLabel = new HashMap<String, LabelType>();
|
||||
if (labelTypes != null) {
|
||||
for (LabelType t : labelTypes) {
|
||||
byLabel.put(t.getName().toLowerCase(), t);
|
||||
}
|
||||
}
|
@@ -16,7 +16,7 @@ package com.google.gerrit.client.admin;
|
||||
|
||||
import com.google.gerrit.client.Gerrit;
|
||||
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.ProjectAccess;
|
||||
import com.google.gerrit.common.data.RefConfigSection;
|
||||
@@ -226,8 +226,7 @@ public class AccessSectionEditor extends Composite implements
|
||||
addPermission(varName, perms);
|
||||
}
|
||||
} else if (RefConfigSection.isValid(value.getName())) {
|
||||
for (ApprovalType t : Gerrit.getConfig().getApprovalTypes()
|
||||
.getApprovalTypes()) {
|
||||
for (LabelType t : Gerrit.getConfig().getLabelTypes().getLabelTypes()) {
|
||||
addPermission(Permission.LABEL + t.getName(), perms);
|
||||
}
|
||||
for (String varName : Util.C.permissionNames().keySet()) {
|
||||
|
@@ -18,7 +18,7 @@ import com.google.gerrit.client.Gerrit;
|
||||
import com.google.gerrit.client.rpc.GerritCallback;
|
||||
import com.google.gerrit.client.ui.SuggestUtil;
|
||||
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.GroupReference;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
@@ -260,12 +260,12 @@ public class PermissionEditor extends Composite implements Editor<Permission>,
|
||||
this.value = value;
|
||||
|
||||
if (value.isLabel()) {
|
||||
ApprovalType at = Gerrit.getConfig().getApprovalTypes().byLabel(value.getLabel());
|
||||
if (at != null) {
|
||||
LabelType lt = Gerrit.getConfig().getLabelTypes().byLabel(value.getLabel());
|
||||
if (lt != null) {
|
||||
validRange = new PermissionRange.WithDefaults(
|
||||
value.getName(),
|
||||
at.getMin().getValue(), at.getMax().getValue(),
|
||||
at.getMin().getValue(), at.getMax().getValue());
|
||||
lt.getMin().getValue(), lt.getMax().getValue(),
|
||||
lt.getMin().getValue(), lt.getMax().getValue());
|
||||
}
|
||||
} else if (GlobalCapability.isCapability(value.getName())) {
|
||||
validRange = GlobalCapability.getRange(value.getName());
|
||||
|
@@ -30,8 +30,8 @@ import com.google.gerrit.client.ui.AccountLink;
|
||||
import com.google.gerrit.client.ui.AddMemberBox;
|
||||
import com.google.gerrit.client.ui.ReviewerSuggestOracle;
|
||||
import com.google.gerrit.common.data.ApprovalDetail;
|
||||
import com.google.gerrit.common.data.ApprovalType;
|
||||
import com.google.gerrit.common.data.ApprovalTypes;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.common.data.SubmitRecord;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
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. */
|
||||
public class ApprovalTable extends Composite {
|
||||
static short parseLabelValue(String value) {
|
||||
if (value.charAt(0) == ' ' || value.charAt(0) == '+') {
|
||||
value = value.substring(1);
|
||||
}
|
||||
return Short.parseShort(value);
|
||||
}
|
||||
|
||||
private final ApprovalTypes types;
|
||||
private final LabelTypes types;
|
||||
private final Grid table;
|
||||
private final Widget missing;
|
||||
private final Panel addReviewer;
|
||||
@@ -80,7 +73,7 @@ public class ApprovalTable extends Composite {
|
||||
|
||||
public ApprovalTable() {
|
||||
rows = new HashMap<Integer, Integer>();
|
||||
types = Gerrit.getConfig().getApprovalTypes();
|
||||
types = Gerrit.getConfig().getLabelTypes();
|
||||
table = new Grid(1, 3);
|
||||
table.addStyleName(Gerrit.RESOURCES.css().infoTable());
|
||||
|
||||
@@ -371,8 +364,7 @@ public class ApprovalTable extends Composite {
|
||||
table.setWidget(row, col, new Image(Gerrit.RESOURCES.greenCheck()));
|
||||
|
||||
} else {
|
||||
// TODO: support arbitrary labels.
|
||||
ApprovalType legacyType = types.byLabel(labelName);
|
||||
LabelType legacyType = types.byLabel(labelName);
|
||||
if (legacyType == null) {
|
||||
table.clearCell(row, col);
|
||||
col++;
|
||||
|
@@ -31,7 +31,7 @@ import com.google.gerrit.common.data.AccountInfo;
|
||||
import com.google.gerrit.common.data.AccountInfoCache;
|
||||
import com.google.gerrit.common.data.ApprovalSummary;
|
||||
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.LabelValue;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
@@ -68,7 +68,7 @@ public class ChangeTable extends NavigationTable<ChangeInfo> {
|
||||
|
||||
private final List<Section> sections;
|
||||
private AccountInfoCache accountCache = AccountInfoCache.empty();
|
||||
private final List<ApprovalType> approvalTypes;
|
||||
private final List<LabelType> labelTypes;
|
||||
private final int columns;
|
||||
|
||||
public ChangeTable() {
|
||||
@@ -77,9 +77,9 @@ public class ChangeTable extends NavigationTable<ChangeInfo> {
|
||||
|
||||
public ChangeTable(boolean showApprovals) {
|
||||
super(Util.C.changeItemHelp());
|
||||
approvalTypes = Gerrit.getConfig().getApprovalTypes().getApprovalTypes();
|
||||
labelTypes = Gerrit.getConfig().getLabelTypes().getLabelTypes();
|
||||
if (showApprovals) {
|
||||
columns = BASE_COLUMNS + approvalTypes.size();
|
||||
columns = BASE_COLUMNS + labelTypes.size();
|
||||
} else {
|
||||
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_LAST_UPDATE, Util.C.changeTableColumnLastUpdate());
|
||||
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();
|
||||
if (text == null) {
|
||||
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());
|
||||
|
||||
fmt.removeStyleName(row, col, Gerrit.RESOURCES.css().negscore());
|
||||
|
@@ -14,8 +14,6 @@
|
||||
|
||||
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.changes.ChangeInfo.ApprovalInfo;
|
||||
import com.google.gerrit.client.changes.ChangeInfo.LabelInfo;
|
||||
@@ -466,7 +464,11 @@ public class PublishCommentScreen extends AccountScreen implements
|
||||
}
|
||||
|
||||
short parseValue() {
|
||||
return parseLabelValue(value);
|
||||
String value = this.value;
|
||||
if (value.startsWith(" ") || value.startsWith("+")) {
|
||||
value = value.substring(1);
|
||||
}
|
||||
return Short.parseShort(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
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.GitwebConfig;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
@@ -52,7 +52,7 @@ class GerritConfigProvider implements Provider<GerritConfig> {
|
||||
private final GitWebConfig gitWebConfig;
|
||||
private final AllProjectsName wildProject;
|
||||
private final SshInfo sshInfo;
|
||||
private final ApprovalTypes approvalTypes;
|
||||
private final LabelTypes labelTypes;
|
||||
|
||||
private EmailSender emailSender;
|
||||
private final ContactStore contactStore;
|
||||
@@ -62,7 +62,7 @@ class GerritConfigProvider implements Provider<GerritConfig> {
|
||||
@Inject
|
||||
GerritConfigProvider(final Realm r, @GerritServerConfig final Config gsc,
|
||||
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 @AnonymousCowardName String acn) {
|
||||
realm = r;
|
||||
@@ -72,7 +72,7 @@ class GerritConfigProvider implements Provider<GerritConfig> {
|
||||
gitWebConfig = gwc;
|
||||
sshInfo = si;
|
||||
wildProject = wp;
|
||||
approvalTypes = at;
|
||||
labelTypes = at;
|
||||
contactStore = cs;
|
||||
servletContext = sc;
|
||||
anonymousCowardName = acn;
|
||||
@@ -123,7 +123,7 @@ class GerritConfigProvider implements Provider<GerritConfig> {
|
||||
config.setDownloadCommands(downloadConfig.getDownloadCommands());
|
||||
config.setAuthType(authConfig.getAuthType());
|
||||
config.setWildProject(wildProject);
|
||||
config.setApprovalTypes(approvalTypes);
|
||||
config.setLabelTypes(labelTypes);
|
||||
config.setDocumentationAvailable(servletContext
|
||||
.getResource("/Documentation/index.html") != null);
|
||||
config.setTestChangeMerge(cfg.getBoolean("changeMerge",
|
||||
|
@@ -14,8 +14,8 @@
|
||||
|
||||
package com.google.gerrit.httpd.rpc.changedetail;
|
||||
|
||||
import com.google.gerrit.common.data.ApprovalType;
|
||||
import com.google.gerrit.common.data.ApprovalTypes;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.common.data.PatchSetPublishDetail;
|
||||
import com.google.gerrit.common.data.PermissionRange;
|
||||
import com.google.gerrit.common.data.SubmitRecord;
|
||||
@@ -47,7 +47,7 @@ final class PatchSetPublishDetailFactory extends Handler<PatchSetPublishDetail>
|
||||
private final PatchSetInfoFactory infoFactory;
|
||||
private final ReviewDb db;
|
||||
private final ChangeControl.Factory changeControlFactory;
|
||||
private final ApprovalTypes approvalTypes;
|
||||
private final LabelTypes labelTypes;
|
||||
private final AccountInfoCacheFactory aic;
|
||||
private final IdentifiedUser user;
|
||||
|
||||
@@ -62,12 +62,12 @@ final class PatchSetPublishDetailFactory extends Handler<PatchSetPublishDetail>
|
||||
final ReviewDb db,
|
||||
final AccountInfoCacheFactory.Factory accountInfoCacheFactory,
|
||||
final ChangeControl.Factory changeControlFactory,
|
||||
final ApprovalTypes approvalTypes,
|
||||
final LabelTypes labelTypes,
|
||||
final IdentifiedUser user, @Assisted final PatchSet.Id patchSetId) {
|
||||
this.infoFactory = infoFactory;
|
||||
this.db = db;
|
||||
this.changeControlFactory = changeControlFactory;
|
||||
this.approvalTypes = approvalTypes;
|
||||
this.labelTypes = labelTypes;
|
||||
this.aic = accountInfoCacheFactory.create();
|
||||
this.user = user;
|
||||
|
||||
@@ -124,8 +124,8 @@ final class PatchSetPublishDetailFactory extends Handler<PatchSetPublishDetail>
|
||||
boolean canMakeOk = false;
|
||||
PermissionRange range = rangeByName.get(lbl.label);
|
||||
if (range != null) {
|
||||
ApprovalType at = approvalTypes.byLabel(lbl.label);
|
||||
if (at == null || at.getMax().getValue() == range.getMax()) {
|
||||
LabelType lt = labelTypes.byLabel(lbl.label);
|
||||
if (lt == null || lt.getMax().getValue() == range.getMax()) {
|
||||
canMakeOk = true;
|
||||
}
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@ package com.google.gerrit.httpd.rpc.patch;
|
||||
|
||||
import com.google.gerrit.common.data.ApprovalSummary;
|
||||
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.PatchDetailService;
|
||||
import com.google.gerrit.common.data.PatchScript;
|
||||
@@ -56,7 +56,7 @@ import java.util.Set;
|
||||
|
||||
class PatchDetailServiceImpl extends BaseServiceImplementation implements
|
||||
PatchDetailService {
|
||||
private final ApprovalTypes approvalTypes;
|
||||
private final LabelTypes labelTypes;
|
||||
|
||||
private final AccountInfoCacheFactory.Factory accountInfoCacheFactory;
|
||||
private final ChangeControl.Factory changeControlFactory;
|
||||
@@ -69,7 +69,7 @@ class PatchDetailServiceImpl extends BaseServiceImplementation implements
|
||||
@Inject
|
||||
PatchDetailServiceImpl(final Provider<ReviewDb> schema,
|
||||
final Provider<CurrentUser> currentUser,
|
||||
final ApprovalTypes approvalTypes,
|
||||
final LabelTypes labelTypes,
|
||||
final AccountInfoCacheFactory.Factory accountInfoCacheFactory,
|
||||
final ChangeControl.Factory changeControlFactory,
|
||||
final DeleteDraftPatchSet.Factory deleteDraftPatchSetFactory,
|
||||
@@ -78,7 +78,7 @@ class PatchDetailServiceImpl extends BaseServiceImplementation implements
|
||||
final SaveDraft.Factory saveDraftFactory,
|
||||
final ChangeDetailFactory.Factory changeDetailFactory) {
|
||||
super(schema, currentUser);
|
||||
this.approvalTypes = approvalTypes;
|
||||
this.labelTypes = labelTypes;
|
||||
|
||||
this.accountInfoCacheFactory = accountInfoCacheFactory;
|
||||
this.changeControlFactory = changeControlFactory;
|
||||
@@ -189,7 +189,7 @@ class PatchDetailServiceImpl extends BaseServiceImplementation implements
|
||||
continue;
|
||||
}
|
||||
if (change.getStatus().isOpen()) {
|
||||
fs.normalize(approvalTypes.byId(category.get()), ca);
|
||||
fs.normalize(labelTypes.byId(category.get()), ca);
|
||||
}
|
||||
if (ca.getValue() == 0) {
|
||||
continue;
|
||||
@@ -235,7 +235,7 @@ class PatchDetailServiceImpl extends BaseServiceImplementation implements
|
||||
continue;
|
||||
}
|
||||
if (change.getStatus().isOpen()) {
|
||||
fs.normalize(approvalTypes.byId(category.get()), ca);
|
||||
fs.normalize(labelTypes.byId(category.get()), ca);
|
||||
}
|
||||
if (ca.getValue() == 0) {
|
||||
continue;
|
||||
|
@@ -14,8 +14,8 @@
|
||||
|
||||
package com.google.gerrit.common;
|
||||
|
||||
import com.google.gerrit.common.data.ApprovalType;
|
||||
import com.google.gerrit.common.data.ApprovalTypes;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.common.data.ContributorAgreement;
|
||||
import com.google.gerrit.extensions.events.LifecycleListener;
|
||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||
@@ -206,7 +206,7 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
||||
|
||||
private final AccountCache accountCache;
|
||||
|
||||
private final ApprovalTypes approvalTypes;
|
||||
private final LabelTypes labelTypes;
|
||||
|
||||
private final EventFactory eventFactory;
|
||||
|
||||
@@ -233,7 +233,7 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
||||
final @GerritServerConfig Config config,
|
||||
final @AnonymousCowardName String anonymousCowardName,
|
||||
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 DynamicSet<ChangeListener> unrestrictedListeners) {
|
||||
this.anonymousCowardName = anonymousCowardName;
|
||||
@@ -241,7 +241,7 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
||||
this.hookQueue = queue.createQueue(1, "hook");
|
||||
this.projectCache = projectCache;
|
||||
this.accountCache = accountCache;
|
||||
this.approvalTypes = approvalTypes;
|
||||
this.labelTypes = labelTypes;
|
||||
this.eventFactory = eventFactory;
|
||||
this.sitePaths = sitePath;
|
||||
this.unrestrictedListeners = unrestrictedListeners;
|
||||
@@ -616,9 +616,9 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
||||
Entry<ApprovalCategory.Id, ApprovalCategoryValue.Id> approval) {
|
||||
ApprovalAttribute a = new ApprovalAttribute();
|
||||
a.type = approval.getKey().get();
|
||||
ApprovalType at = approvalTypes.byId(approval.getKey().get());
|
||||
if (at != null) {
|
||||
a.description = at.getName();
|
||||
LabelType lt = labelTypes.byId(approval.getKey().get());
|
||||
if (lt != null) {
|
||||
a.description = lt.getName();
|
||||
}
|
||||
a.value = Short.toString(approval.getValue().get());
|
||||
return a;
|
||||
|
@@ -17,8 +17,8 @@ package com.google.gerrit.server;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gerrit.common.data.ApprovalType;
|
||||
import com.google.gerrit.common.data.ApprovalTypes;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.Account.Id;
|
||||
import com.google.gerrit.reviewdb.client.ApprovalCategory;
|
||||
@@ -46,12 +46,12 @@ import java.util.Set;
|
||||
*/
|
||||
public class ApprovalsUtil {
|
||||
private final ReviewDb db;
|
||||
private final ApprovalTypes approvalTypes;
|
||||
private final LabelTypes labelTypes;
|
||||
|
||||
@Inject
|
||||
public ApprovalsUtil(ReviewDb db, ApprovalTypes approvalTypes) {
|
||||
public ApprovalsUtil(ReviewDb db, LabelTypes labelTypes) {
|
||||
this.db = db;
|
||||
this.approvalTypes = approvalTypes;
|
||||
this.labelTypes = labelTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,7 +91,7 @@ public class ApprovalsUtil {
|
||||
for (PatchSetApproval a : patchSetApprovals) {
|
||||
// ApprovalCategory.SUBMIT is still in db but not relevant in git-store
|
||||
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) &&
|
||||
type.isCopyMinScore() &&
|
||||
type.isMaxNegative(a)) {
|
||||
@@ -106,7 +106,7 @@ public class ApprovalsUtil {
|
||||
public void addReviewers(ReviewDb db, Change change, PatchSet ps,
|
||||
PatchSetInfo info, Set<Id> wantReviewers,
|
||||
Set<Account.Id> existingReviewers) throws OrmException {
|
||||
List<ApprovalType> allTypes = approvalTypes.getApprovalTypes();
|
||||
List<LabelType> allTypes = labelTypes.getLabelTypes();
|
||||
if (allTypes.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
@@ -35,8 +35,8 @@ import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gerrit.common.changes.ListChangesOption;
|
||||
import com.google.gerrit.common.data.ApprovalType;
|
||||
import com.google.gerrit.common.data.ApprovalTypes;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.common.data.LabelValue;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.common.data.PermissionRange;
|
||||
@@ -114,7 +114,7 @@ public class ChangeJson {
|
||||
}
|
||||
|
||||
private final Provider<ReviewDb> db;
|
||||
private final ApprovalTypes approvalTypes;
|
||||
private final LabelTypes labelTypes;
|
||||
private final FunctionState.Factory functionState;
|
||||
private final CurrentUser user;
|
||||
private final AnonymousUser anonymous;
|
||||
@@ -134,7 +134,7 @@ public class ChangeJson {
|
||||
@Inject
|
||||
ChangeJson(
|
||||
Provider<ReviewDb> db,
|
||||
ApprovalTypes at,
|
||||
LabelTypes at,
|
||||
FunctionState.Factory fs,
|
||||
CurrentUser u,
|
||||
AnonymousUser au,
|
||||
@@ -146,7 +146,7 @@ public class ChangeJson {
|
||||
@CanonicalWebUrl Provider<String> curl,
|
||||
Urls urls) {
|
||||
this.db = db;
|
||||
this.approvalTypes = at;
|
||||
this.labelTypes = at;
|
||||
this.functionState = fs;
|
||||
this.user = u;
|
||||
this.anonymous = au;
|
||||
@@ -338,7 +338,7 @@ public class ChangeJson {
|
||||
setAllApprovals(cd, labels);
|
||||
}
|
||||
for (Map.Entry<String, LabelInfo> e : labels.entrySet()) {
|
||||
ApprovalType type = approvalTypes.byLabel(e.getKey());
|
||||
LabelType type = labelTypes.byLabel(e.getKey());
|
||||
if (type == null) {
|
||||
continue; // TODO: Support arbitrary labels.
|
||||
}
|
||||
@@ -356,7 +356,7 @@ public class ChangeJson {
|
||||
throws OrmException {
|
||||
// Don't use Maps.newTreeMap(Comparator) due to OpenJDK bug 100167.
|
||||
Map<String, LabelInfo> labels =
|
||||
new TreeMap<String, LabelInfo>(LabelOrdering.create(approvalTypes));
|
||||
new TreeMap<String, LabelInfo>(LabelOrdering.create(labelTypes));
|
||||
for (SubmitRecord rec : submitRecords(cd)) {
|
||||
if (rec.labels == null) {
|
||||
continue;
|
||||
@@ -387,7 +387,7 @@ public class ChangeJson {
|
||||
return labels;
|
||||
}
|
||||
|
||||
private void setRecommendedAndDisliked(ChangeData cd, ApprovalType type,
|
||||
private void setRecommendedAndDisliked(ChangeData cd, LabelType type,
|
||||
LabelInfo label) throws OrmException {
|
||||
if (label.approved != null || label.rejected != null) {
|
||||
return;
|
||||
@@ -428,25 +428,25 @@ public class ChangeJson {
|
||||
Collection<PatchSetApproval> approvals = cd.currentApprovals(db);
|
||||
FunctionState fs =
|
||||
functionState.create(ctl, cd.change(db).currentPatchSetId(), approvals);
|
||||
for (ApprovalType at : approvalTypes.getApprovalTypes()) {
|
||||
CategoryFunction.forType(at).run(at, fs);
|
||||
for (LabelType lt : labelTypes.getLabelTypes()) {
|
||||
CategoryFunction.forType(lt).run(lt, fs);
|
||||
}
|
||||
|
||||
Multimap<Account.Id, String> existing =
|
||||
HashMultimap.create(approvals.size(), labels.size());
|
||||
for (PatchSetApproval psa : approvals) {
|
||||
ApprovalType at = approvalTypes.byId(psa.getCategoryId().get());
|
||||
if (at == null) {
|
||||
LabelType lt = labelTypes.byId(psa.getCategoryId().get());
|
||||
if (lt == null) {
|
||||
continue;
|
||||
}
|
||||
LabelInfo p = labels.get(at.getName());
|
||||
LabelInfo p = labels.get(lt.getName());
|
||||
if (p == null) {
|
||||
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()));
|
||||
}
|
||||
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
|
||||
@@ -475,9 +475,9 @@ public class ChangeJson {
|
||||
//
|
||||
// Don't use Maps.newTreeMap(Comparator) due to OpenJDK bug 100167.
|
||||
Map<String, LabelInfo> labels =
|
||||
new TreeMap<String, LabelInfo>(LabelOrdering.create(approvalTypes));
|
||||
new TreeMap<String, LabelInfo>(LabelOrdering.create(labelTypes));
|
||||
for (PatchSetApproval psa : cd.currentApprovals(db)) {
|
||||
ApprovalType type = approvalTypes.byId(psa.getCategoryId().get());
|
||||
LabelType type = labelTypes.byId(psa.getCategoryId().get());
|
||||
if (type == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -537,7 +537,7 @@ public class ChangeJson {
|
||||
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();
|
||||
for (LabelValue v : type.getValues()) {
|
||||
label.values.put(v.formatValue(), v.getText());
|
||||
@@ -556,7 +556,7 @@ public class ChangeJson {
|
||||
continue;
|
||||
}
|
||||
for (SubmitRecord.Label r : rec.labels) {
|
||||
ApprovalType type = approvalTypes.byLabel(r.label);
|
||||
LabelType type = labelTypes.byLabel(r.label);
|
||||
if (type == null) {
|
||||
continue; // TODO: Support arbitrary labels.
|
||||
}
|
||||
|
@@ -16,17 +16,17 @@ package com.google.gerrit.server.change;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Ordering;
|
||||
import com.google.gerrit.common.data.ApprovalType;
|
||||
import com.google.gerrit.common.data.ApprovalTypes;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
|
||||
class LabelOrdering {
|
||||
public static Ordering<String> create(final ApprovalTypes approvalTypes) {
|
||||
public static Ordering<String> create(final LabelTypes labelTypes) {
|
||||
return Ordering.natural().nullsLast().onResultOf(
|
||||
new Function<String, Short>() {
|
||||
@Override
|
||||
public Short apply(String n) {
|
||||
ApprovalType at = approvalTypes.byLabel(n);
|
||||
return at != null ? at.getPosition() : null;
|
||||
LabelType lt = labelTypes.byLabel(n);
|
||||
return lt != null ? lt.getPosition() : null;
|
||||
}
|
||||
}).compound(Ordering.natural());
|
||||
}
|
||||
|
@@ -19,8 +19,8 @@ import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gerrit.common.ChangeHooks;
|
||||
import com.google.gerrit.common.data.ApprovalType;
|
||||
import com.google.gerrit.common.data.ApprovalTypes;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.common.data.PermissionRange;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
@@ -102,7 +102,7 @@ public class PostReview implements RestModifyView<RevisionResource, Input> {
|
||||
}
|
||||
|
||||
private final ReviewDb db;
|
||||
private final ApprovalTypes approvalTypes;
|
||||
private final LabelTypes labelTypes;
|
||||
private final EmailReviewComments.Factory email;
|
||||
@Deprecated private final ChangeHooks hooks;
|
||||
|
||||
@@ -116,11 +116,11 @@ public class PostReview implements RestModifyView<RevisionResource, Input> {
|
||||
|
||||
@Inject
|
||||
PostReview(ReviewDb db,
|
||||
ApprovalTypes approvalTypes,
|
||||
LabelTypes labelTypes,
|
||||
EmailReviewComments.Factory email,
|
||||
ChangeHooks hooks) {
|
||||
this.db = db;
|
||||
this.approvalTypes = approvalTypes;
|
||||
this.labelTypes = labelTypes;
|
||||
this.email = email;
|
||||
this.hooks = hooks;
|
||||
}
|
||||
@@ -180,8 +180,8 @@ public class PostReview implements RestModifyView<RevisionResource, Input> {
|
||||
Map.Entry<String, Short> ent = itr.next();
|
||||
|
||||
// TODO Support more generic label assignments.
|
||||
ApprovalType at = approvalTypes.byLabel(ent.getKey());
|
||||
if (at == null) {
|
||||
LabelType lt = labelTypes.byLabel(ent.getKey());
|
||||
if (lt == null) {
|
||||
if (strict) {
|
||||
throw new BadRequestException(String.format(
|
||||
"label \"%s\" is not a configured ApprovalCategory",
|
||||
@@ -198,7 +198,7 @@ public class PostReview implements RestModifyView<RevisionResource, Input> {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (at.getValue(ent.getValue()) == null) {
|
||||
if (lt.getValue(ent.getValue()) == null) {
|
||||
if (strict) {
|
||||
throw new BadRequestException(String.format(
|
||||
"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));
|
||||
if (range == null || !range.contains(ent.getValue())) {
|
||||
if (strict) {
|
||||
@@ -345,8 +345,8 @@ public class PostReview implements RestModifyView<RevisionResource, Input> {
|
||||
|
||||
for (Map.Entry<String, Short> ent : labels.entrySet()) {
|
||||
// TODO Support arbitrary label names.
|
||||
ApprovalType at = approvalTypes.byLabel(ent.getKey());
|
||||
String name = at.getName();
|
||||
LabelType lt = labelTypes.byLabel(ent.getKey());
|
||||
String name = lt.getName();
|
||||
if (change.getStatus().isClosed()) {
|
||||
// TODO Allow updating some labels even when closed.
|
||||
continue;
|
||||
@@ -368,23 +368,23 @@ public class PostReview implements RestModifyView<RevisionResource, Input> {
|
||||
upd.add(c);
|
||||
labelDelta.add(format(name, c.getValue()));
|
||||
categories.put(
|
||||
at.getApprovalCategoryId(),
|
||||
at.getApprovalCategoryValueId(c.getValue()));
|
||||
lt.getApprovalCategoryId(),
|
||||
lt.getApprovalCategoryValueId(c.getValue()));
|
||||
} else if (c != null && c.getValue() == ent.getValue()) {
|
||||
current.put(name, c);
|
||||
} else if (c == null) {
|
||||
c = new PatchSetApproval(new PatchSetApproval.Key(
|
||||
rsrc.getPatchSet().getId(),
|
||||
rsrc.getAccountId(),
|
||||
at.getApprovalCategoryId()),
|
||||
lt.getApprovalCategoryId()),
|
||||
ent.getValue());
|
||||
c.setGranted(timestamp);
|
||||
c.cache(change);
|
||||
ins.add(c);
|
||||
labelDelta.add(format(name, c.getValue()));
|
||||
categories.put(
|
||||
at.getApprovalCategoryId(),
|
||||
at.getApprovalCategoryValueId(c.getValue()));
|
||||
lt.getApprovalCategoryId(),
|
||||
lt.getApprovalCategoryValueId(c.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,11 +402,11 @@ public class PostReview implements RestModifyView<RevisionResource, Input> {
|
||||
// TODO Find another way to link reviewers to changes.
|
||||
if (del.isEmpty()) {
|
||||
// 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(
|
||||
rsrc.getPatchSet().getId(),
|
||||
rsrc.getAccountId(),
|
||||
approvalTypes.getApprovalTypes().get(0).getApprovalCategoryId()),
|
||||
labelTypes.getLabelTypes().get(0).getApprovalCategoryId()),
|
||||
(short) 0);
|
||||
c.setGranted(timestamp);
|
||||
c.cache(change);
|
||||
@@ -433,9 +433,9 @@ public class PostReview implements RestModifyView<RevisionResource, Input> {
|
||||
continue;
|
||||
}
|
||||
|
||||
ApprovalType at = approvalTypes.byId(a.getCategoryId().get());
|
||||
if (at != null) {
|
||||
current.put(at.getName(), a);
|
||||
LabelType lt = labelTypes.byId(a.getCategoryId().get());
|
||||
if (lt != null) {
|
||||
current.put(lt.getName(), a);
|
||||
} else {
|
||||
del.add(a);
|
||||
}
|
||||
|
@@ -21,9 +21,9 @@ import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
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.GroupDescriptions;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.common.errors.EmailException;
|
||||
import com.google.gerrit.common.errors.NoSuchGroupException;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
@@ -98,7 +98,7 @@ public class PostReviewers implements RestModifyView<ChangeResource, Input> {
|
||||
Provider<ReviewDb> db,
|
||||
IdentifiedUser currentUser,
|
||||
IdentifiedUser.GenericFactory identifiedUserFactory,
|
||||
ApprovalTypes approvalTypes,
|
||||
LabelTypes labelTypes,
|
||||
@GerritServerConfig Config cfg,
|
||||
ChangeHooks hooks,
|
||||
AccountCache accountCache,
|
||||
@@ -117,7 +117,7 @@ public class PostReviewers implements RestModifyView<ChangeResource, Input> {
|
||||
this.accountCache = accountCache;
|
||||
this.json = json;
|
||||
|
||||
this.addReviewerCategoryId = Iterables.getLast(approvalTypes.getApprovalTypes())
|
||||
this.addReviewerCategoryId = Iterables.getLast(labelTypes.getLabelTypes())
|
||||
.getApprovalCategoryId();
|
||||
}
|
||||
|
||||
|
@@ -18,8 +18,8 @@ import static com.google.gerrit.common.data.LabelValue.formatValue;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gerrit.common.data.ApprovalType;
|
||||
import com.google.gerrit.common.data.ApprovalTypes;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.common.data.PermissionRange;
|
||||
import com.google.gerrit.common.data.SubmitRecord;
|
||||
@@ -42,17 +42,17 @@ import java.util.TreeMap;
|
||||
|
||||
public class ReviewerJson {
|
||||
private final Provider<ReviewDb> db;
|
||||
private final ApprovalTypes approvalTypes;
|
||||
private final LabelTypes labelTypes;
|
||||
private final FunctionState.Factory functionState;
|
||||
private final AccountInfo.Loader.Factory accountLoaderFactory;
|
||||
|
||||
@Inject
|
||||
ReviewerJson(Provider<ReviewDb> db,
|
||||
ApprovalTypes approvalTypes,
|
||||
LabelTypes labelTypes,
|
||||
FunctionState.Factory functionState,
|
||||
AccountInfo.Loader.Factory accountLoaderFactory) {
|
||||
this.db = db;
|
||||
this.approvalTypes = approvalTypes;
|
||||
this.labelTypes = labelTypes;
|
||||
this.functionState = functionState;
|
||||
this.accountLoaderFactory = accountLoaderFactory;
|
||||
}
|
||||
@@ -84,18 +84,18 @@ public class ReviewerJson {
|
||||
}
|
||||
|
||||
FunctionState fs = functionState.create(ctl, psId, approvals);
|
||||
for (ApprovalType at : approvalTypes.getApprovalTypes()) {
|
||||
for (LabelType at : labelTypes.getLabelTypes()) {
|
||||
CategoryFunction.forType(at).run(at, fs);
|
||||
}
|
||||
|
||||
// Don't use Maps.newTreeMap(Comparator) due to OpenJDK bug 100167.
|
||||
out.approvals = new TreeMap<String,String>(LabelOrdering.create(
|
||||
approvalTypes));
|
||||
labelTypes));
|
||||
for (PatchSetApproval ca : approvals) {
|
||||
for (PermissionRange pr : ctl.getLabelRanges()) {
|
||||
if (!pr.isEmpty()) {
|
||||
// TODO: Support arbitrary labels.
|
||||
ApprovalType at = approvalTypes.byId(ca.getCategoryId().get());
|
||||
LabelType at = labelTypes.byId(ca.getCategoryId().get());
|
||||
if (at != null) {
|
||||
out.approvals.put(at.getName(), formatValue(ca.getValue())); }
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ import static com.google.inject.Scopes.SINGLETON;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.gerrit.audit.AuditModule;
|
||||
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.NewProjectCreatedListener;
|
||||
import com.google.gerrit.extensions.registration.DynamicItem;
|
||||
@@ -140,7 +140,7 @@ public class GerritGlobalModule extends FactoryModule {
|
||||
break;
|
||||
}
|
||||
|
||||
bind(ApprovalTypes.class).toProvider(ApprovalTypesProvider.class).in(
|
||||
bind(LabelTypes.class).toProvider(LabelTypesProvider.class).in(
|
||||
SINGLETON);
|
||||
bind(EmailExpander.class).toProvider(EmailExpanderProvider.class).in(
|
||||
SINGLETON);
|
||||
|
@@ -14,8 +14,8 @@
|
||||
|
||||
package com.google.gerrit.server.config;
|
||||
|
||||
import com.google.gerrit.common.data.ApprovalType;
|
||||
import com.google.gerrit.common.data.ApprovalTypes;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.reviewdb.client.ApprovalCategory;
|
||||
import com.google.gerrit.reviewdb.client.ApprovalCategoryValue;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
@@ -29,17 +29,17 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ApprovalTypesProvider implements Provider<ApprovalTypes> {
|
||||
public class LabelTypesProvider implements Provider<LabelTypes> {
|
||||
private final SchemaFactory<ReviewDb> schema;
|
||||
|
||||
@Inject
|
||||
ApprovalTypesProvider(final SchemaFactory<ReviewDb> sf) {
|
||||
LabelTypesProvider(final SchemaFactory<ReviewDb> sf) {
|
||||
schema = sf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApprovalTypes get() {
|
||||
List<ApprovalType> types = new ArrayList<ApprovalType>(2);
|
||||
public LabelTypes get() {
|
||||
List<LabelType> types = new ArrayList<LabelType>(2);
|
||||
|
||||
try {
|
||||
final ReviewDb db = schema.open();
|
||||
@@ -47,7 +47,7 @@ public class ApprovalTypesProvider implements Provider<ApprovalTypes> {
|
||||
for (final ApprovalCategory c : db.approvalCategories().all()) {
|
||||
final List<ApprovalCategoryValue> values =
|
||||
db.approvalCategoryValues().byCategory(c.getId()).toList();
|
||||
types.add(ApprovalType.fromApprovalCategory(c, values));
|
||||
types.add(LabelType.fromApprovalCategory(c, values));
|
||||
}
|
||||
} finally {
|
||||
db.close();
|
||||
@@ -56,6 +56,6 @@ public class ApprovalTypesProvider implements Provider<ApprovalTypes> {
|
||||
throw new ProvisionException("Cannot query approval categories", e);
|
||||
}
|
||||
|
||||
return new ApprovalTypes(Collections.unmodifiableList(types));
|
||||
return new LabelTypes(Collections.unmodifiableList(types));
|
||||
}
|
||||
}
|
@@ -14,8 +14,8 @@
|
||||
|
||||
package com.google.gerrit.server.events;
|
||||
|
||||
import com.google.gerrit.common.data.ApprovalType;
|
||||
import com.google.gerrit.common.data.ApprovalTypes;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.common.data.SubmitRecord;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.Branch;
|
||||
@@ -62,7 +62,7 @@ public class EventFactory {
|
||||
private static final Logger log = LoggerFactory.getLogger(EventFactory.class);
|
||||
private final AccountCache accountCache;
|
||||
private final Provider<String> urlProvider;
|
||||
private final ApprovalTypes approvalTypes;
|
||||
private final LabelTypes labelTypes;
|
||||
private final PatchListCache patchListCache;
|
||||
private final SchemaFactory<ReviewDb> schema;
|
||||
private final PatchSetInfoFactory psInfoFactory;
|
||||
@@ -71,13 +71,13 @@ public class EventFactory {
|
||||
@Inject
|
||||
EventFactory(AccountCache accountCache,
|
||||
@CanonicalWebUrl @Nullable Provider<String> urlProvider,
|
||||
ApprovalTypes approvalTypes,
|
||||
LabelTypes labelTypes,
|
||||
final PatchSetInfoFactory psif,
|
||||
PatchListCache patchListCache, SchemaFactory<ReviewDb> schema,
|
||||
@GerritPersonIdent PersonIdent myIdent) {
|
||||
this.accountCache = accountCache;
|
||||
this.urlProvider = urlProvider;
|
||||
this.approvalTypes = approvalTypes;
|
||||
this.labelTypes = labelTypes;
|
||||
this.patchListCache = patchListCache;
|
||||
this.schema = schema;
|
||||
this.psInfoFactory = psif;
|
||||
@@ -460,9 +460,9 @@ public class EventFactory {
|
||||
a.by = asAccountAttribute(approval.getAccountId());
|
||||
a.grantedOn = approval.getGranted().getTime() / 1000L;
|
||||
|
||||
ApprovalType at = approvalTypes.byId(approval.getCategoryId().get());
|
||||
if (at != null) {
|
||||
a.description = at.getName();
|
||||
LabelType lt = labelTypes.byId(approval.getCategoryId().get());
|
||||
if (lt != null) {
|
||||
a.description = lt.getName();
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ import static com.google.gerrit.server.git.MergeUtil.mergeOneCommit;
|
||||
import static com.google.gerrit.server.git.MergeUtil.getApprovalsForCommit;
|
||||
|
||||
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.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.PatchSetAncestor;
|
||||
@@ -53,19 +53,19 @@ import java.util.Map;
|
||||
public class CherryPick extends SubmitStrategy {
|
||||
private final PatchSetInfoFactory patchSetInfoFactory;
|
||||
private final Provider<String> urlProvider;
|
||||
private final ApprovalTypes approvalTypes;
|
||||
private final LabelTypes labelTypes;
|
||||
private final GitReferenceUpdated gitRefUpdated;
|
||||
private final Map<Change.Id, CodeReviewCommit> newCommits;
|
||||
|
||||
CherryPick(final SubmitStrategy.Arguments args,
|
||||
final PatchSetInfoFactory patchSetInfoFactory,
|
||||
final Provider<String> urlProvider, final ApprovalTypes approvalTypes,
|
||||
final Provider<String> urlProvider, final LabelTypes labelTypes,
|
||||
final GitReferenceUpdated gitRefUpdated) {
|
||||
super(args);
|
||||
|
||||
this.patchSetInfoFactory = patchSetInfoFactory;
|
||||
this.urlProvider = urlProvider;
|
||||
this.approvalTypes = approvalTypes;
|
||||
this.labelTypes = labelTypes;
|
||||
this.gitRefUpdated = gitRefUpdated;
|
||||
this.newCommits = new HashMap<Change.Id, CodeReviewCommit>();
|
||||
}
|
||||
@@ -163,7 +163,7 @@ public class CherryPick extends SubmitStrategy {
|
||||
}
|
||||
|
||||
final String cherryPickCmtMsg =
|
||||
createCherryPickCommitMessage(n, approvalTypes, urlProvider, args.db,
|
||||
createCherryPickCommitMessage(n, labelTypes, urlProvider, args.db,
|
||||
args.identifiedUserFactory);
|
||||
|
||||
final CodeReviewCommit newCommit =
|
||||
|
@@ -26,8 +26,8 @@ import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.gerrit.common.ChangeHooks;
|
||||
import com.google.gerrit.common.data.ApprovalType;
|
||||
import com.google.gerrit.common.data.ApprovalTypes;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.common.data.Capable;
|
||||
import com.google.gerrit.common.data.SubmitTypeRecord;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
@@ -130,7 +130,7 @@ public class MergeOp {
|
||||
private final GitReferenceUpdated gitRefUpdated;
|
||||
private final MergedSender.Factory mergedSenderFactory;
|
||||
private final MergeFailSender.Factory mergeFailSenderFactory;
|
||||
private final ApprovalTypes approvalTypes;
|
||||
private final LabelTypes labelTypes;
|
||||
private final PatchSetInfoFactory patchSetInfoFactory;
|
||||
private final IdentifiedUser.GenericFactory identifiedUserFactory;
|
||||
private final ChangeControl.GenericFactory changeControlFactory;
|
||||
@@ -164,7 +164,7 @@ public class MergeOp {
|
||||
final ProjectCache pc, final FunctionState.Factory fs,
|
||||
final GitReferenceUpdated gru, final MergedSender.Factory msf,
|
||||
final MergeFailSender.Factory mfsf,
|
||||
final ApprovalTypes approvalTypes, final PatchSetInfoFactory psif,
|
||||
final LabelTypes labelTypes, final PatchSetInfoFactory psif,
|
||||
final IdentifiedUser.GenericFactory iuf,
|
||||
final ChangeControl.GenericFactory changeControlFactory,
|
||||
final MergeQueue mergeQueue, @Assisted final Branch.NameKey branch,
|
||||
@@ -182,7 +182,7 @@ public class MergeOp {
|
||||
gitRefUpdated = gru;
|
||||
mergedSenderFactory = msf;
|
||||
mergeFailSenderFactory = mfsf;
|
||||
this.approvalTypes = approvalTypes;
|
||||
this.labelTypes = labelTypes;
|
||||
patchSetInfoFactory = psif;
|
||||
identifiedUserFactory = iuf;
|
||||
this.changeControlFactory = changeControlFactory;
|
||||
@@ -936,8 +936,8 @@ public class MergeOp {
|
||||
c,
|
||||
identifiedUserFactory.create(c.getOwner())),
|
||||
merged, approvals);
|
||||
for (ApprovalType at : approvalTypes.getApprovalTypes()) {
|
||||
CategoryFunction.forType(at).run(at, fs);
|
||||
for (LabelType lt : labelTypes.getLabelTypes()) {
|
||||
CategoryFunction.forType(lt).run(lt, fs);
|
||||
}
|
||||
for (PatchSetApproval a : approvals) {
|
||||
if (a.getValue() > 0
|
||||
|
@@ -14,8 +14,8 @@
|
||||
|
||||
package com.google.gerrit.server.git;
|
||||
|
||||
import com.google.gerrit.common.data.ApprovalType;
|
||||
import com.google.gerrit.common.data.ApprovalTypes;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.ApprovalCategory;
|
||||
import com.google.gerrit.reviewdb.client.Branch;
|
||||
@@ -165,7 +165,7 @@ public class MergeUtil {
|
||||
}
|
||||
|
||||
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 List<FooterLine> footers = n.getFooterLines();
|
||||
final StringBuilder msgbuf = new StringBuilder();
|
||||
@@ -254,12 +254,12 @@ public class MergeUtil {
|
||||
} else if (VRIF.equals(a.getCategoryId())) {
|
||||
tag = "Tested-by";
|
||||
} else {
|
||||
final ApprovalType at = approvalTypes.byId(a.getCategoryId().get());
|
||||
if (at == null) {
|
||||
final LabelType lt = labelTypes.byId(a.getCategoryId().get());
|
||||
if (lt == null) {
|
||||
// TODO: Support arbitrary labels.
|
||||
continue;
|
||||
}
|
||||
tag = at.getName();
|
||||
tag = lt.getName();
|
||||
}
|
||||
|
||||
if (!contains(footers, new FooterKey(tag), identbuf.toString())) {
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
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.Branch;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
@@ -51,7 +51,7 @@ class ReviewNoteHeaderFormatter {
|
||||
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(value < 0 ? "-" : "+").append(Math.abs(value)).append(": ");
|
||||
appendUserData(user);
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
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.Project.SubmitType;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
@@ -49,7 +49,7 @@ public class SubmitStrategyFactory {
|
||||
private final PersonIdent myIdent;
|
||||
private final PatchSetInfoFactory patchSetInfoFactory;
|
||||
private final Provider<String> urlProvider;
|
||||
private final ApprovalTypes approvalTypes;
|
||||
private final LabelTypes labelTypes;
|
||||
private final GitReferenceUpdated gitRefUpdated;
|
||||
private final RebaseChange rebaseChange;
|
||||
|
||||
@@ -59,13 +59,13 @@ public class SubmitStrategyFactory {
|
||||
@GerritPersonIdent final PersonIdent myIdent,
|
||||
final PatchSetInfoFactory patchSetInfoFactory,
|
||||
@CanonicalWebUrl @Nullable final Provider<String> urlProvider,
|
||||
final ApprovalTypes approvalTypes, final GitReferenceUpdated gitRefUpdated,
|
||||
final LabelTypes labelTypes, final GitReferenceUpdated gitRefUpdated,
|
||||
final RebaseChange rebaseChange) {
|
||||
this.identifiedUserFactory = identifiedUserFactory;
|
||||
this.myIdent = myIdent;
|
||||
this.patchSetInfoFactory = patchSetInfoFactory;
|
||||
this.urlProvider = urlProvider;
|
||||
this.approvalTypes = approvalTypes;
|
||||
this.labelTypes = labelTypes;
|
||||
this.gitRefUpdated = gitRefUpdated;
|
||||
this.rebaseChange = rebaseChange;
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public class SubmitStrategyFactory {
|
||||
switch (submitType) {
|
||||
case CHERRY_PICK:
|
||||
return new CherryPick(args, patchSetInfoFactory, urlProvider,
|
||||
approvalTypes, gitRefUpdated);
|
||||
labelTypes, gitRefUpdated);
|
||||
case FAST_FORWARD_ONLY:
|
||||
return new FastForwardOnly(args);
|
||||
case MERGE_ALWAYS:
|
||||
|
@@ -16,8 +16,8 @@ package com.google.gerrit.server.mail;
|
||||
|
||||
import com.google.common.collect.HashBasedTable;
|
||||
import com.google.common.collect.Table;
|
||||
import com.google.gerrit.common.data.ApprovalType;
|
||||
import com.google.gerrit.common.data.ApprovalTypes;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.common.data.LabelValue;
|
||||
import com.google.gerrit.common.errors.EmailException;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
@@ -34,12 +34,12 @@ public class MergedSender extends ReplyToChangeSender {
|
||||
public MergedSender create(Change change);
|
||||
}
|
||||
|
||||
private final ApprovalTypes approvalTypes;
|
||||
private final LabelTypes labelTypes;
|
||||
|
||||
@Inject
|
||||
public MergedSender(EmailArguments ea, ApprovalTypes at, @Assisted Change c) {
|
||||
public MergedSender(EmailArguments ea, LabelTypes lt, @Assisted Change c) {
|
||||
super(ea, c, "merged");
|
||||
approvalTypes = at;
|
||||
labelTypes = lt;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,7 +63,7 @@ public class MergedSender extends ReplyToChangeSender {
|
||||
Table<Account.Id, String, PatchSetApproval> neg = HashBasedTable.create();
|
||||
for (PatchSetApproval ca : args.db.get().patchSetApprovals()
|
||||
.byPatchSet(patchSet.getId())) {
|
||||
ApprovalType lt = approvalTypes.byId(ca.getCategoryId().get());
|
||||
LabelType lt = labelTypes.byId(ca.getCategoryId().get());
|
||||
if (lt == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -93,7 +93,7 @@ public class MergedSender extends ReplyToChangeSender {
|
||||
txt.append(getNameFor(id));
|
||||
txt.append(": ");
|
||||
boolean first = true;
|
||||
for (ApprovalType lt : approvalTypes.getApprovalTypes()) {
|
||||
for (LabelType lt : labelTypes.getLabelTypes()) {
|
||||
PatchSetApproval ca = approvals.get(id, lt.getName());
|
||||
if (ca == null) {
|
||||
continue;
|
||||
|
@@ -15,7 +15,7 @@
|
||||
package com.google.gerrit.server.query.change;
|
||||
|
||||
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.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
@@ -110,7 +110,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
||||
final ChangeControl.GenericFactory changeControlGenericFactory;
|
||||
final AccountResolver accountResolver;
|
||||
final GroupBackend groupBackend;
|
||||
final ApprovalTypes approvalTypes;
|
||||
final LabelTypes labelTypes;
|
||||
final AllProjectsName allProjectsName;
|
||||
final PatchListCache patchListCache;
|
||||
final GitRepositoryManager repoManager;
|
||||
@@ -124,7 +124,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
||||
ChangeControl.GenericFactory changeControlGenericFactory,
|
||||
AccountResolver accountResolver,
|
||||
GroupBackend groupBackend,
|
||||
ApprovalTypes approvalTypes,
|
||||
LabelTypes labelTypes,
|
||||
AllProjectsName allProjectsName,
|
||||
PatchListCache patchListCache,
|
||||
GitRepositoryManager repoManager,
|
||||
@@ -136,7 +136,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
||||
this.changeControlGenericFactory = changeControlGenericFactory;
|
||||
this.accountResolver = accountResolver;
|
||||
this.groupBackend = groupBackend;
|
||||
this.approvalTypes = approvalTypes;
|
||||
this.labelTypes = labelTypes;
|
||||
this.allProjectsName = allProjectsName;
|
||||
this.patchListCache = patchListCache;
|
||||
this.repoManager = repoManager;
|
||||
@@ -302,7 +302,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
||||
@Operator
|
||||
public Predicate<ChangeData> label(String name) {
|
||||
return new LabelPredicate(args.changeControlGenericFactory,
|
||||
args.userFactory, args.dbProvider, args.approvalTypes, name);
|
||||
args.userFactory, args.dbProvider, args.labelTypes, name);
|
||||
}
|
||||
|
||||
@Operator
|
||||
|
@@ -14,8 +14,8 @@
|
||||
|
||||
package com.google.gerrit.server.query.change;
|
||||
|
||||
import com.google.gerrit.common.data.ApprovalType;
|
||||
import com.google.gerrit.common.data.ApprovalTypes;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
@@ -57,7 +57,7 @@ class LabelPredicate extends OperatorPredicate<ChangeData> {
|
||||
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) {
|
||||
return types.byLabel(toFind);
|
||||
}
|
||||
@@ -66,19 +66,19 @@ class LabelPredicate extends OperatorPredicate<ChangeData> {
|
||||
return types.byId(toFind);
|
||||
}
|
||||
|
||||
for (ApprovalType at : types.getApprovalTypes()) {
|
||||
if (toFind.equalsIgnoreCase(at.getName())) {
|
||||
return at;
|
||||
for (LabelType lt : types.getLabelTypes()) {
|
||||
if (toFind.equalsIgnoreCase(lt.getName())) {
|
||||
return lt;
|
||||
}
|
||||
}
|
||||
|
||||
for (ApprovalType at : types.getApprovalTypes()) {
|
||||
if (toFind.equalsIgnoreCase(at.getAbbreviatedName())) {
|
||||
return at;
|
||||
for (LabelType lt : types.getLabelTypes()) {
|
||||
if (toFind.equalsIgnoreCase(lt.getAbbreviatedName())) {
|
||||
return lt;
|
||||
}
|
||||
}
|
||||
|
||||
return ApprovalType.withDefaultValues(toFind.substring(0, 4), toFind);
|
||||
return LabelType.withDefaultValues(toFind.substring(0, 4), toFind);
|
||||
}
|
||||
|
||||
private static Test op(String op) {
|
||||
@@ -107,13 +107,13 @@ class LabelPredicate extends OperatorPredicate<ChangeData> {
|
||||
private final IdentifiedUser.GenericFactory userFactory;
|
||||
private final Provider<ReviewDb> dbProvider;
|
||||
private final Test test;
|
||||
private final ApprovalType type;
|
||||
private final LabelType type;
|
||||
private final String permissionName;
|
||||
private final int expVal;
|
||||
|
||||
LabelPredicate(ChangeControl.GenericFactory ccFactory,
|
||||
IdentifiedUser.GenericFactory userFactory, Provider<ReviewDb> dbProvider,
|
||||
ApprovalTypes types, String value) {
|
||||
LabelTypes types, String value) {
|
||||
super(ChangeQueryBuilder.FIELD_LABEL, value);
|
||||
this.ccFactory = ccFactory;
|
||||
this.userFactory = userFactory;
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
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.PatchSetApproval;
|
||||
|
||||
@@ -43,7 +43,7 @@ public abstract class CategoryFunction {
|
||||
* @return the function implementation; {@link NoOpFunction} if the function
|
||||
* 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());
|
||||
return r != null ? r : new NoOpFunction();
|
||||
}
|
||||
@@ -85,9 +85,9 @@ public abstract class CategoryFunction {
|
||||
* state.valid(at, !neg && pos);
|
||||
* </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
|
||||
* the valid status into.
|
||||
*/
|
||||
public abstract void run(ApprovalType at, FunctionState state);
|
||||
public abstract void run(LabelType lt, FunctionState state);
|
||||
}
|
||||
|
@@ -14,8 +14,8 @@
|
||||
|
||||
package com.google.gerrit.server.workflow;
|
||||
|
||||
import com.google.gerrit.common.data.ApprovalType;
|
||||
import com.google.gerrit.common.data.ApprovalTypes;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.common.data.LabelValue;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.common.data.PermissionRange;
|
||||
@@ -42,7 +42,7 @@ public class FunctionState {
|
||||
Collection<PatchSetApproval> all);
|
||||
}
|
||||
|
||||
private final ApprovalTypes approvalTypes;
|
||||
private final LabelTypes labelTypes;
|
||||
private final IdentifiedUser.GenericFactory userFactory;
|
||||
|
||||
private final Map<String, Collection<PatchSetApproval>> approvals =
|
||||
@@ -52,11 +52,11 @@ public class FunctionState {
|
||||
private final Change change;
|
||||
|
||||
@Inject
|
||||
FunctionState(final ApprovalTypes approvalTypes,
|
||||
FunctionState(final LabelTypes labelTypes,
|
||||
final IdentifiedUser.GenericFactory userFactory,
|
||||
@Assisted final ChangeControl c, @Assisted final PatchSet.Id psId,
|
||||
@Assisted final Collection<PatchSetApproval> all) {
|
||||
this.approvalTypes = approvalTypes;
|
||||
this.labelTypes = labelTypes;
|
||||
this.userFactory = userFactory;
|
||||
|
||||
callerChangeControl = c;
|
||||
@@ -68,10 +68,10 @@ public class FunctionState {
|
||||
approvals.get(ca.getCategoryId().get());
|
||||
if (l == null) {
|
||||
l = new ArrayList<PatchSetApproval>();
|
||||
ApprovalType at = approvalTypes.byId(ca.getCategoryId().get());
|
||||
if (at != null) {
|
||||
LabelType lt = labelTypes.byId(ca.getCategoryId().get());
|
||||
if (lt != null) {
|
||||
// TODO: Support arbitrary labels
|
||||
approvals.put(at.getName(), l);
|
||||
approvals.put(lt.getName(), l);
|
||||
}
|
||||
}
|
||||
l.add(ca);
|
||||
@@ -79,20 +79,20 @@ public class FunctionState {
|
||||
}
|
||||
}
|
||||
|
||||
List<ApprovalType> getApprovalTypes() {
|
||||
return approvalTypes.getApprovalTypes();
|
||||
List<LabelType> getLabelTypes() {
|
||||
return labelTypes.getLabelTypes();
|
||||
}
|
||||
|
||||
Change getChange() {
|
||||
return change;
|
||||
}
|
||||
|
||||
public void valid(final ApprovalType at, final boolean v) {
|
||||
valid.put(id(at), v);
|
||||
public void valid(final LabelType lt, final boolean v) {
|
||||
valid.put(id(lt), v);
|
||||
}
|
||||
|
||||
public boolean isValid(final ApprovalType at) {
|
||||
return isValid(at.getName());
|
||||
public boolean isValid(final LabelType lt) {
|
||||
return isValid(lt.getName());
|
||||
}
|
||||
|
||||
public boolean isValid(final String labelName) {
|
||||
@@ -100,8 +100,8 @@ public class FunctionState {
|
||||
return b != null && b;
|
||||
}
|
||||
|
||||
public Collection<PatchSetApproval> getApprovals(final ApprovalType at) {
|
||||
return getApprovals(at.getName());
|
||||
public Collection<PatchSetApproval> getApprovals(final LabelType lt) {
|
||||
return getApprovals(lt.getName());
|
||||
}
|
||||
|
||||
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.
|
||||
* <p>
|
||||
*/
|
||||
private void applyTypeFloor(final ApprovalType at, final PatchSetApproval a) {
|
||||
final LabelValue atMin = at.getMin();
|
||||
private void applyTypeFloor(final LabelType lt, final PatchSetApproval a) {
|
||||
final LabelValue atMin = lt.getMin();
|
||||
|
||||
if (atMin != null && a.getValue() < atMin.getValue()) {
|
||||
a.setValue(atMin.getValue());
|
||||
}
|
||||
|
||||
final LabelValue atMax = at.getMax();
|
||||
final LabelValue atMax = lt.getMax();
|
||||
if (atMax != null && a.getValue() > atMax.getValue()) {
|
||||
a.setValue(atMax.getValue());
|
||||
}
|
||||
@@ -136,8 +136,8 @@ public class FunctionState {
|
||||
* of them is used.
|
||||
* <p>
|
||||
*/
|
||||
private void applyRightFloor(final ApprovalType at, final PatchSetApproval a) {
|
||||
final String permission = Permission.forLabel(at.getName());
|
||||
private void applyRightFloor(final LabelType lt, final PatchSetApproval a) {
|
||||
final String permission = Permission.forLabel(lt.getName());
|
||||
final IdentifiedUser user = userFactory.create(a.getAccountId());
|
||||
final PermissionRange range = controlFor(user).getRange(permission);
|
||||
a.setValue((short) range.squash(a.getValue()));
|
||||
@@ -148,12 +148,12 @@ public class FunctionState {
|
||||
}
|
||||
|
||||
/** Run <code>applyTypeFloor</code>, <code>applyRightFloor</code>. */
|
||||
public void normalize(final ApprovalType at, final PatchSetApproval ca) {
|
||||
applyTypeFloor(at, ca);
|
||||
applyRightFloor(at, ca);
|
||||
public void normalize(final LabelType lt, final PatchSetApproval ca) {
|
||||
applyTypeFloor(lt, ca);
|
||||
applyRightFloor(lt, ca);
|
||||
}
|
||||
|
||||
private static String id(final ApprovalType at) {
|
||||
return at.getId();
|
||||
private static String id(final LabelType lt) {
|
||||
return lt.getId();
|
||||
}
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
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.PatchSetApproval;
|
||||
|
||||
@@ -33,16 +33,16 @@ public class MaxNoBlock extends CategoryFunction {
|
||||
public static String NAME = "MaxNoBlock";
|
||||
|
||||
@Override
|
||||
public void run(final ApprovalType at, final FunctionState state) {
|
||||
public void run(final LabelType lt, final FunctionState state) {
|
||||
boolean passed = false;
|
||||
for (final PatchSetApproval a : state.getApprovals(at)) {
|
||||
state.normalize(at, a);
|
||||
for (final PatchSetApproval a : state.getApprovals(lt)) {
|
||||
state.normalize(lt, a);
|
||||
|
||||
passed |= at.isMaxPositive(a);
|
||||
passed |= lt.isMaxPositive(a);
|
||||
}
|
||||
|
||||
// The type must have at least one max positive (a full accept).
|
||||
//
|
||||
state.valid(at, passed);
|
||||
state.valid(lt, passed);
|
||||
}
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
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.PatchSetApproval;
|
||||
|
||||
@@ -45,19 +45,19 @@ public class MaxWithBlock extends CategoryFunction {
|
||||
public static String NAME = "MaxWithBlock";
|
||||
|
||||
@Override
|
||||
public void run(final ApprovalType at, final FunctionState state) {
|
||||
public void run(final LabelType lt, final FunctionState state) {
|
||||
boolean rejected = false;
|
||||
boolean passed = false;
|
||||
for (final PatchSetApproval a : state.getApprovals(at)) {
|
||||
state.normalize(at, a);
|
||||
for (final PatchSetApproval a : state.getApprovals(lt)) {
|
||||
state.normalize(lt, a);
|
||||
|
||||
rejected |= at.isMaxNegative(a);
|
||||
passed |= at.isMaxPositive(a);
|
||||
rejected |= lt.isMaxNegative(a);
|
||||
passed |= lt.isMaxPositive(a);
|
||||
}
|
||||
|
||||
// The type must not have had its max negative (a forceful reject)
|
||||
// and must have at least one max positive (a full accept).
|
||||
//
|
||||
state.valid(at, !rejected && passed);
|
||||
state.valid(lt, !rejected && passed);
|
||||
}
|
||||
}
|
||||
|
@@ -14,14 +14,14 @@
|
||||
|
||||
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. */
|
||||
public class NoBlock extends CategoryFunction {
|
||||
public static String NAME = "NoBlock";
|
||||
|
||||
@Override
|
||||
public void run(final ApprovalType at, final FunctionState state) {
|
||||
state.valid(at, true);
|
||||
public void run(final LabelType lt, final FunctionState state) {
|
||||
state.valid(lt, true);
|
||||
}
|
||||
}
|
||||
|
@@ -14,13 +14,13 @@
|
||||
|
||||
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. */
|
||||
public class NoOpFunction extends CategoryFunction {
|
||||
public static String NAME = "NoOp";
|
||||
|
||||
@Override
|
||||
public void run(final ApprovalType at, final FunctionState state) {
|
||||
public void run(final LabelType lt, final FunctionState state) {
|
||||
}
|
||||
}
|
||||
|
@@ -2,8 +2,8 @@
|
||||
|
||||
package gerrit;
|
||||
|
||||
import com.google.gerrit.common.data.ApprovalType;
|
||||
import com.google.gerrit.common.data.ApprovalTypes;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||
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);
|
||||
PatchSet patchSet = StoredValues.PATCH_SET.get(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;
|
||||
if (cd != null) {
|
||||
@@ -60,7 +60,7 @@ class PRED__load_commit_labels_1 extends Predicate.P1 {
|
||||
continue;
|
||||
}
|
||||
|
||||
ApprovalType t = types.byId(a.getCategoryId().get());
|
||||
LabelType t = types.byId(a.getCategoryId().get());
|
||||
if (t == null) {
|
||||
continue;
|
||||
}
|
||||
|
@@ -14,8 +14,8 @@
|
||||
|
||||
package gerrit;
|
||||
|
||||
import com.google.gerrit.common.data.ApprovalType;
|
||||
import com.google.gerrit.common.data.ApprovalTypes;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.rules.PrologEnvironment;
|
||||
|
||||
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();
|
||||
|
||||
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;
|
||||
for (int idx = list.size() - 1; 0 <= idx; idx--) {
|
||||
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(
|
||||
"approval_type", 5);
|
||||
|
||||
static Term export(ApprovalType type) {
|
||||
static Term export(LabelType type) {
|
||||
return new StructureTerm(symApprovalType,
|
||||
SymbolTerm.intern(type.getName()),
|
||||
SymbolTerm.intern(type.getId()),
|
||||
|
@@ -14,8 +14,8 @@
|
||||
|
||||
package com.google.gerrit.rules;
|
||||
|
||||
import com.google.gerrit.common.data.ApprovalType;
|
||||
import com.google.gerrit.common.data.ApprovalTypes;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.common.data.LabelValue;
|
||||
import com.google.inject.AbstractModule;
|
||||
|
||||
@@ -26,7 +26,7 @@ public class GerritCommonTest extends PrologTestCase {
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
final ApprovalTypes types = new ApprovalTypes(Arrays.asList(
|
||||
final LabelTypes types = new LabelTypes(Arrays.asList(
|
||||
category(0, "CRVW", "Code-Review",
|
||||
value(2, "Looks good to me, approved"),
|
||||
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() {
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
private static ApprovalType category(int pos, String id, String name,
|
||||
private static LabelType category(int pos, String id, String name,
|
||||
LabelValue... values) {
|
||||
ApprovalType type = new ApprovalType(id, name, Arrays.asList(values));
|
||||
LabelType type = new LabelType(id, name, Arrays.asList(values));
|
||||
type.setPosition((short) pos);
|
||||
return type;
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
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 org.kohsuke.args4j.CmdLineException;
|
||||
@@ -30,11 +30,11 @@ import java.lang.annotation.Annotation;
|
||||
final class ApproveOption implements Option, Setter<Short> {
|
||||
private final String name;
|
||||
private final String usage;
|
||||
private final ApprovalType type;
|
||||
private final LabelType type;
|
||||
|
||||
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.usage = usage;
|
||||
this.type = type;
|
||||
|
@@ -16,8 +16,8 @@ package com.google.gerrit.sshd.commands;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gerrit.common.data.ApprovalType;
|
||||
import com.google.gerrit.common.data.ApprovalTypes;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.common.data.LabelValue;
|
||||
import com.google.gerrit.common.data.ReviewResult;
|
||||
import com.google.gerrit.common.data.ReviewResult.Error.Type;
|
||||
@@ -116,7 +116,7 @@ public class ReviewCommand extends SshCommand {
|
||||
private ReviewDb db;
|
||||
|
||||
@Inject
|
||||
private ApprovalTypes approvalTypes;
|
||||
private LabelTypes labelTypes;
|
||||
|
||||
@Inject
|
||||
private DeleteDraftPatchSet.Factory deleteDraftPatchSetFactory;
|
||||
@@ -400,7 +400,7 @@ public class ReviewCommand extends SshCommand {
|
||||
protected void parseCommandLine() throws UnloggedFailure {
|
||||
optionList = new ArrayList<ApproveOption>();
|
||||
|
||||
for (ApprovalType type : approvalTypes.getApprovalTypes()) {
|
||||
for (LabelType type : labelTypes.getLabelTypes()) {
|
||||
String usage = "";
|
||||
usage = "score for " + type.getName() + "\n";
|
||||
|
||||
|
Reference in New Issue
Block a user