Search in sources :

Example 1 with CRITERIA_LAUNCH_ID

use of com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_LAUNCH_ID in project service-api by reportportal.

the class LaunchDataProviderHandlerImpl method updateFilter.

private Queryable updateFilter(Queryable filter, ReportPortalUser.ProjectDetails projectDetails, ReportPortalUser user, Map<String, String> params) {
    Long launchId = Optional.ofNullable(params.get(LAUNCH_ID_PARAM)).map(ControllerUtils::safeParseLong).orElseThrow(() -> new ReportPortalException(ErrorType.BAD_REQUEST_ERROR, "Launch id must be provided for launch based items provider"));
    launchAccessValidator.validate(launchId, projectDetails, user);
    Queryable launchBasedFilter = Filter.builder().withTarget(TestItem.class).withCondition(FilterCondition.builder().eq(CRITERIA_LAUNCH_ID, String.valueOf(launchId)).build()).build();
    // Added to fix performance issue.
    List<String> issueTypeLocators = filter.getFilterConditions().stream().map(ConvertibleCondition::getAllConditions).flatMap(List::stream).filter(c -> CRITERIA_ISSUE_TYPE.equals(c.getSearchCriteria()) && !c.isNegative() && Condition.IN.equals(c.getCondition())).map(FilterCondition::getValue).flatMap(c -> Stream.of(c.split(","))).collect(Collectors.toList());
    String issueTypeIdsString = issueTypeRepository.getIssueTypeIdsByLocators(issueTypeLocators).stream().map(String::valueOf).collect(Collectors.joining(","));
    FilterCondition oldIssueTypeCondition = new FilterCondition(Condition.IN, false, null, CRITERIA_ISSUE_TYPE);
    FilterCondition issueTypeIdCondition = new FilterCondition(Condition.IN, false, issueTypeIdsString, CRITERIA_ISSUE_TYPE_ID);
    filter.replaceSearchCriteria(oldIssueTypeCondition, issueTypeIdCondition);
    return new CompositeFilter(Operator.AND, filter, launchBasedFilter);
}
Also used : TestItem(com.epam.ta.reportportal.entity.item.TestItem) Autowired(org.springframework.beans.factory.annotation.Autowired) ErrorType(com.epam.ta.reportportal.ws.model.ErrorType) Operator(org.jooq.Operator) Statistics(com.epam.ta.reportportal.entity.statistics.Statistics) CRITERIA_ISSUE_TYPE(com.epam.ta.reportportal.commons.querygen.constant.TestItemCriteriaConstant.CRITERIA_ISSUE_TYPE) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) Map(java.util.Map) CRITERIA_LAUNCH_ID(com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_LAUNCH_ID) Pageable(org.springframework.data.domain.Pageable) TestItemRepository(com.epam.ta.reportportal.dao.TestItemRepository) IssueTypeRepositoryCustom(com.epam.ta.reportportal.dao.IssueTypeRepositoryCustom) LaunchAccessValidator(com.epam.ta.reportportal.core.item.impl.LaunchAccessValidator) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) Set(java.util.Set) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) Component(org.springframework.stereotype.Component) List(java.util.List) com.epam.ta.reportportal.commons.querygen(com.epam.ta.reportportal.commons.querygen) Stream(java.util.stream.Stream) CRITERIA_ISSUE_TYPE_ID(com.epam.ta.reportportal.commons.querygen.constant.TestItemCriteriaConstant.CRITERIA_ISSUE_TYPE_ID) Optional(java.util.Optional) DataProviderHandler(com.epam.ta.reportportal.core.item.impl.provider.DataProviderHandler) ControllerUtils(com.epam.ta.reportportal.util.ControllerUtils) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) List(java.util.List)

Example 2 with CRITERIA_LAUNCH_ID

use of com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_LAUNCH_ID in project service-api by reportportal.

the class MostTimeConsumingContentLoader method buildItemFilter.

