public class ApprovalsUtil extends Object
Approvals are overloaded, they represent both approvals and reviewers which should be CCed on a change. To ensure that reviewers are not lost there must always be an approval on each patchset for each reviewer, even if the reviewer hasn't actually given a score to the change. To mark the "no score" case, a dummy approval, which may live in any of the available categories, with a score of 0 is used.
The methods in this class only modify the gwtorm database.
Constructor and Description |
---|
ApprovalsUtil(ApprovalCopier copier,
PermissionBackend permissionBackend,
ProjectCache projectCache) |
@Inject public ApprovalsUtil(ApprovalCopier copier, PermissionBackend permissionBackend, ProjectCache projectCache)
public static PatchSetApproval newApproval(PatchSet.Id psId, CurrentUser user, LabelId labelId, int value, Date when)
public ReviewerSet getReviewers(ChangeNotes notes)
notes
- change notes.public ReviewerSet getReviewers(ChangeNotes notes, Iterable<PatchSetApproval> allApprovals)
allApprovals
- all approvals to consider; must all belong to the same change.public List<ReviewerStatusUpdate> getReviewerUpdates(ChangeNotes notes)
notes
- change notes.public List<PatchSetApproval> addReviewers(ChangeUpdate update, LabelTypes labelTypes, Change change, PatchSet ps, PatchSetInfo info, Iterable<Account.Id> wantReviewers, Collection<Account.Id> existingReviewers)
public List<PatchSetApproval> addReviewers(ChangeNotes notes, ChangeUpdate update, LabelTypes labelTypes, Change change, Iterable<Account.Id> wantReviewers)
public Collection<Account.Id> addCcs(ChangeNotes notes, ChangeUpdate update, Collection<Account.Id> wantCCs)
notes
- change notes.update
- change update.wantCCs
- accounts to CC.public Iterable<PatchSetApproval> addApprovalsForNewPatchSet(ChangeUpdate update, LabelTypes labelTypes, PatchSet ps, CurrentUser user, Map<String,Short> approvals) throws RestApiException, PermissionBackendException
update
- change update.labelTypes
- label types for the containing project.ps
- patch set being approved.user
- user adding approvals.approvals
- approvals to add.RestApiException
PermissionBackendException
public static void checkLabel(LabelTypes labelTypes, String name, Short value) throws BadRequestException
BadRequestException
public com.google.common.collect.ListMultimap<PatchSet.Id,PatchSetApproval> byChange(ChangeNotes notes)
public Iterable<PatchSetApproval> byPatchSet(ChangeNotes notes, PatchSet.Id psId, org.eclipse.jgit.revwalk.RevWalk rw, org.eclipse.jgit.lib.Config repoConfig)
public Iterable<PatchSetApproval> byPatchSetUser(ChangeNotes notes, PatchSet.Id psId, Account.Id accountId, org.eclipse.jgit.revwalk.RevWalk rw, org.eclipse.jgit.lib.Config repoConfig)
public PatchSetApproval getSubmitter(ChangeNotes notes, PatchSet.Id c)
public static PatchSetApproval getSubmitter(PatchSet.Id c, Iterable<PatchSetApproval> approvals)