@PublicSpi
public interface AttributeValuesReceiver
Implementing AttributeValuesReceiver
and using StructureAttributeService.loadAttributeValues(com.almworks.jira.structure.api.forest.ForestSpec, boolean, com.almworks.integers.LongList, java.util.Collection<? extends com.almworks.jira.structure.api.attribute.AttributeSpec<?>>, com.almworks.jira.structure.api.attribute.AttributeValuesReceiver)
methods
allows for the calling code to get some values while other values are still being loaded, get metadata and cancel the loading process.
Most methods have default implementations so the only method that is required is receiveValues(com.almworks.jira.structure.api.attribute.AttributeSpec<T>, com.almworks.jira.structure.api.attribute.ValueColumn<java.lang.Long, T>)
. Override other methods
if you need the corresponding information.
For most methods, there's no particular order in which they are called. Each method may be called multiple times.
The implementations of these method must be reasonably quick. Copying the data for the future consumption (maybe from another thread) is the typical design. You can take locks but make sure they are usually quick to acquire.
You must not call StructureAttributeService
or ForestService
or any other system component that can potentially
block or involve a lot of computation or cause reentrancy into the attribute service.
Modifier and Type | Method and Description |
---|---|
default boolean |
isCancelled()
Used to check if the attribute loading should be cancelled.
|
default void |
receiveInaccessibleRows(LongSet rows)
Notifies the receiver that some of the requested rows were not available for loading by the requested user.
|
default void |
receiveMeta(ValuesMeta meta)
Provides the receiver with the metadata about the loading process.
|
<T> void |
receiveValues(AttributeSpec<T> attributeSpec,
ValueColumn<Long,T> values)
Offers the receiver to retrieve the values for the specified attribute.
|
default void |
valuesReady(AttributeSpec<?> attributeSpec)
Notifies the receiver that the loading process has loaded all requested rows for the given attribute spec.
|
<T> void receiveValues(@NotNull AttributeSpec<T> attributeSpec, @NotNull ValueColumn<Long,T> values)
Offers the receiver to retrieve the values for the specified attribute. It is usually called when a chunk of the values for some attribute has been calculated.
The receiver should request values from ValueColumn
only for the rows that were requested
in the StructureAttributeService.loadAttributeValues(com.almworks.jira.structure.api.forest.ForestSpec, boolean, com.almworks.integers.LongList, java.util.Collection<? extends com.almworks.jira.structure.api.attribute.AttributeSpec<?>>, com.almworks.jira.structure.api.attribute.AttributeValuesReceiver)
call. If you request a value for a row that was not originally requested,
you can get either a null
, a current value, or an outdated value.
The implementation must not save the values
instance anywhere. All values must be read inside this method.
This method may be called multiple times for the same attribute spec. The later calls may contain the same or different values.
Although ValueColumn.getValue(K)
may return null, it should not return null for the rows that were requested.
attributeSpec
- attribute for which values have been loadedvalues
- values accessorValueColumn
default boolean isCancelled()
Used to check if the attribute loading should be cancelled. This method is called periodically during the loading process.
The implementation of this method should be really, really fast and not involve any locking. isCancelled()
is called many times
and any delay would be greatly multiplied.
default void valuesReady(@NotNull AttributeSpec<?> attributeSpec)
Notifies the receiver that the loading process has loaded all requested rows for the given attribute spec. This may be used to count the progress or see which attributes are still being loaded.
Note that receiveValues(com.almworks.jira.structure.api.attribute.AttributeSpec<T>, com.almworks.jira.structure.api.attribute.ValueColumn<java.lang.Long, T>)
for the same attribute may still be called after this method is called, if more values are loaded
for this attribute and some rows that were not requested (this may be caused by other multi-row attributes depending on this one).
attributeSpec
- attribute for which the requested values have been loadedreceiveValues(com.almworks.jira.structure.api.attribute.AttributeSpec<T>, com.almworks.jira.structure.api.attribute.ValueColumn<java.lang.Long, T>)
default void receiveMeta(@NotNull ValuesMeta meta)
Provides the receiver with the metadata about the loading process. This method is called once right before the loading is completed.
The metadata contains some versioning information and diagnostics.
The versions - ValuesMeta.getItemsVersion()
and ValuesMeta.getForestVersion()
- are guaranteed to happen before
or be the same as the actual versions of items stream and the forest at the moments when each reported value was loaded. You can use these
versions to safely check if there might have been any updates in the items or the forest since the loading.
meta
- metadatadefault void receiveInaccessibleRows(@NotNull LongSet rows)
Notifies the receiver that some of the requested rows were not available for loading by the requested user.
A row may be unavailable because it doesn't exist or because the user does not the permission to view the associated item.
This method may be called several times during a single loading call, and the subsequent calls may include the row IDs that were reported in the previous calls. An implementation should accumulate the row IDs somewhere.
rows
- inaccessible row idsCopyright © 2024 Tempo Software. All Rights Reserved.