Search in sources :

Example 1 with TEST_ITEM_RESULTS

use of com.epam.ta.reportportal.jooq.tables.JTestItemResults.TEST_ITEM_RESULTS in project commons-dao by reportportal.

the class LogRepositoryCustomImpl method buildNestedStepQuery.

private SelectHavingStep<Record3<Long, Timestamp, String>> buildNestedStepQuery(Long parentId, boolean excludeEmptySteps, Queryable filter) {
    SelectConditionStep<Record3<Long, Timestamp, String>> nestedStepSelect = dsl.select(TEST_ITEM.ITEM_ID.as(ID), TEST_ITEM.START_TIME.as(TIME), DSL.val(ITEM).as(TYPE)).from(TEST_ITEM).join(TEST_ITEM_RESULTS).on(TEST_ITEM.ITEM_ID.eq(TEST_ITEM_RESULTS.RESULT_ID)).where(TEST_ITEM.PARENT_ID.eq(parentId)).and(TEST_ITEM.HAS_STATS.isFalse());
    filter.getFilterConditions().stream().flatMap(condition -> condition.getAllConditions().stream()).filter(c -> CRITERIA_STATUS.equals(c.getSearchCriteria())).findFirst().map(c -> Stream.of(c.getValue().split(",")).filter(StatusEnum::isPresent).map(JStatusEnum::valueOf).collect(toList())).map(TEST_ITEM_RESULTS.STATUS::in).ifPresent(nestedStepSelect::and);
    if (excludeEmptySteps) {
        JTestItem nested = TEST_ITEM.as(NESTED);
        nestedStepSelect.and(field(DSL.exists(dsl.with(LOGS).as(QueryBuilder.newBuilder(filter, QueryUtils.collectJoinFields(filter)).addCondition(LOG.ITEM_ID.eq(parentId)).build()).select().from(LOG).join(LOGS).on(LOG.ID.eq(field(LOGS, ID).cast(Long.class))).where(LOG.ITEM_ID.eq(TEST_ITEM.ITEM_ID))).orExists(dsl.select().from(nested).where(nested.PARENT_ID.eq(TEST_ITEM.ITEM_ID)))));
    }
    return nestedStepSelect.groupBy(TEST_ITEM.ITEM_ID);
}
Also used : TimestampUtils(com.epam.ta.reportportal.dao.util.TimestampUtils) StatusEnum(com.epam.ta.reportportal.entity.enums.StatusEnum) CRITERIA_STATUS(com.epam.ta.reportportal.commons.querygen.constant.TestItemCriteriaConstant.CRITERIA_STATUS) java.util(java.util) DSL(org.jooq.impl.DSL) RecordMappers(com.epam.ta.reportportal.dao.util.RecordMappers) QueryBuilder(com.epam.ta.reportportal.commons.querygen.QueryBuilder) LOG(com.epam.ta.reportportal.jooq.Tables.LOG) DSL.field(org.jooq.impl.DSL.field) Autowired(org.springframework.beans.factory.annotation.Autowired) ErrorType(com.epam.ta.reportportal.ws.model.ErrorType) JTestItem(com.epam.ta.reportportal.jooq.tables.JTestItem) NESTED_ITEM_FETCHER(com.epam.ta.reportportal.dao.util.ResultFetchers.NESTED_ITEM_FETCHER) BigDecimal(java.math.BigDecimal) Lists(com.google.common.collect.Lists) LAUNCH(com.epam.ta.reportportal.jooq.Tables.LAUNCH) QueryUtils(com.epam.ta.reportportal.dao.util.QueryUtils) Log(com.epam.ta.reportportal.entity.log.Log) org.jooq(org.jooq) Duration(java.time.Duration) JooqFieldNameTransformer.fieldName(com.epam.ta.reportportal.dao.util.JooqFieldNameTransformer.fieldName) Pageable(org.springframework.data.domain.Pageable) Sort(org.springframework.data.domain.Sort) Repository(org.springframework.stereotype.Repository) RoundingMode(java.math.RoundingMode) ATTACHMENT(com.epam.ta.reportportal.jooq.tables.JAttachment.ATTACHMENT) TEST_ITEM_RESULTS(com.epam.ta.reportportal.jooq.tables.JTestItemResults.TEST_ITEM_RESULTS) NestedItem(com.epam.ta.reportportal.entity.item.NestedItem) CLUSTERS(com.epam.ta.reportportal.jooq.Tables.CLUSTERS) Optional.ofNullable(java.util.Optional.ofNullable) Filter(com.epam.ta.reportportal.commons.querygen.Filter) Timestamp(java.sql.Timestamp) LogRepositoryConstants(com.epam.ta.reportportal.dao.constant.LogRepositoryConstants) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) PageableExecutionUtils(org.springframework.data.repository.support.PageableExecutionUtils) Page(org.springframework.data.domain.Page) ID(com.epam.ta.reportportal.dao.constant.WidgetRepositoryConstants.ID) Collectors.toList(java.util.stream.Collectors.toList) Stream(java.util.stream.Stream) TEST_ITEM(com.epam.ta.reportportal.jooq.tables.JTestItem.TEST_ITEM) Queryable(com.epam.ta.reportportal.commons.querygen.Queryable) NESTED(com.epam.ta.reportportal.dao.constant.TestItemRepositoryConstants.NESTED) JStatusEnum(com.epam.ta.reportportal.jooq.enums.JStatusEnum) CRITERIA_LOG_TIME(com.epam.ta.reportportal.commons.querygen.constant.LogCriteriaConstant.CRITERIA_LOG_TIME) IndexLog(com.epam.ta.reportportal.ws.model.analyzer.IndexLog) LOG_FETCHER(com.epam.ta.reportportal.dao.util.ResultFetchers.LOG_FETCHER) JStatusEnum(com.epam.ta.reportportal.jooq.enums.JStatusEnum) TEST_ITEM_RESULTS(com.epam.ta.reportportal.jooq.tables.JTestItemResults.TEST_ITEM_RESULTS) JTestItem(com.epam.ta.reportportal.jooq.tables.JTestItem)

