Class GenericServiceInstancesTagListDataProvider<T extends TabularSource<? extends ITabularSourceField>>
- java.lang.Object
-
- lumis.service.tag.GenericServiceInstancesTagListDataProvider<T>
-
- Type Parameters:
T
- the source type.
- All Implemented Interfaces:
IDataProvider<T>
- Direct Known Subclasses:
SingleBlogTagListDataProvider
,TagServiceInstanceTagListDataProvider
@StableMinor(version="14.0", sinceVersion="9.0") public class GenericServiceInstancesTagListDataProvider<T extends TabularSource<? extends ITabularSourceField>> extends Object implements IDataProvider<T>
Generic data provider that read the used tags in contents of a given set of service instances.
This data provider uses the defaultbig data repository
to read the data.
By default, this data provider uses a search like the one performed in the default search service. The basic flow of this data provider is:
- Calculate a
base query
based on theown service instance
andfilter service instances
. Add a search aggregation
to the base query.Perform the search
.Populate source
with the aggregation result.
filter service instances
will be filtered by theown service instance
's area tag.It is important to notice that, by using search aggregation, this data provider does not support pagination.
- Since:
- 9.0.0
- Version:
- $Revision: 24476 $ $Date: 2021-04-28 11:28:23 -0300 (Wed, 28 Apr 2021) $
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
DEFAULT_COUNT_SOURCE_FIELD_ID
The default count source field identifier.protected static String
DEFAULT_TAG_SOURCE_FIELD_ID
The default tag source field identifier.protected static String
SEARCH_AGGREGATION_ID
The default search aggregation identifier.-
Fields inherited from interface lumis.doui.source.IDataProvider
INTERFACE_INSTANCE_PROPERTY_FIELDS, INTERFACE_INSTANCE_PROPERTY_FILTERS, INTERFACE_INSTANCE_PROPERTY_MAX_ROWS, INTERFACE_INSTANCE_PROPERTY_ORDER_BY, MAX_NUM_ORDER_BY_FIELDS
-
-
Constructor Summary
Constructors Constructor Description GenericServiceInstancesTagListDataProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addSearchAggregation(SearchQuery query, T source)
Adds the search aggregation on the givensearch query
.protected SearchQuery
getBaseQuery(T source)
Returns the base search query.protected String
getCountSourceFieldId(T source)
Returns the count source field identifier.protected Collection<String>
getFilterServiceInstaceIds(T source)
Returns the filter service instance identifiers.protected int
getMaxRows(T source)
Returns the maximum number of rows to be returned in source.protected ServiceInstanceConfig
getOwnServiceInstance(T source)
Returns the own service instance.protected String
getSearchAggregationId(T source)
Returns the search aggregation identifier to be used on search.protected String
getTagSourceFieldId(T source)
Returns the tag source field identifier.void
loadData(SessionConfig sessionConfig, T source, ITransaction transaction)
protected void
populateRow(IMultiBucketAggregationResult.IBucket<Serializable> bucket, ISourceData row, T source)
Populates the given row of the given source with the givenbucket
of search aggregation result.protected void
populateSource(T source, Map<String,IAggregationResult> aggregations, SearchQuery query)
Populates the given source with the given aggregations.protected ISearchResults
search(T source, SearchQuery query)
Performs the search.protected void
sortSource(T source, SearchQuery query)
Sorts the given source.
-
-
-
Field Detail
-
SEARCH_AGGREGATION_ID
protected static final String SEARCH_AGGREGATION_ID
The default search aggregation identifier.- Since:
- 9.0.0
- See Also:
- Constant Field Values
-
DEFAULT_TAG_SOURCE_FIELD_ID
protected static final String DEFAULT_TAG_SOURCE_FIELD_ID
The default tag source field identifier.- Since:
- 9.0.0
- See Also:
- Constant Field Values
-
DEFAULT_COUNT_SOURCE_FIELD_ID
protected static final String DEFAULT_COUNT_SOURCE_FIELD_ID
The default count source field identifier.- Since:
- 9.0.0
- See Also:
- Constant Field Values
-
-
Method Detail
-
loadData
public void loadData(SessionConfig sessionConfig, T source, ITransaction transaction) throws PortalException
- Specified by:
loadData
in interfaceIDataProvider<T extends TabularSource<? extends ITabularSourceField>>
- Throws:
PortalException
-
search
protected ISearchResults search(T source, SearchQuery query)
Performs the search.- Parameters:
source
- the source.query
- the query.- Returns:
- the search results.
- Since:
- 9.0.0
-
sortSource
protected void sortSource(T source, SearchQuery query) throws PortalException
Sorts the given source.The default implementation sorts rows accordingly to the
count
source field, descending. It assumes every row have this field filled.- Parameters:
source
- the source.query
- TODO- Throws:
PortalException
- Since:
- 9.0.0
-
populateSource
protected void populateSource(T source, Map<String,IAggregationResult> aggregations, SearchQuery query) throws PortalException
Populates the given source with the given aggregations.The default implementation assumes there's an aggregation result for the given
aggregation identifier
and it is an instance ofIMultiBucketAggregationResult
.- Parameters:
source
- the source.aggregations
- the aggregations.query
- TODO- Throws:
PortalException
- Since:
- 9.0.0
-
populateRow
protected void populateRow(IMultiBucketAggregationResult.IBucket<Serializable> bucket, ISourceData row, T source) throws PortalException
Populates the given row of the given source with the givenbucket
of search aggregation result.The default implementation populates:
count field
will be populated with thebucket's document count
.tag field
will be populated with thebucket's key
.
- Parameters:
bucket
- the bucket.row
- the row.source
- the source.- Throws:
PortalException
- Since:
- 9.0.0
-
addSearchAggregation
protected void addSearchAggregation(SearchQuery query, T source) throws PortalException
Adds the search aggregation on the givensearch query
.- Parameters:
query
- the base query.source
- the source.- Throws:
PortalException
- Since:
- 9.0.0
-
getMaxRows
protected int getMaxRows(T source) throws PortalException
Returns the maximum number of rows to be returned in source.The default implementation returns the
source's max rows
.- Parameters:
source
- the source.- Returns:
- the maximum number of rows to be returned in source.
- Throws:
PortalException
- Since:
- 9.0.0
-
getSearchAggregationId
protected String getSearchAggregationId(T source) throws PortalException
Returns the search aggregation identifier to be used on search.The default implementation always returns
SEARCH_AGGREGATION_ID
.- Parameters:
source
- the source.- Returns:
- the search aggregation identifier to be used on search.
- Throws:
PortalException
- Since:
- 9.0.0
-
getTagSourceFieldId
protected String getTagSourceFieldId(T source) throws PortalException
Returns the tag source field identifier.The default implementation search the source for a field of
tag data type
and returns the first found. If no such field exists, fallback toDEFAULT_TAG_SOURCE_FIELD_ID
.- Parameters:
source
- the source.- Returns:
- the tag source field identifier.
- Throws:
PortalException
- Since:
- 9.0.0
-
getCountSourceFieldId
protected String getCountSourceFieldId(T source) throws PortalException
Returns the count source field identifier.The default implementation search the source for a field of
integer data type
and returns the first found. If no such field exists, fallback toDEFAULT_COUNT_SOURCE_FIELD_ID
.- Parameters:
source
- the source.- Returns:
- the count source field identifier.
- Throws:
PortalException
- Since:
- 9.0.0
-
getBaseQuery
protected SearchQuery getBaseQuery(T source) throws PortalException
Returns the base search query.The default implementation uses a search service-like query.
- Parameters:
source
- the source.- Returns:
- the base search query.
- Throws:
PortalException
- Since:
- 9.0.0
-
getFilterServiceInstaceIds
protected Collection<String> getFilterServiceInstaceIds(T source) throws PortalException
Returns the filter service instance identifiers. These are the service instance identifiers included in search.The default implementation returns a singleton collection of
own service instance
identifier.- Parameters:
source
- the source.- Returns:
- the filter service instance identifiers.
- Throws:
PortalException
- Since:
- 9.0.0
-
getOwnServiceInstance
protected ServiceInstanceConfig getOwnServiceInstance(T source) throws PortalException
Returns the own service instance.- Parameters:
source
- the source.- Returns:
- the own service instance.
- Throws:
PortalException
- Since:
- 9.0.0
-
-