Class ChangeData


  • public class ChangeData
    extends Object
    ChangeData provides lazily loaded interface to change metadata loaded from NoteDb. It can be constructed by loading from NoteDb, or calling setters. The latter happens when ChangeData is retrieved through the change index. This happens for Applications that are performance sensitive (eg. dashboard loads, git protocol negotiation) but can tolerate staleness. In that case, setting lazyLoad=false disables loading from NoteDb, so we don't accidentally enable a slow path.
    • Method Detail

      • ensureChangeLoaded

        public static void ensureChangeLoaded​(Iterable<ChangeData> changes)
      • ensureAllPatchSetsLoaded

        public static void ensureAllPatchSetsLoaded​(Iterable<ChangeData> changes)
      • ensureCurrentPatchSetLoaded

        public static void ensureCurrentPatchSetLoaded​(Iterable<ChangeData> changes)
      • ensureCurrentApprovalsLoaded

        public static void ensureCurrentApprovalsLoaded​(Iterable<ChangeData> changes)
      • ensureMessagesLoaded

        public static void ensureMessagesLoaded​(Iterable<ChangeData> changes)
      • ensureReviewedByLoadedForOpenChanges

        public static void ensureReviewedByLoadedForOpenChanges​(Iterable<ChangeData> changes)
      • createForTest

        public static ChangeData createForTest​(Project.NameKey project,
                                               Change.Id id,
                                               int currentPatchSetId,
                                               org.eclipse.jgit.lib.ObjectId commitId)
        Create an instance for testing only.

        Attempting to lazy load data will fail with NPEs. Callers may consider manually setting fields that can be set.

        Parameters:
        id - change ID
        Returns:
        instance for testing.
      • setStorageConstraint

        public ChangeData setStorageConstraint​(ChangeData.StorageConstraint storageConstraint)
        If false, omit fields that require database/repo IO.

        This is used to enforce that the dashboard is rendered from the index only. If lazyLoad is on, the ChangeData object will load from the database ("lazily") when a field accessor is called.

      • lazyload

        public boolean lazyload()
        Returns true if we allow reading data from NoteDb.
      • getAllUsersNameForIndexing

        public AllUsersName getAllUsersNameForIndexing()
      • setCurrentFilePaths

        public void setCurrentFilePaths​(List<String> filePaths)
      • currentFilePaths

        public List<String> currentFilePaths()
      • setChangedLines

        public void setChangedLines​(int insertions,
                                    int deletions)
      • setLinesInserted

        public void setLinesInserted​(int insertions)
      • setLinesDeleted

        public void setLinesDeleted​(int deletions)
      • setNoChangedLines

        public void setNoChangedLines()
      • change

        public Change change()
      • setChange

        public void setChange​(Change c)
      • reloadChange

        public Change reloadChange()
      • getLabelTypes

        public LabelTypes getLabelTypes()
      • currentPatchSet

        public PatchSet currentPatchSet()
      • commitMessage

        public String commitMessage()
      • commitFooters

        public List<org.eclipse.jgit.revwalk.FooterLine> commitFooters()
        Returns the list of commit footers (which may be empty).
      • trackingFooters

        public com.google.common.collect.ListMultimap<String,​String> trackingFooters()
      • getAuthor

        public org.eclipse.jgit.lib.PersonIdent getAuthor()
      • getCommitter

        public org.eclipse.jgit.lib.PersonIdent getCommitter()
      • attentionSet

        public com.google.common.collect.ImmutableSet<AttentionSetUpdate> attentionSet()
        Returns the most recent update (i.e. status) per user.
      • getMergedOn

        public Optional<Instant> getMergedOn()
                                      throws com.google.gerrit.exceptions.StorageException
        Returns the Optional value of time when the change was merged.

        The value can be set from index field, see setMergedOn(java.time.Instant) or loaded from the database (available in ChangeNotes)

        Returns:
        Optional value of time when the change was merged.
        Throws:
        com.google.gerrit.exceptions.StorageException - if lazyLoad is off, ChangeNotes can not be loaded because we do not expect to call the database.
      • setMergedOn

        public void setMergedOn​(Instant mergedOn)
        Sets the value e.g. when loading from index.
      • setAttentionSet

        public void setAttentionSet​(com.google.common.collect.ImmutableSet<AttentionSetUpdate> attentionSet)
        Sets the specified attention set. If two or more entries refer to the same user, throws an IllegalStateException.
      • patchSets

        public Collection<PatchSet> patchSets()
        Returns patches for the change, in patch set ID order.
      • patchSet

        public PatchSet patchSet​(PatchSet.Id psId)
        Returns patch with the given ID, or null if it does not exist.
      • approvals

        public com.google.common.collect.ListMultimap<PatchSet.Id,​PatchSetApproval> approvals()
        Returns all patch set approvals for the change, keyed by ID, ordered by timestamp within each patch set.
      • setReviewers

        public void setReviewers​(ReviewerSet reviewers)
      • setReviewersByEmail

        public void setReviewersByEmail​(ReviewerByEmailSet reviewersByEmail)
      • setPendingReviewers

        public void setPendingReviewers​(ReviewerSet pendingReviewers)
      • getPendingReviewers

        public ReviewerSet getPendingReviewers()
      • pendingReviewers

        public ReviewerSet pendingReviewers()
      • setPendingReviewersByEmail

        public void setPendingReviewersByEmail​(ReviewerByEmailSet pendingReviewersByEmail)
      • unresolvedCommentCount

        public Integer unresolvedCommentCount()
      • setUnresolvedCommentCount

        public void setUnresolvedCommentCount​(Integer count)
      • totalCommentCount

        public Integer totalCommentCount()
      • setTotalCommentCount

        public void setTotalCommentCount​(Integer count)
      • submitRequirements

        public Map<SubmitRequirement,​SubmitRequirementResult> submitRequirements()
        Get all evaluated submit requirements for this change, including those from parent projects. For closed changes, submit requirements are read from the change notes. For active changes, submit requirements are evaluated online.

        For changes loaded from the index, the value will be set from index field ChangeField.STORED_SUBMIT_REQUIREMENTS.

      • setMergeable

        public void setMergeable​(Boolean mergeable)
      • isMergeable

        public Boolean isMergeable()
      • isMerge

        public Boolean isMerge()
      • editRefs

        public com.google.common.collect.Table<Account.Id,​PatchSet.Id,​org.eclipse.jgit.lib.ObjectId> editRefs()
      • isReviewedBy

        public boolean isReviewedBy​(Account.Id accountId)
      • setReviewedBy

        public void setReviewedBy​(Set<Account.Id> reviewedBy)
      • setHashtags

        public void setHashtags​(Set<String> hashtags)
      • stars

        public com.google.common.collect.ImmutableListMultimap<Account.Id,​String> stars()
      • setStars

        public void setStars​(com.google.common.collect.ListMultimap<Account.Id,​String> stars)
      • isPureRevert

        public Boolean isPureRevert()
        Returns null if revertOf is null; true if the change is a pure revert; false otherwise.
      • setRefStates

        public void setRefStates​(com.google.common.collect.ImmutableSetMultimap<Project.NameKey,​RefState> refStates)
      • getRefStatePatterns

        public com.google.common.collect.ImmutableList<byte[]> getRefStatePatterns()
      • setRefStatePatterns

        public void setRefStatePatterns​(Iterable<byte[]> refStatePatterns)