Class ChangeData
java.lang.Object
com.google.gerrit.server.query.change.ChangeData
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic classstatic classstatic enum -
Method Summary
Modifier and TypeMethodDescriptioncom.google.common.collect.ListMultimap<PatchSet.Id, PatchSetApproval> Returns all patch set approvals for the change, keyed by ID, ordered by timestamp within each patch set.asChanges(List<ChangeData> changeDatas) static Map<Change.Id, ChangeData> asMap(List<ChangeData> changes) com.google.common.collect.ImmutableSet<AttentionSetUpdate> Returns the most recent update (i.e.change()List<org.eclipse.jgit.revwalk.FooterLine> Returns the list of commit footers (which may be empty).com.google.common.collect.ListMultimap<PatchSet.Id, PatchSetApproval> static ChangeDatacreateForTest(Project.NameKey project, Change.Id id, int currentPatchSetId, org.eclipse.jgit.lib.ObjectId commitId) Create an instance for testing only.static ChangeDatacreateForTest(Project.NameKey project, Change.Id id, int currentPatchSetId, org.eclipse.jgit.lib.ObjectId commitId, ChangeNumberVirtualIdAlgorithm virtualIdAlgo, ChangeNotes changeNotes) Create an instance for testing only.com.google.common.collect.Table<Account.Id, PatchSet.Id, org.eclipse.jgit.lib.Ref> editRefs()static voidensureAllPatchSetsLoaded(Iterable<ChangeData> changes) static voidensureChangeLoaded(Iterable<ChangeData> changes) static voidensureChangeServerId(Iterable<ChangeData> changes) static voidensureCurrentApprovalsLoaded(Iterable<ChangeData> changes) static voidensureCurrentPatchSetLoaded(Iterable<ChangeData> changes) static voidensureMessagesLoaded(Iterable<ChangeData> changes) static voidorg.eclipse.jgit.lib.PersonIdentorg.eclipse.jgit.lib.PersonIdentgetId()Returns theOptionalvalue of time when the change was merged.com.google.common.collect.ImmutableList<byte[]> com.google.common.collect.SetMultimap<Project.NameKey, RefState> booleanhashtags()isMerge()booleanReturnsnullifrevertOfisnull; true if the change is a pure revert; false otherwise.booleanisReviewedBy(Account.Id accountId) booleanisStarred(Account.Id accountId) booleanlazyload()Returnstrueif we allow reading data from NoteDb.messages()Optional<org.eclipse.jgit.lib.ObjectId> org.eclipse.jgit.lib.ObjectIdnotes()patchSet(PatchSet.Id psId) Returns patch with the given ID, or null if it does not exist.Returns patches for the change, in patch set ID order.project()voidsetAttentionSet(com.google.common.collect.ImmutableSet<AttentionSetUpdate> attentionSet) Sets the specified attention set.voidvoidsetChangedLines(int insertions, int deletions) voidsetCurrentApprovals(List<PatchSetApproval> approvals) voidsetCurrentFilePaths(List<String> filePaths) voidsetCustomKeyedValues(Map<String, String> customKeyedValues) voidvoidsetHashtags(Set<String> hashtags) voidsetLinesDeleted(int deletions) voidsetLinesInserted(int insertions) voidsetMergeable(Boolean mergeable) voidsetMergedOn(Instant mergedOn) Sets the value e.g.setMetaRevision(org.eclipse.jgit.lib.ObjectId metaRevision) voidvoidsetPatchSets(Collection<PatchSet> patchSets) voidsetPendingReviewers(ReviewerSet pendingReviewers) voidsetPendingReviewersByEmail(ReviewerByEmailSet pendingReviewersByEmail) voidsetRefStatePatterns(Iterable<byte[]> refStatePatterns) voidsetRefStates(com.google.common.collect.ImmutableSetMultimap<Project.NameKey, RefState> refStates) voidsetReviewedBy(Set<Account.Id> reviewedBy) voidsetReviewers(ReviewerSet reviewers) voidsetReviewersByEmail(ReviewerByEmailSet reviewersByEmail) voidsetReviewerUpdates(List<ReviewerStatusUpdate> reviewerUpdates) voidsetStars(List<Account.Id> accountIds) setStorageConstraint(ChangeData.StorageConstraint storageConstraint) If false, omit fields that require database/repo IO.voidsetSubmitRecords(SubmitRuleOptions options, List<SubmitRecord> records) voidsetSubmitRequirements(Map<SubmitRequirement, SubmitRequirementResult> submitRequirements) voidsetTotalCommentCount(Integer count) voidsetUnresolvedCommentCount(Integer count) com.google.common.collect.ImmutableList<Account.Id> stars()submitRecords(SubmitRuleOptions options) Get all evaluated submit requirements for this change, including those from parent projects.Similar tosubmitRequirements(), except that it also converts submit records resulting from the evaluation of legacy submit rules to submit requirements.toString()
-
Method Details
-
asChanges
-
asMap
-
ensureChangeLoaded
-
ensureAllPatchSetsLoaded
-
ensureCurrentPatchSetLoaded
-
ensureCurrentApprovalsLoaded
-
ensureMessagesLoaded
-
ensureReviewedByLoadedForOpenChanges
-
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:
project- project nameid- change IDcurrentPatchSetId- current patchset numbercommitId- commit SHA1 of the current patchset- Returns:
- instance for testing.
-
createForTest
public static ChangeData createForTest(Project.NameKey project, Change.Id id, int currentPatchSetId, org.eclipse.jgit.lib.ObjectId commitId, ChangeNumberVirtualIdAlgorithm virtualIdAlgo, ChangeNotes changeNotes) 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:
project- project nameid- change IDcurrentPatchSetId- current patchset numbercommitId- commit SHA1 of the current patchsetvirtualIdAlgo- algorithm for virtualising the Change numberchangeNotes- notes associated with the Change- Returns:
- instance for testing.
-
setStorageConstraint
@CanIgnoreReturnValue 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
lazyLoadis on, theChangeDataobject will load from the database ("lazily") when a field accessor is called. -
getStorageConstraint
-
lazyload
public boolean lazyload()Returnstrueif we allow reading data from NoteDb. -
getAllUsersNameForIndexing
-
setFailedParsingFromIndex
-
hasFailedParsingFromIndex
public boolean hasFailedParsingFromIndex() -
setCurrentFilePaths
-
currentFilePaths
-
changedLines
-
setChangedLines
public void setChangedLines(int insertions, int deletions) -
setLinesInserted
public void setLinesInserted(int insertions) -
setLinesDeleted
public void setLinesDeleted(int deletions) -
setNoChangedLines
public void setNoChangedLines() -
getId
-
ensureChangeServerId
-
changeServerId
-
virtualId
-
project
-
branchOrThrow
-
isPrivateOrThrow
public boolean isPrivateOrThrow() -
setMetaRevision
-
metaRevision
-
metaRevisionOrThrow
public org.eclipse.jgit.lib.ObjectId metaRevisionOrThrow() -
change
-
setChange
-
reloadChange
-
getLabelTypes
-
notes
-
currentPatchSet
-
currentApprovals
-
setCurrentApprovals
-
commitMessage
-
getAuthor
public org.eclipse.jgit.lib.PersonIdent getAuthor() -
getCommitter
public org.eclipse.jgit.lib.PersonIdent getCommitter() -
attentionSet
Returns the most recent update (i.e. status) per user. -
getMergedOn
Returns theOptionalvalue 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 inChangeNotes)- Returns:
Optionalvalue of time when the change was merged.- Throws:
com.google.gerrit.exceptions.StorageException- iflazyLoadis off,ChangeNotescan not be loaded because we do not expect to call the database.
-
setMergedOn
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 anIllegalStateException. -
patchSets
Returns patches for the change, in patch set ID order. -
setPatchSets
-
patchSet
Returns patch with the given ID, or null if it does not exist. -
approvals
Returns all patch set approvals for the change, keyed by ID, ordered by timestamp within each patch set. -
conditionallyLoadApprovalsWithCopied
public com.google.common.collect.ListMultimap<PatchSet.Id,PatchSetApproval> conditionallyLoadApprovalsWithCopied() -
getSubmitApproval
-
reviewers
-
setReviewers
-
reviewersByEmail
-
setReviewersByEmail
-
getReviewersByEmail
-
setPendingReviewers
-
getPendingReviewers
-
pendingReviewers
-
setPendingReviewersByEmail
-
getPendingReviewersByEmail
-
pendingReviewersByEmail
-
reviewerUpdates
-
setReviewerUpdates
-
getReviewerUpdates
-
publishedComments
-
robotComments
-
unresolvedCommentCount
-
setUnresolvedCommentCount
-
totalCommentCount
-
setTotalCommentCount
-
messages
-
submitRequirementsIncludingLegacy
Similar tosubmitRequirements(), except that it also converts submit records resulting from the evaluation of legacy submit rules to submit requirements. -
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_FIELD. -
setSubmitRequirements
public void setSubmitRequirements(Map<SubmitRequirement, SubmitRequirementResult> submitRequirements) -
submitRecords
-
setSubmitRecords
-
submitTypeRecord
-
setMergeable
-
isMergeable
-
isMerge
-
editsByUser
-
editRefs
-
draftsByUser
-
isReviewedBy
-
reviewedBy
-
setReviewedBy
-
hashtags
-
setHashtags
-
customKeyedValues
-
setCustomKeyedValues
-
stars
-
setStars
-
isStarred
-
isPureRevert
ReturnsnullifrevertOfisnull; true if the change is a pure revert; false otherwise. -
toString
-
getRefStates
-
setRefStates
public void setRefStates(com.google.common.collect.ImmutableSetMultimap<Project.NameKey, RefState> refStates) -
getRefStatePatterns
public com.google.common.collect.ImmutableList<byte[]> getRefStatePatterns() -
setRefStatePatterns
-