Aggregations

Filter (com.epam.ta.reportportal.commons.querygen.Filter)1 QueryBuilder (com.epam.ta.reportportal.commons.querygen.QueryBuilder)1 Queryable (com.epam.ta.reportportal.commons.querygen.Queryable)1 CRITERIA_LOG_TIME (com.epam.ta.reportportal.commons.querygen.constant.LogCriteriaConstant.CRITERIA_LOG_TIME)1 CRITERIA_STATUS (com.epam.ta.reportportal.commons.querygen.constant.TestItemCriteriaConstant.CRITERIA_STATUS)1 LogRepositoryConstants (com.epam.ta.reportportal.dao.constant.LogRepositoryConstants)1 NESTED (com.epam.ta.reportportal.dao.constant.TestItemRepositoryConstants.NESTED)1 ID (com.epam.ta.reportportal.dao.constant.WidgetRepositoryConstants.ID)1 JooqFieldNameTransformer.fieldName (com.epam.ta.reportportal.dao.util.JooqFieldNameTransformer.fieldName)1 QueryUtils (com.epam.ta.reportportal.dao.util.QueryUtils)1 RecordMappers (com.epam.ta.reportportal.dao.util.RecordMappers)1 LOG_FETCHER (com.epam.ta.reportportal.dao.util.ResultFetchers.LOG_FETCHER)1 NESTED_ITEM_FETCHER (com.epam.ta.reportportal.dao.util.ResultFetchers.NESTED_ITEM_FETCHER)1 TimestampUtils (com.epam.ta.reportportal.dao.util.TimestampUtils)1 StatusEnum (com.epam.ta.reportportal.entity.enums.StatusEnum)1 NestedItem (com.epam.ta.reportportal.entity.item.NestedItem)1 Log (com.epam.ta.reportportal.entity.log.Log)1 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)1 CLUSTERS (com.epam.ta.reportportal.jooq.Tables.CLUSTERS)1 LAUNCH (com.epam.ta.reportportal.jooq.Tables.LAUNCH)1