private Filter buildItemFilter(Long launchId, WidgetOptions widgetOptions, List<String> contentFields) {
    Filter filter = Filter.builder().withTarget(TestItem.class).withCondition(FilterCondition.builder().eq(CRITERIA_LAUNCH_ID, String.valueOf(launchId)).build()).build();
    filter = updateFilterWithStatuses(filter, contentFields);
    filter = updateFilterWithTestItemTypes(filter, ofNullable(widgetOptions.getOptions().get(INCLUDE_METHODS)).map(v -> BooleanUtils.toBoolean(String.valueOf(v))).orElse(false));
    return filter.withCondition(FilterCondition.builder().eq(CRITERIA_HAS_CHILDREN, Boolean.FALSE.toString()).build()).withCondition(FilterCondition.builder().eq(CRITERIA_HAS_STATS, Boolean.TRUE.toString()).build());
}
Also used : TestItemTypeEnum(com.epam.ta.reportportal.entity.enums.TestItemTypeEnum) StatusEnum(com.epam.ta.reportportal.entity.enums.StatusEnum) WidgetOptions(com.epam.ta.reportportal.entity.widget.WidgetOptions) TestItem(com.epam.ta.reportportal.entity.item.TestItem) ContentLoaderConstants(com.epam.ta.reportportal.core.widget.content.constant.ContentLoaderConstants) Autowired(org.springframework.beans.factory.annotation.Autowired) GROUP_FILTERS(com.epam.ta.reportportal.core.widget.util.WidgetFilterUtil.GROUP_FILTERS) BooleanUtils(org.apache.commons.lang3.BooleanUtils) TestItemCriteriaConstant(com.epam.ta.reportportal.commons.querygen.constant.TestItemCriteriaConstant) MostTimeConsumingTestCasesContent(com.epam.ta.reportportal.entity.widget.content.MostTimeConsumingTestCasesContent) StringUtils(org.apache.commons.lang3.StringUtils) Lists(com.google.common.collect.Lists) CollectionUtils(org.apache.commons.collections.CollectionUtils) Service(org.springframework.stereotype.Service) Condition(com.epam.ta.reportportal.commons.querygen.Condition) Map(java.util.Map) CRITERIA_LAUNCH_ID(com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_LAUNCH_ID) CRITERIA_NAME(com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_NAME) Sort(org.springframework.data.domain.Sort) Collections.emptyMap(java.util.Collections.emptyMap) Launch(com.epam.ta.reportportal.entity.launch.Launch) ImmutableMap(com.google.common.collect.ImmutableMap) Optional.ofNullable(java.util.Optional.ofNullable) Filter(com.epam.ta.reportportal.commons.querygen.Filter) WidgetOptionUtil(com.epam.ta.reportportal.core.widget.util.WidgetOptionUtil) FilterCondition(com.epam.ta.reportportal.commons.querygen.FilterCondition) WidgetContentRepository(com.epam.ta.reportportal.dao.WidgetContentRepository) Collectors(java.util.stream.Collectors) List(java.util.List) HAS_METHOD_OR_CLASS(com.epam.ta.reportportal.core.filter.predefined.PredefinedFilters.HAS_METHOD_OR_CLASS) LoadContentStrategy(com.epam.ta.reportportal.core.widget.content.LoadContentStrategy) LaunchRepository(com.epam.ta.reportportal.dao.LaunchRepository) LatestLaunchContent(com.epam.ta.reportportal.entity.widget.content.LatestLaunchContent) STEP(com.epam.ta.reportportal.jooq.enums.JTestItemTypeEnum.STEP) Collections(java.util.Collections) Filter(com.epam.ta.reportportal.commons.querygen.Filter)

Aggregations

CRITERIA_LAUNCH_ID (com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_LAUNCH_ID)2 TestItem (com.epam.ta.reportportal.entity.item.TestItem)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)1 com.epam.ta.reportportal.commons.querygen (com.epam.ta.reportportal.commons.querygen)1 Condition (com.epam.ta.reportportal.commons.querygen.Condition)1 Filter (com.epam.ta.reportportal.commons.querygen.Filter)1 FilterCondition (com.epam.ta.reportportal.commons.querygen.FilterCondition)1 CRITERIA_NAME (com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_NAME)1 TestItemCriteriaConstant (com.epam.ta.reportportal.commons.querygen.constant.TestItemCriteriaConstant)1 CRITERIA_ISSUE_TYPE (com.epam.ta.reportportal.commons.querygen.constant.TestItemCriteriaConstant.CRITERIA_ISSUE_TYPE)1 CRITERIA_ISSUE_TYPE_ID (com.epam.ta.reportportal.commons.querygen.constant.TestItemCriteriaConstant.CRITERIA_ISSUE_TYPE_ID)1 HAS_METHOD_OR_CLASS (com.epam.ta.reportportal.core.filter.predefined.PredefinedFilters.HAS_METHOD_OR_CLASS)1 LaunchAccessValidator (com.epam.ta.reportportal.core.item.impl.LaunchAccessValidator)1 DataProviderHandler (com.epam.ta.reportportal.core.item.impl.provider.DataProviderHandler)1 LoadContentStrategy (com.epam.ta.reportportal.core.widget.content.LoadContentStrategy)1 ContentLoaderConstants (com.epam.ta.reportportal.core.widget.content.constant.ContentLoaderConstants)1