@PublicApi
public interface StructureAttributeService
StructureAttributeService
provides unified way to retrieve field values, aggregate values or any other
defined attributes for issues or other items.
An "attribute" is an abstraction that lets the consumer of this service not care about what type of value is needed (is it just a field value or an aggregated value), how to calculate it, how to cache it and what type of items is this value defined for.
Furthermore, attribute system is extensible, so a third-party plugin can use attributes SPI to define their
own attribute or extend how existing attributes work for a new type of items. See AttributeLoaderProvider
for details.
This service is intended to be used for retrieving values for multiple attributes of multiple rows in one go.
Whenever you need to retrieve multiple values, try to minimize the number of calls to StructureAttributeService
for best performance.
The method that takes ForestSpec
as the forest definition is preferred over the others because it
enables StructureAttributeService
to cache the results. The forest specification serves as the cache key
and the service is able to correctly invalidate all cached values when the forest or items change.
The methods that receive an arbitrary forest don't do caching and always recalculate the values.
Normally, if you request a value for a row ID that is not in the forest, you'll get an undefined value
in return. However, StructureAttributeService
additionally checks if the row is a copy of another row,
made by a generator. In that case the calculation is performed for the original row. The resulting value can be
retrieved from the result by the row ID that was requested, so this conversion is transparent to the caller.
AttributeSpec
,
ForestSpec
,
VersionedRowValues
,
CoreAttributeSpecs
Modifier and Type | Method and Description |
---|---|
VersionedRowValues |
getAttributeValues(Forest forest,
com.almworks.integers.LongList rows,
Collection<? extends AttributeSpec<?>> attributes)
Returns attribute values for the given matrix of Rows and Attributes.
|
VersionedRowValues |
getAttributeValues(ForestSpec spec,
com.almworks.integers.LongList rows,
Collection<? extends AttributeSpec<?>> attributes)
Returns attribute values for the given matrix of Rows and Attributes.
|
VersionedRowValues |
getAttributeValues(ItemForest forest,
com.almworks.integers.LongList rows,
Collection<? extends AttributeSpec<?>> attributes)
Returns attribute values for the given matrix of Rows and Attributes.
|
@NotNull VersionedRowValues getAttributeValues(@Nullable ForestSpec spec, @Nullable com.almworks.integers.LongList rows, @Nullable Collection<? extends AttributeSpec<?>> attributes)
Returns attribute values for the given matrix of Rows and Attributes. The value is retrieved for each
(row, attribute)
pair from the collections of rows and attributes passed as parameters.
The values are cached when possible.
spec
- forest specification that identifies the forest, which contains the given rowsrows
- a collection of row IDs for which the values are neededattributes
- a collection of attribute specifications for the values that are needed@NotNull VersionedRowValues getAttributeValues(@Nullable Forest forest, @Nullable com.almworks.integers.LongList rows, @Nullable Collection<? extends AttributeSpec<?>> attributes)
Returns attribute values for the given matrix of Rows and Attributes. The value is retrieved for each
(row, attribute)
pair from the collections of rows and attributes passed as parameters.
The values are not cached because this method accepts an arbitrary forest. If you need to calculate
values for a structure or other forest that can be identified with ForestSpec
, use
getAttributeValues(ForestSpec, LongList, Collection)
.
forest
- forest that contains the given rowsrows
- a collection of row IDs for which the values are neededattributes
- a collection of attribute specifications for the values that are neededVersionedRowValues getAttributeValues(@Nullable ItemForest forest, @Nullable com.almworks.integers.LongList rows, @Nullable Collection<? extends AttributeSpec<?>> attributes)
Returns attribute values for the given matrix of Rows and Attributes. The value is retrieved for each
(row, attribute)
pair from the collections of rows and attributes passed as parameters.
The values are not cached because this method accepts an arbitrary forest. If you need to calculate
values for a structure or other forest that can be identified with ForestSpec
, use
getAttributeValues(ForestSpec, LongList, Collection)
.
This method lets you calculate values for temporary rows, which are not yet known to RowManager
. By
providing an instance of ItemForest
, you have StructureAttributeService
bypass going to row manager
for row data. Typically, negative row ID numbers are used for temporary rows.
forest
- forest that contains the given rows and information about each rowrows
- a collection of row IDs for which the values are neededattributes
- a collection of attribute specifications for the values that are neededCopyright © 2016 ALM Works. All Rights Reserved.