use of com.google.gerrit.server.update.BatchUpdateReviewDb in project gerrit by GerritCodeReview.
the class CommentsUtil method deleteCommentByRewritingHistory.
public void deleteCommentByRewritingHistory(ReviewDb db, ChangeUpdate update, Comment.Key commentKey, PatchSet.Id psId, String newMessage) throws OrmException {
if (PrimaryStorage.of(update.getChange()).equals(PrimaryStorage.REVIEW_DB)) {
PatchLineComment.Key key = new PatchLineComment.Key(new Patch.Key(psId, commentKey.filename), commentKey.uuid);
if (db instanceof BatchUpdateReviewDb) {
db = ((BatchUpdateReviewDb) db).unsafeGetDelegate();
}
db = ReviewDbUtil.unwrapDb(db);
PatchLineComment patchLineComment = db.patchComments().get(key);
if (!patchLineComment.getStatus().equals(PUBLISHED)) {
throw new OrmException(String.format("comment %s is not published", key));
}
patchLineComment.setMessage(newMessage);
db.patchComments().upsert(Collections.singleton(patchLineComment));
}
update.deleteCommentByRewritingHistory(commentKey.uuid, newMessage);
}
use of com.google.gerrit.server.update.BatchUpdateReviewDb in project gerrit by GerritCodeReview.
the class DeleteReviewerOp method approvals.
private Iterable<PatchSetApproval> approvals(ChangeContext ctx, Account.Id accountId) throws OrmException {
Change.Id changeId = ctx.getNotes().getChangeId();
Iterable<PatchSetApproval> approvals;
PrimaryStorage r = PrimaryStorage.of(ctx.getChange());
if (migration.readChanges() && r == PrimaryStorage.REVIEW_DB) {
// Because NoteDb and ReviewDb have different semantics for zero-value
// approvals, we must fall back to ReviewDb as the source of truth here.
ReviewDb db = ctx.getDb();
if (db instanceof BatchUpdateReviewDb) {
db = ((BatchUpdateReviewDb) db).unsafeGetDelegate();
}
db = ReviewDbUtil.unwrapDb(db);
approvals = db.patchSetApprovals().byChange(changeId);
} else {
approvals = approvalsUtil.byChange(ctx.getDb(), ctx.getNotes()).values();
}
return Iterables.filter(approvals, psa -> accountId.equals(psa.getAccountId()));
}
Aggregations