Import approval right entities from Gerrit 1 into ProjectRight

The ProjectRight entity binds a single group to an ApprovalCategory,
and denotes what range of values within the ApprovalCategory can be
used by the members of that group.

Since Gerrit 1 supported individual users to be added to projects in
the approver, verifier or submitter category we create fake groups for
these cases and toss the other users into those groups.

The submitter category uses a position of -1, indicating that it should
not appear in the review status table of a change, but it still is a
valid category within the system.  This hack is necesary to reuse the
same ProjectRight system to handle the submitter status.

Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2009-01-03 14:00:31 -08:00
parent 68eff50909
commit a26dc96cf8
7 changed files with 473 additions and 8 deletions

View File

@@ -216,6 +216,20 @@ public class GerritServer {
txn.commit();
}
private void initSubmitCategory(final ReviewDb c) throws OrmException {
final Transaction txn = c.beginTransaction();
final ApprovalCategory cat;
final ArrayList<ApprovalCategoryValue> vals;
cat = new ApprovalCategory(new ApprovalCategory.Id("SUBM"), "Submit");
cat.setPosition((short) -1);
vals = new ArrayList<ApprovalCategoryValue>();
vals.add(value(cat, 1, "Submit"));
c.approvalCategories().insert(Collections.singleton(cat), txn);
c.approvalCategoryValues().insert(vals);
txn.commit();
}
private static ApprovalCategoryValue value(final ApprovalCategory cat,
final int value, final String name) {
return new ApprovalCategoryValue(new ApprovalCategoryValue.Id(cat.getId(),
@@ -241,6 +255,7 @@ public class GerritServer {
initSystemConfig(c);
initVerifiedCategory(c);
initCodeReviewCategory(c);
initSubmitCategory(c);
sConfig = c.systemConfig().get(new SystemConfig.Key());
}