Search in sources :

Example 1 with RobotCommentNotes

use of com.google.gerrit.server.notedb.RobotCommentNotes in project gerrit by GerritCodeReview.

the class ChangeData method getRefStates.

public SetMultimap<NameKey, RefState> getRefStates() {
    if (refStates == null) {
        if (!lazyload()) {
            return ImmutableSetMultimap.of();
        }
        ImmutableSetMultimap.Builder<NameKey, RefState> result = ImmutableSetMultimap.builder();
        for (Table.Cell<Account.Id, PatchSet.Id, ObjectId> edit : editRefs().cellSet()) {
            result.put(project, RefState.create(RefNames.refsEdit(edit.getRowKey(), edit.getColumnKey().changeId(), edit.getColumnKey()), edit.getValue()));
        }
        starRefs().values().forEach(r -> result.put(allUsersName, RefState.of(r.ref())));
        // TODO: instantiating the notes is too much. We don't want to parse NoteDb, we just want the
        // refs.
        result.put(project, RefState.create(notes().getRefName(), notes().getMetaId()));
        // Force loading robot comments.
        notes().getRobotComments();
        RobotCommentNotes robotNotes = notes().getRobotCommentNotes();
        result.put(project, RefState.create(robotNotes.getRefName(), robotNotes.getMetaId()));
        draftRefs().entrySet().forEach(r -> result.put(allUsersName, RefState.create(RefNames.refsDraftComments(getId(), r.getKey()), r.getValue())));
        refStates = result.build();
    }
    return refStates;
}
Also used : HashBasedTable(com.google.common.collect.HashBasedTable) Table(com.google.common.collect.Table) ImmutableSetMultimap(com.google.common.collect.ImmutableSetMultimap) RefState(com.google.gerrit.index.RefState) ObjectId(org.eclipse.jgit.lib.ObjectId) RobotCommentNotes(com.google.gerrit.server.notedb.RobotCommentNotes) ObjectId(org.eclipse.jgit.lib.ObjectId) NameKey(com.google.gerrit.entities.Project.NameKey)

Aggregations

HashBasedTable (com.google.common.collect.HashBasedTable)1 ImmutableSetMultimap (com.google.common.collect.ImmutableSetMultimap)1 Table (com.google.common.collect.Table)1 NameKey (com.google.gerrit.entities.Project.NameKey)1 RefState (com.google.gerrit.index.RefState)1 RobotCommentNotes (com.google.gerrit.server.notedb.RobotCommentNotes)1 ObjectId (org.eclipse.jgit.lib.ObjectId)1