Search in sources :

Example 31 with ChangeMessageInfo

use of com.google.gerrit.extensions.common.ChangeMessageInfo in project gerrit by GerritCodeReview.

the class ChangeJson method messages.

private Collection<ChangeMessageInfo> messages(ChangeControl ctl, ChangeData cd, Map<PatchSet.Id, PatchSet> map) throws OrmException {
    List<ChangeMessage> messages = cmUtil.byChange(db.get(), cd.notes());
    if (messages.isEmpty()) {
        return Collections.emptyList();
    }
    List<ChangeMessageInfo> result = Lists.newArrayListWithCapacity(messages.size());
    for (ChangeMessage message : messages) {
        PatchSet.Id patchNum = message.getPatchSetId();
        PatchSet ps = patchNum != null ? map.get(patchNum) : null;
        if (patchNum == null || ctl.isPatchVisible(ps, db.get())) {
            ChangeMessageInfo cmi = new ChangeMessageInfo();
            cmi.id = message.getKey().get();
            cmi.author = accountLoader.get(message.getAuthor());
            cmi.date = message.getWrittenOn();
            cmi.message = message.getMessage();
            cmi.tag = message.getTag();
            cmi._revisionNumber = patchNum != null ? patchNum.get() : null;
            Account.Id realAuthor = message.getRealAuthor();
            if (realAuthor != null) {
                cmi.realAuthor = accountLoader.get(realAuthor);
            }
            result.add(cmi);
        }
    }
    return result;
}
Also used : Account(com.google.gerrit.reviewdb.client.Account) ChangeMessage(com.google.gerrit.reviewdb.client.ChangeMessage) ChangeMessageInfo(com.google.gerrit.extensions.common.ChangeMessageInfo) PatchSet(com.google.gerrit.reviewdb.client.PatchSet)

Aggregations

ChangeMessageInfo (com.google.gerrit.extensions.common.ChangeMessageInfo)31 Test (org.junit.Test)26 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)21 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)17 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)14 CherryPickInput (com.google.gerrit.extensions.api.changes.CherryPickInput)6 GerritConfig (com.google.gerrit.acceptance.GerritConfig)5 CommentInfo (com.google.gerrit.extensions.common.CommentInfo)5 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)4 BranchInput (com.google.gerrit.extensions.api.projects.BranchInput)4 ChangeApi (com.google.gerrit.extensions.api.changes.ChangeApi)3 RevisionInfo (com.google.gerrit.extensions.common.RevisionInfo)3 MailMessage (com.google.gerrit.server.mail.receive.MailMessage)3 ArrayList (java.util.ArrayList)3 RestResponse (com.google.gerrit.acceptance.RestResponse)2 FakeEmailSender (com.google.gerrit.testutil.FakeEmailSender)2 RevCommit (org.eclipse.jgit.revwalk.RevCommit)2 ImmutableList (com.google.common.collect.ImmutableList)1 DraftInput (com.google.gerrit.extensions.api.changes.DraftInput)1 RobotCommentInput (com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput)1