EventQueryParams extends DataQueryParams { public Set<Legend> getItemLegends() { return getItemsAndItemFilters().stream() .filter( QueryItem::hasLegendSet ) .map( i -> i.getLegendSet().getLegends() ) .flatMap( i -> i.stream() ) .collect( Collectors.toSet() ); } private  EventQueryParams(); static EventQueryParams fromDataQueryParams( DataQueryParams dataQueryParams ); @Override String getKey(); List<QueryItem> getDuplicateQueryItems(); List<QueryItem> getItemsAndItemFilters(); Set<DimensionalItemObject> getDimensionalObjectItems(); Set<Legend> getItemLegends(); Set<Option> getItemOptions(); boolean timeFieldIsValid(); boolean orgUnitFieldIsValid(); ProgramStatus getProgramStatus(); EventQueryParams removeProgramIndicatorItems(); AnalyticsAggregationType getAggregationTypeFallback(); @Override boolean isAggregationType( AggregationType type ); boolean isOrganisationUnitMode( OrganisationUnitSelectionMode mode ); boolean hasItemsOrItemFilters(); boolean isLastPeriodAggregationType(); boolean isFirstPeriodAggregationType(); boolean isFirstOrLastPeriodAggregationType(); boolean hasNonDefaultBoundaries(); boolean hasAnalyticsVariables(); boolean useIndividualQuery(); Set<OrganisationUnit> getOrganisationUnitChildren(); boolean isSorting(); boolean isPaging(); int getPageWithDefault(); int getPageSizeWithDefault(); int getOffset(); boolean hasSortOrder(); boolean hasLimit(); boolean hasEventStatus(); boolean hasValueDimension(); @Override boolean hasProgramIndicatorDimension(); boolean hasEventProgramIndicatorDimension(); boolean hasEnrollmentProgramIndicatorDimension(); boolean hasSinglePeriod(); boolean hasFilterPeriods(); boolean isProgramRegistration(); boolean hasClusterSize(); boolean hasProgramStatus(); boolean hasBbox(); boolean hasDataIdScheme(); int getSortOrderAsInt(); @Override String toString(); List<QueryItem> getItems(); List<QueryItem> getItemFilters(); DimensionalItemObject getValue(); List<ProgramIndicator> getItemProgramIndicators(); ProgramIndicator getProgramIndicator(); List<DimensionalItemObject> getAsc(); @Override List<DimensionalObject> getDimensions(); List<DimensionalItemObject> getDesc(); OrganisationUnitSelectionMode getOrganisationUnitMode(); Integer getPage(); Integer getPageSize(); SortOrder getSortOrder(); Integer getLimit(); EventOutputType getOutputType(); EventStatus getEventStatus(); boolean isCollapseDataDimensions(); boolean isCoordinatesOnly(); boolean isGeometryOnly(); boolean isAggregateData(); Long getClusterSize(); String getCoordinateField(); String getBbox(); boolean isIncludeClusterPoints(); @Override boolean isIncludeMetadataDetails(); IdScheme getDataIdScheme(); static final String EVENT_COORDINATE_FIELD; static final String ENROLLMENT_COORDINATE_FIELD; }
@Test public void testGetItemLegends() { Legend leA = createLegend( 'A', 0d, 1d ); Legend leB = createLegend( 'B', 1d, 2d ); LegendSet lsA = createLegendSet( 'A', leA, leB ); QueryItem qiA = new QueryItem( deA, lsA, deA.getValueType(), deA.getAggregationType(), null ); EventQueryParams params = new EventQueryParams.Builder() .addItem( qiA ) .build(); Set<Legend> expected = Sets.newHashSet( leA, leB ); assertEquals( expected, params.getItemLegends() ); }