use of com.epam.ta.reportportal.jooq.tables.JTestItem in project commons-dao by reportportal.
the class LogRepositoryCustomImpl method buildLogsUnderItemsQuery.
private SelectConditionStep<? extends Record> buildLogsUnderItemsQuery(Long launchId, List<Long> itemIds, boolean includeAttachments) {
JTestItem parentItemTable = TEST_ITEM.as(PARENT_ITEM_TABLE);
JTestItem childItemTable = TEST_ITEM.as(CHILD_ITEM_TABLE);
List<Field<?>> selectFields = Lists.newArrayList(LOG.ID, LOG.LOG_LEVEL, LOG.LOG_MESSAGE, LOG.LOG_TIME, parentItemTable.ITEM_ID.as(ROOT_ITEM_ID), LOG.LAUNCH_ID, LOG.LAST_MODIFIED, LOG.CLUSTER_ID);
if (includeAttachments) {
Collections.addAll(selectFields, ATTACHMENT.fields());
}
SelectOnConditionStep<Record> logsSelect = dsl.selectDistinct(selectFields).on(LOG.ID, LOG.LOG_TIME).from(LOG).join(childItemTable).on(LOG.ITEM_ID.eq(childItemTable.ITEM_ID)).join(parentItemTable).on(DSL.sql(childItemTable.PATH + " <@ " + parentItemTable.PATH));
if (includeAttachments) {
logsSelect = logsSelect.leftJoin(ATTACHMENT).on(LOG.ATTACHMENT_ID.eq(ATTACHMENT.ID));
}
return logsSelect.where(childItemTable.LAUNCH_ID.eq(launchId)).and(parentItemTable.LAUNCH_ID.eq(launchId)).and(parentItemTable.ITEM_ID.in(itemIds));
}
use of com.epam.ta.reportportal.jooq.tables.JTestItem in project commons-dao by reportportal.
the class LogRepositoryCustomImpl method findIdsUnderTestItemByLaunchIdAndTestItemIdsAndLogLevelGte.
@Override
public List<Long> findIdsUnderTestItemByLaunchIdAndTestItemIdsAndLogLevelGte(Long launchId, List<Long> itemIds, int logLevel) {
JTestItem parentItemTable = TEST_ITEM.as(PARENT_ITEM_TABLE);
JTestItem childItemTable = TEST_ITEM.as(CHILD_ITEM_TABLE);
return dsl.selectDistinct(LOG.ID).from(LOG).join(childItemTable).on(LOG.ITEM_ID.eq(childItemTable.ITEM_ID)).join(parentItemTable).on(DSL.sql(childItemTable.PATH + " <@ " + parentItemTable.PATH)).where(childItemTable.LAUNCH_ID.eq(launchId)).and(parentItemTable.LAUNCH_ID.eq(launchId)).and(parentItemTable.ITEM_ID.in(itemIds)).and(LOG.LOG_LEVEL.greaterOrEqual(logLevel)).fetchInto(Long.class);
}
use of com.epam.ta.reportportal.jooq.tables.JTestItem in project commons-dao by reportportal.
the class TestItemRepositoryCustomImpl method findAllNestedStepsByIds.
@Override
public List<NestedStep> findAllNestedStepsByIds(Collection<Long> ids, Queryable logFilter, boolean excludePassedLogs) {
JTestItem nested = TEST_ITEM.as(NESTED);
SelectQuery<? extends Record> logsSelectQuery = QueryBuilder.newBuilder(logFilter, QueryUtils.collectJoinFields(logFilter)).build();
return dsl.select(TEST_ITEM.ITEM_ID, TEST_ITEM.NAME, TEST_ITEM.UUID, TEST_ITEM.START_TIME, TEST_ITEM.TYPE, TEST_ITEM_RESULTS.STATUS, TEST_ITEM_RESULTS.END_TIME, TEST_ITEM_RESULTS.DURATION, DSL.field(hasContentQuery(nested, logsSelectQuery, excludePassedLogs)).as(HAS_CONTENT), DSL.field(dsl.with(LOGS).as(logsSelectQuery).selectCount().from(LOG).join(nested).on(LOG.ITEM_ID.eq(nested.ITEM_ID)).join(LOGS).on(LOG.ID.eq(fieldName(LOGS, ID).cast(Long.class))).join(ATTACHMENT).on(LOG.ATTACHMENT_ID.eq(ATTACHMENT.ID)).where(nested.HAS_STATS.isFalse().and(DSL.sql(fieldName(NESTED, TEST_ITEM.PATH.getName()) + " <@ cast(? AS LTREE)", TEST_ITEM.PATH)))).as(ATTACHMENTS_COUNT)).from(TEST_ITEM).join(TEST_ITEM_RESULTS).on(TEST_ITEM.ITEM_ID.eq(TEST_ITEM_RESULTS.RESULT_ID)).where(TEST_ITEM.ITEM_ID.in(ids)).fetch(NESTED_STEP_RECORD_MAPPER);
}
use of com.epam.ta.reportportal.jooq.tables.JTestItem in project commons-dao by reportportal.
the class LogRepositoryCustomImpl method findAllIndexUnderTestItemByLaunchIdAndTestItemIdsAndLogLevelGte.
@Override
public Map<Long, List<IndexLog>> findAllIndexUnderTestItemByLaunchIdAndTestItemIdsAndLogLevelGte(Long launchId, List<Long> itemIds, int logLevel) {
JTestItem parentItemTable = TEST_ITEM.as(PARENT_ITEM_TABLE);
JTestItem childItemTable = TEST_ITEM.as(CHILD_ITEM_TABLE);
return INDEX_LOG_FETCHER.apply(dsl.selectDistinct(LOG.ID, LOG.LOG_LEVEL, LOG.LOG_MESSAGE, parentItemTable.ITEM_ID.as(ROOT_ITEM_ID), CLUSTERS.INDEX_ID).on(LOG.ID).from(LOG).join(childItemTable).on(LOG.ITEM_ID.eq(childItemTable.ITEM_ID)).join(parentItemTable).on(DSL.sql(childItemTable.PATH + " <@ " + parentItemTable.PATH)).leftJoin(CLUSTERS).on(LOG.CLUSTER_ID.eq(CLUSTERS.ID)).where(childItemTable.LAUNCH_ID.eq(launchId)).and(parentItemTable.LAUNCH_ID.eq(launchId)).and(parentItemTable.ITEM_ID.in(itemIds)).and(LOG.LOG_LEVEL.greaterOrEqual(logLevel)).fetch());
}
use of com.epam.ta.reportportal.jooq.tables.JTestItem 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);
}
Aggregations