use of com.epam.ta.reportportal.core.widget.content.constant.ContentLoaderConstants.RESULT 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);
}
use of com.epam.ta.reportportal.core.widget.content.constant.ContentLoaderConstants.RESULT in project service-api by reportportal.
the class GetProjectInfoHandlerImpl method getActivities.
private Map<String, List<ActivityResource>> getActivities(Project project, InfoInterval infoInterval) {
String value = Arrays.stream(ActivityAction.values()).filter(not(ACTIVITIES_PROJECT_FILTER)).map(ActivityAction::getValue).collect(joining(","));
Filter filter = new Filter(Activity.class, Lists.newArrayList(new FilterCondition(IN, false, value, CRITERIA_ACTION), new FilterCondition(EQUALS, false, String.valueOf(project.getId()), CRITERIA_PROJECT_ID), new FilterCondition(GREATER_THAN_OR_EQUALS, false, String.valueOf(Timestamp.valueOf(getStartIntervalDate(infoInterval)).getTime()), CRITERIA_CREATION_DATE)));
List<Activity> activities = activityRepository.findByFilter(filter, PageRequest.of(0, LIMIT, Sort.by(Sort.Direction.DESC, CRITERIA_CREATION_DATE))).getContent();
Map<Long, String> userIdLoginMapping = userRepository.findAllById(activities.stream().filter(a -> a.getUserId() != null).map(Activity::getUserId).collect(Collectors.toSet())).stream().collect(toMap(User::getId, User::getLogin));
return Collections.singletonMap(RESULT, activities.stream().map(a -> ofNullable(a.getUserId()).map(userId -> TO_RESOURCE_WITH_USER.apply(a, userIdLoginMapping.get(userId))).orElseGet(() -> TO_RESOURCE.apply(a))).peek(resource -> resource.setProjectName(project.getName())).collect(toList()));
}
Aggregations