Search in sources :

Example 1 with QueryBuilder

use of com.epam.ta.reportportal.commons.querygen.QueryBuilder in project commons-dao by reportportal.

the class QueryUtils method createQueryBuilderWithLatestLaunchesOption.

public static QueryBuilder createQueryBuilderWithLatestLaunchesOption(Queryable filter, Sort sort, boolean isLatest) {
    Set<String> joinFields = collectJoinFields(filter, sort);
    QueryBuilder queryBuilder = QueryBuilder.newBuilder(filter, joinFields);
    if (isLatest) {
        queryBuilder.with(LAUNCH.NUMBER, SortOrder.DESC).addCondition(LAUNCH.ID.in(DSL.with(LAUNCHES).as(QueryBuilder.newBuilder(filter, joinFields).build()).selectDistinct(LAUNCH.ID).on(LAUNCH.NAME).from(LAUNCH).join(LAUNCHES).on(field(name(LAUNCHES, ID), Long.class).eq(LAUNCH.ID)).orderBy(LAUNCH.NAME, LAUNCH.NUMBER.desc())));
    }
    return queryBuilder;
}
Also used : QueryBuilder(com.epam.ta.reportportal.commons.querygen.QueryBuilder)

Example 2 with QueryBuilder

use of com.epam.ta.reportportal.commons.querygen.QueryBuilder in project commons-dao by reportportal.

the class LogRepositoryCustomImpl method buildNestedLogQuery.

private SelectOnConditionStep<Record3<Long, Timestamp, String>> buildNestedLogQuery(Long parentId, Queryable filter) {
    Queryable logFilter = filter.getFilterConditions().stream().flatMap(condition -> condition.getAllConditions().stream()).filter(condition -> CRITERIA_STATUS.equalsIgnoreCase(condition.getSearchCriteria())).findAny().map(condition -> (Queryable) new Filter(filter.getTarget().getClazz(), filter.getFilterConditions().stream().flatMap(simpleCondition -> simpleCondition.getAllConditions().stream()).filter(filterCondition -> !condition.getSearchCriteria().equalsIgnoreCase(filterCondition.getSearchCriteria())).collect(toList()))).orElse(filter);
    QueryBuilder queryBuilder = QueryBuilder.newBuilder(logFilter, QueryUtils.collectJoinFields(logFilter));
    return dsl.with(LOGS).as(queryBuilder.addCondition(LOG.ITEM_ID.eq(parentId)).build()).select(LOG.ID.as(ID), LOG.LOG_TIME.as(TIME), DSL.val(LogRepositoryConstants.LOG).as(TYPE)).from(LOG).join(LOGS).on(fieldName(LOGS, ID).cast(Long.class).eq(LOG.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) Filter(com.epam.ta.reportportal.commons.querygen.Filter) Queryable(com.epam.ta.reportportal.commons.querygen.Queryable) QueryBuilder(com.epam.ta.reportportal.commons.querygen.QueryBuilder)

Aggregations

QueryBuilder (com.epam.ta.reportportal.commons.querygen.QueryBuilder)2 Filter (com.epam.ta.reportportal.commons.querygen.Filter)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