Search in sources :

Example 1 with DataProviderType

use of com.epam.ta.reportportal.core.item.impl.provider.DataProviderType in project service-api by reportportal.

the class GetTestItemHandlerImpl method getTestItemsByProvider.

@Override
public Iterable<TestItemResource> getTestItemsByProvider(Queryable filter, Pageable pageable, ReportPortalUser.ProjectDetails projectDetails, ReportPortalUser user, Map<String, String> params) {
    DataProviderType dataProviderType = DataProviderType.findByName(params.get(PROVIDER_TYPE_PARAM)).orElseThrow(() -> new ReportPortalException(ErrorType.BAD_REQUEST_ERROR, "Test item data provider base is not specified. Allowed data provider {}", DataProviderType.values()));
    Page<TestItem> testItemPage = testItemDataProviders.get(dataProviderType).getTestItems(filter, pageable, projectDetails, user, params);
    return PagedResourcesAssembler.<TestItem, TestItemResource>pageMultiConverter(items -> {
        List<ResourceUpdater<TestItemResource>> resourceUpdaters = getResourceUpdaters(projectDetails.getProjectId(), testItemPage.getContent());
        return items.stream().map(item -> {
            TestItemResource testItemResource = TestItemConverter.TO_RESOURCE.apply(item);
            resourceUpdaters.forEach(updater -> updater.updateResource(testItemResource));
            return testItemResource;
        }).collect(toList());
    }).apply(testItemPage);
}
Also used : TestItemService(com.epam.ta.reportportal.core.item.TestItemService) Autowired(org.springframework.beans.factory.annotation.Autowired) DefaultLaunchFilterProvider(com.epam.ta.reportportal.core.item.utils.DefaultLaunchFilterProvider) CRITERIA_ID(com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_ID) Predicates(com.epam.ta.reportportal.commons.Predicates) Pair(org.apache.commons.lang3.tuple.Pair) TestItemConverter(com.epam.ta.reportportal.ws.converter.converters.TestItemConverter) 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) TicketRepository(com.epam.ta.reportportal.dao.TicketRepository) OPERATOR(com.epam.ta.reportportal.entity.project.ProjectRole.OPERATOR) ItemAttributeRepository(com.epam.ta.reportportal.dao.ItemAttributeRepository) UserFilter(com.epam.ta.reportportal.entity.filter.UserFilter) Launch(com.epam.ta.reportportal.entity.launch.Launch) Predicate(java.util.function.Predicate) BusinessRule.expect(com.epam.ta.reportportal.commons.validation.BusinessRule.expect) Filter(com.epam.ta.reportportal.commons.querygen.Filter) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) PagedResourcesAssembler(com.epam.ta.reportportal.ws.converter.PagedResourcesAssembler) ProjectRole(com.epam.ta.reportportal.entity.project.ProjectRole) Queryable(com.epam.ta.reportportal.commons.querygen.Queryable) Suppliers(com.epam.ta.reportportal.commons.validation.Suppliers) StatisticsConverter(com.epam.ta.reportportal.ws.converter.converters.StatisticsConverter) DataProviderType(com.epam.ta.reportportal.core.item.impl.provider.DataProviderType) CRITERIA_PROJECT_ID(com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_PROJECT_ID) java.util(java.util) TestItem(com.epam.ta.reportportal.entity.item.TestItem) ErrorType(com.epam.ta.reportportal.ws.model.ErrorType) GetShareableEntityHandler(com.epam.ta.reportportal.core.shareable.GetShareableEntityHandler) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) TestItemResource(com.epam.ta.reportportal.ws.model.TestItemResource) Service(org.springframework.stereotype.Service) ACCESS_DENIED(com.epam.ta.reportportal.ws.model.ErrorType.ACCESS_DENIED) Condition(com.epam.ta.reportportal.commons.querygen.Condition) UserRole(com.epam.ta.reportportal.entity.user.UserRole) Nullable(javax.annotation.Nullable) BusinessRule(com.epam.ta.reportportal.commons.validation.BusinessRule) StatisticsResource(com.epam.ta.reportportal.ws.model.statistics.StatisticsResource) LaunchModeEnum(com.epam.ta.reportportal.entity.enums.LaunchModeEnum) TestItemUpdaterContent(com.epam.ta.reportportal.ws.converter.utils.item.content.TestItemUpdaterContent) FilterCondition(com.epam.ta.reportportal.commons.querygen.FilterCondition) GetTestItemHandler(com.epam.ta.reportportal.core.item.GetTestItemHandler) Collectors.toList(java.util.stream.Collectors.toList) DataProviderHandler(com.epam.ta.reportportal.core.item.impl.provider.DataProviderHandler) ResourceUpdater(com.epam.ta.reportportal.ws.converter.utils.ResourceUpdater) ResourceUpdaterProvider(com.epam.ta.reportportal.ws.converter.utils.ResourceUpdaterProvider) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) TestItemResource(com.epam.ta.reportportal.ws.model.TestItemResource) Collectors.toList(java.util.stream.Collectors.toList) DataProviderType(com.epam.ta.reportportal.core.item.impl.provider.DataProviderType) TestItem(com.epam.ta.reportportal.entity.item.TestItem)

Aggregations

Predicates (com.epam.ta.reportportal.commons.Predicates)1 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)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 Queryable (com.epam.ta.reportportal.commons.querygen.Queryable)1 CRITERIA_ID (com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_ID)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 BusinessRule (com.epam.ta.reportportal.commons.validation.BusinessRule)1 BusinessRule.expect (com.epam.ta.reportportal.commons.validation.BusinessRule.expect)1 Suppliers (com.epam.ta.reportportal.commons.validation.Suppliers)1 GetTestItemHandler (com.epam.ta.reportportal.core.item.GetTestItemHandler)1 TestItemService (com.epam.ta.reportportal.core.item.TestItemService)1 DataProviderHandler (com.epam.ta.reportportal.core.item.impl.provider.DataProviderHandler)1 DataProviderType (com.epam.ta.reportportal.core.item.impl.provider.DataProviderType)1 DefaultLaunchFilterProvider (com.epam.ta.reportportal.core.item.utils.DefaultLaunchFilterProvider)1 GetShareableEntityHandler (com.epam.ta.reportportal.core.shareable.GetShareableEntityHandler)1 ItemAttributeRepository (com.epam.ta.reportportal.dao.ItemAttributeRepository)1 TestItemRepository (com.epam.ta.reportportal.dao.TestItemRepository)1