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;
}
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));
}
Aggregations