Class ChangeData
- java.lang.Object
-
- com.google.gerrit.server.query.change.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ChangeData.AssistedFactory
static class
ChangeData.ChangedLines
static class
ChangeData.Factory
static class
ChangeData.StorageConstraint
-
Method Summary
-
-
-
Method Detail
-
asChanges
public static List<Change> asChanges(List<ChangeData> changeDatas)
-
asMap
public static Map<Change.Id,ChangeData> asMap(List<ChangeData> changes)
-
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, theChangeData
object will load from the database ("lazily") when a field accessor is called.
-
getStorageConstraint
public ChangeData.StorageConstraint getStorageConstraint()
-
lazyload
public boolean lazyload()
Returnstrue
if we allow reading data from NoteDb.
-
getAllUsersNameForIndexing
public AllUsersName getAllUsersNameForIndexing()
-
changedLines
public Optional<ChangeData.ChangedLines> 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
public Change.Id getId()
-
project
public Project.NameKey project()
-
change
public Change change()
-
setChange
public void setChange(Change c)
-
reloadChange
public Change reloadChange()
-
getLabelTypes
public LabelTypes getLabelTypes()
-
notes
public ChangeNotes notes()
-
currentPatchSet
public PatchSet currentPatchSet()
-
currentApprovals
public List<PatchSetApproval> currentApprovals()
-
setCurrentApprovals
public void setCurrentApprovals(List<PatchSetApproval> approvals)
-
commitMessage
public String commitMessage()
-
commitFooters
public List<org.eclipse.jgit.revwalk.FooterLine> commitFooters()
Returns the list of commit footers (which may be empty).
-
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 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
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 anIllegalStateException
.
-
patchSets
public Collection<PatchSet> patchSets()
Returns patches for the change, in patch set ID order.
-
setPatchSets
public void setPatchSets(Collection<PatchSet> patchSets)
-
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.
-
getSubmitApproval
public Optional<PatchSetApproval> getSubmitApproval()
-
reviewers
public ReviewerSet reviewers()
-
setReviewers
public void setReviewers(ReviewerSet reviewers)
-
reviewersByEmail
public ReviewerByEmailSet reviewersByEmail()
-
setReviewersByEmail
public void setReviewersByEmail(ReviewerByEmailSet reviewersByEmail)
-
getReviewersByEmail
public ReviewerByEmailSet getReviewersByEmail()
-
setPendingReviewers
public void setPendingReviewers(ReviewerSet pendingReviewers)
-
getPendingReviewers
public ReviewerSet getPendingReviewers()
-
pendingReviewers
public ReviewerSet pendingReviewers()
-
setPendingReviewersByEmail
public void setPendingReviewersByEmail(ReviewerByEmailSet pendingReviewersByEmail)
-
getPendingReviewersByEmail
public ReviewerByEmailSet getPendingReviewersByEmail()
-
pendingReviewersByEmail
public ReviewerByEmailSet pendingReviewersByEmail()
-
reviewerUpdates
public List<ReviewerStatusUpdate> reviewerUpdates()
-
setReviewerUpdates
public void setReviewerUpdates(List<ReviewerStatusUpdate> reviewerUpdates)
-
getReviewerUpdates
public List<ReviewerStatusUpdate> getReviewerUpdates()
-
publishedComments
public Collection<HumanComment> publishedComments()
-
robotComments
public Collection<RobotComment> robotComments()
-
unresolvedCommentCount
public Integer unresolvedCommentCount()
-
setUnresolvedCommentCount
public void setUnresolvedCommentCount(Integer count)
-
totalCommentCount
public Integer totalCommentCount()
-
setTotalCommentCount
public void setTotalCommentCount(Integer count)
-
messages
public List<ChangeMessage> messages()
-
submitRequirementsIncludingLegacy
public Map<SubmitRequirement,SubmitRequirementResult> submitRequirementsIncludingLegacy()
Similar tosubmitRequirements
, except that it also converts submit records resulting from the evaluation of legacy submit rules to submit requirements.
-
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
.
-
setSubmitRequirements
public void setSubmitRequirements(Map<SubmitRequirement,SubmitRequirementResult> submitRequirements)
-
submitRecords
public List<SubmitRecord> submitRecords(SubmitRuleOptions options)
-
setSubmitRecords
public void setSubmitRecords(SubmitRuleOptions options, List<SubmitRecord> records)
-
submitTypeRecord
public SubmitTypeRecord submitTypeRecord()
-
setMergeable
public void setMergeable(Boolean mergeable)
-
isMergeable
public Boolean isMergeable()
-
isMerge
public Boolean isMerge()
-
editsByUser
public Set<Account.Id> editsByUser()
-
editRefs
public com.google.common.collect.Table<Account.Id,PatchSet.Id,org.eclipse.jgit.lib.ObjectId> editRefs()
-
draftsByUser
public Set<Account.Id> draftsByUser()
-
isReviewedBy
public boolean isReviewedBy(Account.Id accountId)
-
reviewedBy
public Set<Account.Id> reviewedBy()
-
setReviewedBy
public void setReviewedBy(Set<Account.Id> reviewedBy)
-
stars
public com.google.common.collect.ImmutableListMultimap<Account.Id,String> stars()
-
setStars
public void setStars(com.google.common.collect.ListMultimap<Account.Id,String> stars)
-
starRefs
public com.google.common.collect.ImmutableMap<Account.Id,StarredChangesUtil.StarRef> starRefs()
-
stars
public Set<String> stars(Account.Id accountId)
-
isPureRevert
public Boolean isPureRevert()
Returnsnull
ifrevertOf
isnull
; true if the change is a pure revert; false otherwise.
-
getRefStates
public com.google.common.collect.SetMultimap<Project.NameKey,RefState> getRefStates()
-
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)
-
-