Search in sources :

Example 1 with HistoryRequestParams

use of com.epam.ta.reportportal.core.item.impl.history.param.HistoryRequestParams 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)

Example 2 with HistoryRequestParams

use of com.epam.ta.reportportal.core.item.impl.history.param.HistoryRequestParams in project service-api by reportportal.

the class TestItemBaselineHistoryProvider method loadHistory.

private Page<TestItemHistory> loadHistory(Queryable filter, Pageable pageable, Long itemId, HistoryRequestParams historyRequestParams, ReportPortalUser.ProjectDetails projectDetails, ReportPortalUser user, boolean usingHash) {
    TestItem testItem = testItemRepository.findById(itemId).orElseThrow(() -> new ReportPortalException(ErrorType.TEST_ITEM_NOT_FOUND, itemId));
    Launch launch = testItemService.getEffectiveLaunch(testItem);
    launchAccessValidator.validate(launch.getId(), projectDetails, user);
    return historyRequestParams.getHistoryType().filter(HistoryRequestParams.HistoryTypeEnum.LINE::equals).map(type -> testItemRepository.loadItemsHistoryPage(filter, pageable, projectDetails.getProjectId(), launch.getName(), historyRequestParams.getHistoryDepth(), usingHash)).orElseGet(() -> testItemRepository.loadItemsHistoryPage(filter, pageable, projectDetails.getProjectId(), historyRequestParams.getHistoryDepth(), usingHash));
}
Also used : Launch(com.epam.ta.reportportal.entity.launch.Launch) TestItemService(com.epam.ta.reportportal.core.item.TestItemService) TestItem(com.epam.ta.reportportal.entity.item.TestItem) TestItemHistory(com.epam.ta.reportportal.entity.item.history.TestItemHistory) LaunchAccessValidator(com.epam.ta.reportportal.core.item.impl.LaunchAccessValidator) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) Autowired(org.springframework.beans.factory.annotation.Autowired) BooleanUtils(org.apache.commons.lang3.BooleanUtils) ErrorType(com.epam.ta.reportportal.ws.model.ErrorType) Operator(org.jooq.Operator) TestItemCriteriaConstant(com.epam.ta.reportportal.commons.querygen.constant.TestItemCriteriaConstant) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) List(java.util.List) com.epam.ta.reportportal.commons.querygen(com.epam.ta.reportportal.commons.querygen) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) HistoryProvider(com.epam.ta.reportportal.core.item.impl.history.provider.HistoryProvider) Service(org.springframework.stereotype.Service) Pageable(org.springframework.data.domain.Pageable) TestItemRepository(com.epam.ta.reportportal.dao.TestItemRepository) HistoryRequestParams(com.epam.ta.reportportal.core.item.impl.history.param.HistoryRequestParams) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) Launch(com.epam.ta.reportportal.entity.launch.Launch) HistoryRequestParams(com.epam.ta.reportportal.core.item.impl.history.param.HistoryRequestParams) TestItem(com.epam.ta.reportportal.entity.item.TestItem)

Aggregations

ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)2 HistoryRequestParams (com.epam.ta.reportportal.core.item.impl.history.param.HistoryRequestParams)2 TestItemRepository (com.epam.ta.reportportal.dao.TestItemRepository)2 TestItem (com.epam.ta.reportportal.entity.item.TestItem)2 TestItemHistory (com.epam.ta.reportportal.entity.item.history.TestItemHistory)2 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Operator (org.jooq.Operator)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 Page (org.springframework.data.domain.Page)2 Pageable (org.springframework.data.domain.Pageable)2 Service (org.springframework.stereotype.Service)2 com.epam.ta.reportportal.commons.querygen (com.epam.ta.reportportal.commons.querygen)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