Search in sources :

Example 6 with ChartStatisticsContent

use of com.epam.ta.reportportal.entity.widget.content.ChartStatisticsContent in project service-api by reportportal.

the class ChartInvestigatedContentLoader 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());
    String timeLineOption = WidgetOptionUtil.getValueByKey(TIMELINE, widgetOptions);
    if (StringUtils.isNotBlank(timeLineOption)) {
        Optional<Period> period = Period.findByName(timeLineOption);
        if (period.isPresent()) {
            Map<String, ChartStatisticsContent> statistics = groupByDate(widgetContentRepository.timelineInvestigatedStatistics(filter, sort, limit), period.get());
            return MapUtils.isEmpty(statistics) ? emptyMap() : calculateInvestigatedPercentage(statistics);
        }
    }
    List<ChartStatisticsContent> content = widgetContentRepository.investigatedStatistics(filter, sort, limit);
    return CollectionUtils.isEmpty(content) ? emptyMap() : singletonMap(RESULT, content);
}
Also used : Filter(com.epam.ta.reportportal.commons.querygen.Filter) Sort(org.springframework.data.domain.Sort) ChartStatisticsContent(com.epam.ta.reportportal.entity.widget.content.ChartStatisticsContent)

Example 7 with ChartStatisticsContent

use of com.epam.ta.reportportal.entity.widget.content.ChartStatisticsContent 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)

Example 8 with ChartStatisticsContent

use of com.epam.ta.reportportal.entity.widget.content.ChartStatisticsContent in project service-api by reportportal.

the class AbstractStatisticsContentLoader method groupStatistics.

private void groupStatistics(String groupingPattern, List<ChartStatisticsContent> statisticsContents, Map<String, ChartStatisticsContent> chart) {
    Map<String, List<ChartStatisticsContent>> groupedStatistics = statisticsContents.stream().collect(Collectors.groupingBy(c -> new DateTime(c.getStartTime()).toString(groupingPattern), LinkedHashMap::new, Collectors.toList()));
    groupedStatistics.forEach((key, contents) -> chart.keySet().stream().filter(k -> k.startsWith(key)).findFirst().ifPresent(k -> {
        ChartStatisticsContent content = chart.get(k);
        contents.add(content);
        Map<String, String> values = contents.stream().map(v -> v.getValues().entrySet()).flatMap(Collection::stream).collect(Collectors.toMap(Map.Entry::getKey, entry -> ofNullable(entry.getValue()).orElse("0"), (prev, curr) -> prev = String.valueOf(Double.parseDouble(prev) + Double.parseDouble(curr))));
        content.setValues(values);
        chart.put(k, content);
    }));
}
Also used : ChartStatisticsContent(com.epam.ta.reportportal.entity.widget.content.ChartStatisticsContent) java.util(java.util) MapUtils(org.apache.commons.collections.MapUtils) Optional.ofNullable(java.util.Optional.ofNullable) DateTime(org.joda.time.DateTime) DATE_PATTERN(net.sf.jasperreports.types.date.FixedDate.DATE_PATTERN) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) BinaryOperator(java.util.function.BinaryOperator) DateTime(org.joda.time.DateTime) ChartStatisticsContent(com.epam.ta.reportportal.entity.widget.content.ChartStatisticsContent)

Example 9 with ChartStatisticsContent

use of com.epam.ta.reportportal.entity.widget.content.ChartStatisticsContent in project service-api by reportportal.

the class BugTrendChartContentLoader 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> result = widgetContentRepository.bugTrendStatistics(filter, contentFields, sort, limit);
    return result.isEmpty() ? emptyMap() : singletonMap(RESULT, result);
}
Also used : Filter(com.epam.ta.reportportal.commons.querygen.Filter) Sort(org.springframework.data.domain.Sort) ChartStatisticsContent(com.epam.ta.reportportal.entity.widget.content.ChartStatisticsContent)

Example 10 with ChartStatisticsContent

use of com.epam.ta.reportportal.entity.widget.content.ChartStatisticsContent in project service-api by reportportal.

the class LaunchExecutionAndIssueStatisticsContentLoader 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);
    return content.isEmpty() ? emptyMap() : singletonMap(RESULT, content);
}
Also used : Filter(com.epam.ta.reportportal.commons.querygen.Filter) Sort(org.springframework.data.domain.Sort) ChartStatisticsContent(com.epam.ta.reportportal.entity.widget.content.ChartStatisticsContent)

Aggregations

ChartStatisticsContent (com.epam.ta.reportportal.entity.widget.content.ChartStatisticsContent)11 Filter (com.epam.ta.reportportal.commons.querygen.Filter)6 Sort (org.springframework.data.domain.Sort)6 Optional.ofNullable (java.util.Optional.ofNullable)4 java.util (java.util)3 BinaryOperator (java.util.function.BinaryOperator)3 Function (java.util.function.Function)3 Collectors (java.util.stream.Collectors)3 DATE_PATTERN (net.sf.jasperreports.types.date.FixedDate.DATE_PATTERN)3 MapUtils (org.apache.commons.collections.MapUtils)3 DateTime (org.joda.time.DateTime)3 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 ArrayList (java.util.ArrayList)1