Migrate ApprovalTypes away from ApprovalCategory(Value)
Many callers of ApprovalTypes depend directly on ApprovalCategory and ApprovalCategoryValue, which are the types stored in the database. We want to move away from storing approval categories in the database in favor of arbitrary labels that can be defined on a per-project level, including implicitly in submit rules. Leaking the database types around the code makes this harder. Replace ApprovalCategoryValue everywhere except the database code with a similar and more concise LabelValue type. Use Strings instead of the database Id types when referring to labels in general. In the short term this may create some confusion in the code (alleviated, hopefully, by documentation and variable names), since some places use legacy category IDs as unique keys and others use new style label names as unique keys. In the long term we will stop using category IDs except to map them to unique label names. Unlike ApprovalCategory, the new and improved ApprovalType does not distinguish between the label name and the human-readable name. Generally these do not vary significantly other than the label name having dashes instead of spaces, which is minor enough in the UI. The other affected functionality here is searching by label; since label names can no longer contain spaces "label:CodeReview" no longer works, only "label:Code-Review". Change-Id: I6854259d60af88b6d9df8d7553120a9af64c74ad
This commit is contained in:
@@ -60,14 +60,14 @@ class PRED__load_commit_labels_1 extends Predicate.P1 {
|
||||
continue;
|
||||
}
|
||||
|
||||
ApprovalType t = types.byId(a.getCategoryId());
|
||||
ApprovalType t = types.byId(a.getCategoryId().get());
|
||||
if (t == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
StructureTerm labelTerm = new StructureTerm(
|
||||
sym_label,
|
||||
SymbolTerm.intern(t.getCategory().getLabelName()),
|
||||
SymbolTerm.intern(t.getName()),
|
||||
new IntegerTerm(a.getValue()));
|
||||
|
||||
StructureTerm userTerm = new StructureTerm(
|
||||
|
@@ -73,9 +73,9 @@ class PRED_get_legacy_approval_types_1 extends Predicate.P1 {
|
||||
|
||||
static Term export(ApprovalType type) {
|
||||
return new StructureTerm(symApprovalType,
|
||||
SymbolTerm.intern(type.getCategory().getLabelName()),
|
||||
SymbolTerm.intern(type.getCategory().getId().get()),
|
||||
SymbolTerm.intern(type.getCategory().getFunctionName()),
|
||||
SymbolTerm.intern(type.getName()),
|
||||
SymbolTerm.intern(type.getId()),
|
||||
SymbolTerm.intern(type.getFunctionName()),
|
||||
new IntegerTerm(type.getMin().getValue()),
|
||||
new IntegerTerm(type.getMax().getValue()));
|
||||
}
|
||||
|
Reference in New Issue
Block a user