Search in sources :

Example 1 with CRITERIA_HAS_STATS

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

the class TestItemsHistoryHandlerImpl method getItemsHistory.

@Override
public Iterable<TestItemHistoryElement> getItemsHistory(ReportPortalUser.ProjectDetails projectDetails, Queryable filter, Pageable pageable, HistoryRequestParams historyRequestParams, ReportPortalUser user) {
    validateHistoryDepth(historyRequestParams.getHistoryDepth());
    CompositeFilter itemHistoryFilter = new CompositeFilter(Operator.AND, filter, Filter.builder().withTarget(filter.getTarget().getClazz()).withCondition(FilterCondition.builder().eq(CRITERIA_PROJECT_ID, String.valueOf(projectDetails.getProjectId())).build()).withCondition(FilterCondition.builder().eq(CRITERIA_LAUNCH_MODE, LaunchModeEnum.DEFAULT.name()).build()).withCondition(FilterCondition.builder().eq(CRITERIA_HAS_STATS, String.valueOf(Boolean.TRUE)).build()).build());
    Page<TestItemHistory> testItemHistoryPage = historyProviderFactory.getProvider(historyRequestParams).orElseThrow(() -> new ReportPortalException(UNABLE_LOAD_TEST_ITEM_HISTORY, "Unable to find suitable history baseline provider")).provide(itemHistoryFilter, pageable, historyRequestParams, projectDetails, user, !oldHistory);
    return buildHistoryElements(oldHistory ? TestItemResource::getUniqueId : testItemResource -> String.valueOf(testItemResource.getTestCaseHash()), testItemHistoryPage, projectDetails.getProjectId(), pageable);
}
Also used : CRITERIA_PROJECT_ID(com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_PROJECT_ID) TestItem(com.epam.ta.reportportal.entity.item.TestItem) TestItemHistory(com.epam.ta.reportportal.entity.item.history.TestItemHistory) Autowired(org.springframework.beans.factory.annotation.Autowired) Operator(org.jooq.Operator) Function(java.util.function.Function) TestItemsHistoryHandler(com.epam.ta.reportportal.core.item.history.TestItemsHistoryHandler) Value(org.springframework.beans.factory.annotation.Value) MIN_HISTORY_DEPTH_BOUND(com.epam.ta.reportportal.ws.model.ValidationConstraints.MIN_HISTORY_DEPTH_BOUND) Lists(com.google.common.collect.Lists) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) TestItemResource(com.epam.ta.reportportal.ws.model.TestItemResource) Service(org.springframework.stereotype.Service) TestItemConverter(com.epam.ta.reportportal.ws.converter.converters.TestItemConverter) Map(java.util.Map) UNABLE_LOAD_TEST_ITEM_HISTORY(com.epam.ta.reportportal.ws.model.ErrorType.UNABLE_LOAD_TEST_ITEM_HISTORY) Pageable(org.springframework.data.domain.Pageable) CRITERIA_LAUNCH_MODE(com.epam.ta.reportportal.commons.querygen.constant.LaunchCriteriaConstant.CRITERIA_LAUNCH_MODE) TestItemRepository(com.epam.ta.reportportal.dao.TestItemRepository) CRITERIA_HAS_STATS(com.epam.ta.reportportal.commons.querygen.constant.TestItemCriteriaConstant.CRITERIA_HAS_STATS) TestItemHistoryElement(com.epam.ta.reportportal.ws.model.TestItemHistoryElement) BusinessRule(com.epam.ta.reportportal.commons.validation.BusinessRule) Predicate(java.util.function.Predicate) Optional.ofNullable(java.util.Optional.ofNullable) Filter(com.epam.ta.reportportal.commons.querygen.Filter) LaunchModeEnum(com.epam.ta.reportportal.entity.enums.LaunchModeEnum) TestItemUpdaterContent(com.epam.ta.reportportal.ws.converter.utils.item.content.TestItemUpdaterContent) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) PageableExecutionUtils(org.springframework.data.repository.support.PageableExecutionUtils) FilterCondition(com.epam.ta.reportportal.commons.querygen.FilterCondition) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) PagedResourcesAssembler(com.epam.ta.reportportal.ws.converter.PagedResourcesAssembler) List(java.util.List) HistoryProviderFactory(com.epam.ta.reportportal.core.item.impl.history.provider.HistoryProviderFactory) Queryable(com.epam.ta.reportportal.commons.querygen.Queryable) Optional(java.util.Optional) CompositeFilter(com.epam.ta.reportportal.commons.querygen.CompositeFilter) Suppliers(com.epam.ta.reportportal.commons.validation.Suppliers) MAX_HISTORY_DEPTH_BOUND(com.epam.ta.reportportal.ws.model.ValidationConstraints.MAX_HISTORY_DEPTH_BOUND) ResourceUpdater(com.epam.ta.reportportal.ws.converter.utils.ResourceUpdater) HistoryRequestParams(com.epam.ta.reportportal.core.item.impl.history.param.HistoryRequestParams) ResourceUpdaterProvider(com.epam.ta.reportportal.ws.converter.utils.ResourceUpdaterProvider) CompositeFilter(com.epam.ta.reportportal.commons.querygen.CompositeFilter) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) TestItemHistory(com.epam.ta.reportportal.entity.item.history.TestItemHistory)

Aggregations

ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)1 CompositeFilter (com.epam.ta.reportportal.commons.querygen.CompositeFilter)1 Filter (com.epam.ta.reportportal.commons.querygen.Filter)1 FilterCondition (com.epam.ta.reportportal.commons.querygen.FilterCondition)1 Queryable (com.epam.ta.reportportal.commons.querygen.Queryable)1 CRITERIA_PROJECT_ID (com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_PROJECT_ID)1 CRITERIA_LAUNCH_MODE (com.epam.ta.reportportal.commons.querygen.constant.LaunchCriteriaConstant.CRITERIA_LAUNCH_MODE)1 CRITERIA_HAS_STATS (com.epam.ta.reportportal.commons.querygen.constant.TestItemCriteriaConstant.CRITERIA_HAS_STATS)1 BusinessRule (com.epam.ta.reportportal.commons.validation.BusinessRule)1 Suppliers (com.epam.ta.reportportal.commons.validation.Suppliers)1 TestItemsHistoryHandler (com.epam.ta.reportportal.core.item.history.TestItemsHistoryHandler)1 HistoryRequestParams (com.epam.ta.reportportal.core.item.impl.history.param.HistoryRequestParams)1 HistoryProviderFactory (com.epam.ta.reportportal.core.item.impl.history.provider.HistoryProviderFactory)1 TestItemRepository (com.epam.ta.reportportal.dao.TestItemRepository)1 LaunchModeEnum (com.epam.ta.reportportal.entity.enums.LaunchModeEnum)1 TestItem (com.epam.ta.reportportal.entity.item.TestItem)1 TestItemHistory (com.epam.ta.reportportal.entity.item.history.TestItemHistory)1 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)1 PagedResourcesAssembler (com.epam.ta.reportportal.ws.converter.PagedResourcesAssembler)1 TestItemConverter (com.epam.ta.reportportal.ws.converter.converters.TestItemConverter)1