Class ManagerBackedItemForest
- All Implemented Interfaces:
ItemForest,RowRetriever
-
Field Summary
Fields inherited from interface RowRetriever
IGNORE_MISSING_ROWS -
Constructor Summary
ConstructorsConstructorDescriptionManagerBackedItemForest(Forest forest, RowManager rowManager) ManagerBackedItemForest(Forest forest, RowManager rowManager, ItemAccessMode defaultAccessMode) -
Method Summary
Modifier and TypeMethodDescriptiongetRow(long rowId, ItemAccessMode access) RetrievesStructureRowwith additional information about how the calling code is going to use methodStructureRow.getItem(java.lang.Class<I>).voidscanRows(LongIterable rows, boolean sorted, ItemAccessMode access, LongCollector missingCollector, Predicate<StructureRow> iteratee) Loads multiple rows by their IDs and callsiterateewith aStructureRowfor each row ID in the input.toString()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ItemForest
collectItemIdsMethods inherited from interface RowRetriever
collectIssueIds, collectIssueIds, getRow, reduceOverRows, scanAllExistingRows, scanAllExistingRows, scanAllExistingRows, scanAllRows, scanAllRows, scanAllRows, scanAllRows, scanRows, scanRows, scanRows
-
Constructor Details
-
ManagerBackedItemForest
-
ManagerBackedItemForest
public ManagerBackedItemForest(@NotNull Forest forest, @NotNull RowManager rowManager, @Nullable ItemAccessMode defaultAccessMode)
-
-
Method Details
-
getForest
- Specified by:
getForestin interfaceItemForest
-
getRow
@NotNull public StructureRow getRow(long rowId, @NotNull ItemAccessMode access) throws MissingRowException Description copied from interface:RowRetrieverRetrieves
StructureRowwith additional information about how the calling code is going to use methodStructureRow.getItem(java.lang.Class<I>). The implementation may be optimized according to theaccessparameter.If row's item is invisible or does not exist,
StructureRowis returned anyway, butStructureRow.getItem(java.lang.Class<I>)returnnull.- Specified by:
getRowin interfaceRowRetriever- Parameters:
rowId- row IDaccess- defines how item object is going to be accessed- Returns:
- row instance
- Throws:
MissingRowException- if the specified row ID does not exist- See Also:
-
scanRows
public void scanRows(@Nullable LongIterable rows, boolean sorted, @NotNull ItemAccessMode access, @Nullable LongCollector missingCollector, @NotNull Predicate<StructureRow> iteratee) throws MissingRowException Description copied from interface:RowRetrieverLoads multiple rows by their IDs and calls
iterateewith aStructureRowfor each row ID in the input. Use this method whenever you need to read a potentially large amount of rows and the order of retrieval is not important.For example, use
scanRowsto iterate through the whole forest to see if it has a generator row, or to process user input that has an array of row IDs.The order in which
iterateeis called is not guaranteed to be the same as the iteration order ofrows. Likewise,missingCollectormay receive row IDs out of order.The implementation of
iterateemust be reasonably fast and avoid taking locks or accessing long-running services. It's possible to call otherRowRetrievermethods insideiteratee.It's possible to pass
LongIteratorasLongIterable- the iterator() method is guaranteed to be called only once.Item access mode
You can choose an appropriate value for the access parameter based on what you're going to do with rows in the
iteratee. This allows the provider ofStructureRowinstances to optimize howStructureRow.getItem(java.lang.Class<I>)method works.Dealing with missing rows
If a row ID in the input stream does not correspond to an existing row, the behavior depends on whether the
missingCollectorparameter is set. If it'snull, then the method will immediately throw aMissingRowException. If it's not null, the collector will be called with the missing row ID.To simply ignore the missing rows, you can use
RowRetriever.IGNORE_MISSING_ROWScollector or use one of theRowRetriever.scanAllExistingRows(com.almworks.integers.LongIterable, boolean, com.almworks.jira.structure.api.row.ItemAccessMode, java.util.function.Consumer<com.almworks.jira.structure.api.row.StructureRow>)methods.Note that if the current user does not have access to a row, but the row itself exists, it's not considered missing.
Super-root
Note that normally a row retriever does not handle
SuperRootRowin any special way, so it will be a case of a missing row. Some implementations may, however, support accessing the super-root.Implementation notes
The default implementation is based on calling
RowRetriever.getRow(long). Specific implementations should optimize this method for retrieving multiple rows at once.Do not override other bulk scanning methods, unless that allows for additional optimization.
- Specified by:
scanRowsin interfaceRowRetriever- Parameters:
rows- row IDs of the rows to scansorted- if true, then the caller guarantees the row IDs to be sorted - this can be used for optimizationaccess- indicates how thegetItem()method of the providedStructureRowis going to be used and allows to skip the access checkingmissingCollector- a collector to receive non-existing row IDs, ornulliteratee- predicate to call for each resolved row; if it returnsfalse, the iteration stops and the method returns- Throws:
MissingRowException- if a row was not found andmissingCollectoris null- See Also:
-
toString
-