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 interface
static class
static class
static 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 ChangeData
createForTest
(Project.NameKey project, Change.Id id, int currentPatchSetId, org.eclipse.jgit.lib.ObjectId commitId) Create an instance for testing only.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.com.google.common.collect.Table<Account.Id,
PatchSet.Id, org.eclipse.jgit.lib.Ref> editRefs()
static void
ensureAllPatchSetsLoaded
(Iterable<ChangeData> changes) static void
ensureChangeLoaded
(Iterable<ChangeData> changes) static void
ensureChangeServerId
(Iterable<ChangeData> changes) static void
ensureCurrentApprovalsLoaded
(Iterable<ChangeData> changes) static void
ensureCurrentPatchSetLoaded
(Iterable<ChangeData> changes) static void
ensureMessagesLoaded
(Iterable<ChangeData> changes) static void
org.eclipse.jgit.lib.PersonIdent
org.eclipse.jgit.lib.PersonIdent
getId()
Returns theOptional
value of time when the change was merged.com.google.common.collect.ImmutableList<byte[]>
com.google.common.collect.SetMultimap<Project.NameKey,
RefState> boolean
hashtags()
isMerge()
boolean
Returnsnull
ifrevertOf
isnull
; true if the change is a pure revert; false otherwise.boolean
isReviewedBy
(Account.Id accountId) boolean
isStarred
(Account.Id accountId) boolean
lazyload()
Returnstrue
if we allow reading data from NoteDb.messages()
Optional<org.eclipse.jgit.lib.ObjectId>
org.eclipse.jgit.lib.ObjectId
notes()
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()
void
setAttentionSet
(com.google.common.collect.ImmutableSet<AttentionSetUpdate> attentionSet) Sets the specified attention set.void
void
setChangedLines
(int insertions, int deletions) void
setCurrentApprovals
(List<PatchSetApproval> approvals) void
setCurrentFilePaths
(List<String> filePaths) void
setCustomKeyedValues
(Map<String, String> customKeyedValues) void
void
setHashtags
(Set<String> hashtags) void
setLinesDeleted
(int deletions) void
setLinesInserted
(int insertions) void
setMergeable
(Boolean mergeable) void
setMergedOn
(Instant mergedOn) Sets the value e.g.setMetaRevision
(org.eclipse.jgit.lib.ObjectId metaRevision) void
void
setPatchSets
(Collection<PatchSet> patchSets) void
setPendingReviewers
(ReviewerSet pendingReviewers) void
setPendingReviewersByEmail
(ReviewerByEmailSet pendingReviewersByEmail) void
setRefStatePatterns
(Iterable<byte[]> refStatePatterns) void
setRefStates
(com.google.common.collect.ImmutableSetMultimap<Project.NameKey, RefState> refStates) void
setReviewedBy
(Set<Account.Id> reviewedBy) void
setReviewers
(ReviewerSet reviewers) void
setReviewersByEmail
(ReviewerByEmailSet reviewersByEmail) void
setReviewerUpdates
(List<ReviewerStatusUpdate> reviewerUpdates) void
setStars
(List<Account.Id> accountIds) setStorageConstraint
(ChangeData.StorageConstraint storageConstraint) If false, omit fields that require database/repo IO.void
setSubmitRecords
(SubmitRuleOptions options, List<SubmitRecord> records) void
setSubmitRequirements
(Map<SubmitRequirement, SubmitRequirementResult> submitRequirements) void
setTotalCommentCount
(Integer count) void
setUnresolvedCommentCount
(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
lazyLoad
is on, theChangeData
object will load from the database ("lazily") when a field accessor is called. -
getStorageConstraint
-
lazyload
public boolean lazyload()Returnstrue
if 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 theOptional
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 inChangeNotes
)- Returns:
Optional
value of time when the change was merged.- Throws:
com.google.gerrit.exceptions.StorageException
- iflazyLoad
is off,ChangeNotes
can 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
Returnsnull
ifrevertOf
isnull
; 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
-