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(NotesMigration migration,
IdentifiedUser.GenericFactory userFactory,
ChangeControl.GenericFactory changeControlFactory,
ApprovalCopier copier) |
@Inject public ApprovalsUtil(NotesMigration migration, IdentifiedUser.GenericFactory userFactory, ChangeControl.GenericFactory changeControlFactory, ApprovalCopier copier)
public static List<PatchSetApproval> sortApprovals(Iterable<PatchSetApproval> approvals)
public static PatchSetApproval newApproval(PatchSet.Id psId, CurrentUser user, LabelId labelId, int value, Date when)
public ReviewerSet getReviewers(ReviewDb db, ChangeNotes notes) throws com.google.gwtorm.server.OrmException
db
- review database.notes
- change notes.com.google.gwtorm.server.OrmException
- if reviewers for the change could not be read.public ReviewerSet getReviewers(ChangeNotes notes, Iterable<PatchSetApproval> allApprovals) throws com.google.gwtorm.server.OrmException
allApprovals
- all approvals to consider; must all belong to the same change.com.google.gwtorm.server.OrmException
- if reviewers for the change could not be read.public List<ReviewerStatusUpdate> getReviewerUpdates(ChangeNotes notes) throws com.google.gwtorm.server.OrmException
notes
- change notes.com.google.gwtorm.server.OrmException
- if reviewer updates for the change could not be read.public List<PatchSetApproval> addReviewers(ReviewDb db, ChangeUpdate update, LabelTypes labelTypes, Change change, PatchSet ps, PatchSetInfo info, Iterable<Account.Id> wantReviewers, Collection<Account.Id> existingReviewers) throws com.google.gwtorm.server.OrmException
com.google.gwtorm.server.OrmException
public List<PatchSetApproval> addReviewers(ReviewDb db, ChangeNotes notes, ChangeUpdate update, LabelTypes labelTypes, Change change, Iterable<Account.Id> wantReviewers) throws com.google.gwtorm.server.OrmException
com.google.gwtorm.server.OrmException
public Collection<Account.Id> addCcs(ChangeNotes notes, ChangeUpdate update, Collection<Account.Id> wantCCs) throws com.google.gwtorm.server.OrmException
notes
- change notes.update
- change update.wantCCs
- accounts to CC.com.google.gwtorm.server.OrmException
public Iterable<PatchSetApproval> addApprovalsForNewPatchSet(ReviewDb db, ChangeUpdate update, LabelTypes labelTypes, PatchSet ps, ChangeControl changeCtl, Map<String,Short> approvals) throws RestApiException, com.google.gwtorm.server.OrmException
db
- review database.update
- change update.labelTypes
- label types for the containing project.ps
- patch set being approved.changeCtl
- change control for user adding approvals.approvals
- approvals to add.RestApiException
com.google.gwtorm.server.OrmException
public static void checkLabel(LabelTypes labelTypes, String name, Short value) throws BadRequestException
BadRequestException
public com.google.common.collect.ListMultimap<PatchSet.Id,PatchSetApproval> byChange(ReviewDb db, ChangeNotes notes) throws com.google.gwtorm.server.OrmException
com.google.gwtorm.server.OrmException
public Iterable<PatchSetApproval> byPatchSet(ReviewDb db, ChangeControl ctl, PatchSet.Id psId) throws com.google.gwtorm.server.OrmException
com.google.gwtorm.server.OrmException
public Iterable<PatchSetApproval> byPatchSetUser(ReviewDb db, ChangeControl ctl, PatchSet.Id psId, Account.Id accountId) throws com.google.gwtorm.server.OrmException
com.google.gwtorm.server.OrmException
public PatchSetApproval getSubmitter(ReviewDb db, ChangeNotes notes, PatchSet.Id c)
public static PatchSetApproval getSubmitter(PatchSet.Id c, Iterable<PatchSetApproval> approvals)