Search in sources :

Example 1 with TIMELINE

use of com.epam.ta.reportportal.core.widget.content.constant.ContentLoaderConstants.TIMELINE in project service-api by reportportal.

the class LineChartContentLoader method loadContent.

@Override
public Map<String, ?> loadContent(List<String> contentFields, Map<Filter, Sort> filterSortMapping, WidgetOptions widgetOptions, int limit) {
    Filter filter = GROUP_FILTERS.apply(filterSortMapping.keySet());
    Sort sort = GROUP_SORTS.apply(filterSortMapping.values());
    List<ChartStatisticsContent> content = widgetContentRepository.launchStatistics(filter, contentFields, sort, limit);
    String timeLineOption = ofNullable(widgetOptions).map(wo -> WidgetOptionUtil.getValueByKey(TIMELINE, wo)).orElse(Strings.EMPTY);
    if (StringUtils.isNotBlank(timeLineOption)) {
        Optional<Period> period = Period.findByName(timeLineOption);
        if (period.isPresent()) {
            return CollectionUtils.isEmpty(content) ? emptyMap() : singletonMap(RESULT, groupByDate(content, period.get()));
        }
    }
    return CollectionUtils.isEmpty(content) ? emptyMap() : singletonMap(RESULT, content);
}
Also used : WidgetOptions(com.epam.ta.reportportal.entity.widget.WidgetOptions) GROUP_SORTS(com.epam.ta.reportportal.core.widget.util.WidgetFilterUtil.GROUP_SORTS) Collections.emptyMap(java.util.Collections.emptyMap) TIMELINE(com.epam.ta.reportportal.core.widget.content.constant.ContentLoaderConstants.TIMELINE) Optional.ofNullable(java.util.Optional.ofNullable) Filter(com.epam.ta.reportportal.commons.querygen.Filter) WidgetOptionUtil(com.epam.ta.reportportal.core.widget.util.WidgetOptionUtil) Autowired(org.springframework.beans.factory.annotation.Autowired) GROUP_FILTERS(com.epam.ta.reportportal.core.widget.util.WidgetFilterUtil.GROUP_FILTERS) WidgetContentRepository(com.epam.ta.reportportal.dao.WidgetContentRepository) StringUtils(org.apache.commons.lang3.StringUtils) ChartStatisticsContent(com.epam.ta.reportportal.entity.widget.content.ChartStatisticsContent) List(java.util.List) RESULT(com.epam.ta.reportportal.core.widget.content.constant.ContentLoaderConstants.RESULT) LoadContentStrategy(com.epam.ta.reportportal.core.widget.content.LoadContentStrategy) CollectionUtils(org.apache.commons.collections.CollectionUtils) Service(org.springframework.stereotype.Service) Map(java.util.Map) Strings(org.apache.logging.log4j.util.Strings) Optional(java.util.Optional) Sort(org.springframework.data.domain.Sort) Collections.singletonMap(java.util.Collections.singletonMap) Filter(com.epam.ta.reportportal.commons.querygen.Filter) Sort(org.springframework.data.domain.Sort) ChartStatisticsContent(com.epam.ta.reportportal.entity.widget.content.ChartStatisticsContent)

Aggregations

Filter (com.epam.ta.reportportal.commons.querygen.Filter)1 LoadContentStrategy (com.epam.ta.reportportal.core.widget.content.LoadContentStrategy)1 RESULT (com.epam.ta.reportportal.core.widget.content.constant.ContentLoaderConstants.RESULT)1 TIMELINE (com.epam.ta.reportportal.core.widget.content.constant.ContentLoaderConstants.TIMELINE)1 GROUP_FILTERS (com.epam.ta.reportportal.core.widget.util.WidgetFilterUtil.GROUP_FILTERS)1 GROUP_SORTS (com.epam.ta.reportportal.core.widget.util.WidgetFilterUtil.GROUP_SORTS)1 WidgetOptionUtil (com.epam.ta.reportportal.core.widget.util.WidgetOptionUtil)1 WidgetContentRepository (com.epam.ta.reportportal.dao.WidgetContentRepository)1 WidgetOptions (com.epam.ta.reportportal.entity.widget.WidgetOptions)1 ChartStatisticsContent (com.epam.ta.reportportal.entity.widget.content.ChartStatisticsContent)1 Collections.emptyMap (java.util.Collections.emptyMap)1 Collections.singletonMap (java.util.Collections.singletonMap)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Optional.ofNullable (java.util.Optional.ofNullable)1 CollectionUtils (org.apache.commons.collections.CollectionUtils)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Strings (org.apache.logging.log4j.util.Strings)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1