Interface AggregateAttributeLoader<T>

Type Parameters:
T - type of the loaded value
All Superinterfaces:
AttributeLoader<T>, MultiRowAttributeLoader<T>, RowAttributeLoader<T>
All Known Implementing Classes:
AbstractAggregateLoader, AbstractNaiveDistinctAggregateLoader, DelegatingAggregateAttributeLoader, LongSumLoader, NumberSumLoader, ReducingAggregateLoader, SingleDependencyReducingAggregateLoader

@PublicSpi public interface AggregateAttributeLoader<T> extends MultiRowAttributeLoader<T>

Aggregate attributes have values calculated up through the hierarchy. The parent row's value depends on the values of its children. For example, a total time spent for all issues under a folder is an aggregate.

Aggregate attribute loader represents an aggregate attribute. Aggregate loading function for a row R can calculate values based on:

  • Already calculated values of the same attribute for direct children rows of R;
  • Values of attribute dependencies for the row R (but not its children);
  • StructureRow data for R and its children;
  • Context values, if declared with AttributeLoader.getContextDependencies().

The loader must be a stable function. It must not depend on any other inputs, and should provide the same result for the same inputs every time: V(row) = AGGREGATE([V(children(row))], dependencies(row)).

The values for children rows and the dependencies for the current row are guaranteed to be loaded by the time the loading function is called.

Using loader data

Note that sometimes an aggregate loader will need to store more data in AttributeValue than the resulting Java type allows. In that case, use loader data - see AttributeValue.withData(java.lang.Object).

Sensitive data control

An aggregate, as well as all multi-row loaders, is potentially capable of accessing data calculated for rows that the requesting user is not allowed to see. For example, a total budget may be calculated over a number of sub-budgets, and a user may not have access to all of them.

If the aggregated attribute is considered sensitive (according to StructureConfiguration.getAttributeSensitivitySettings()), then the calls to AttributeLoaderContext.getDependencyValue(com.almworks.jira.structure.api.attribute.AttributeSpec<V>) will not disclose the hidden value. Instead, the loader function will receive AttributeValue.inaccessible().

In other words, you should not worry about implementing security checks in an aggregate, the system does it for you.

Super-root support

An aggregate may be called to calculate a value for a super-root row (see SuperRootRow), passing all root values as children values.

See Also:
  • Method Details

    • loadValue

      @Nullable AttributeValue<T> loadValue(@NotNull List<AttributeValue<T>> childrenValues, @NotNull AggregateAttributeContext context)

      Performs aggregate loading.

      If the value is missing or empty, the loader should return AttributeValue.undefined(). If for some reason this loader is not applicable for the given row, it should return null. (Note, however, that if multiple aggregate loaders work on the same attribute, it could be tricky and lead to unexpected results.)

      Note: children values may contain loop markers

      Parameters:
      childrenValues - the values of this attribute for all children rows, in the same order as the children rows
      context - loading context
      Returns:
      the calculated value