Search in sources :

Example 16 with Result

use of org.jooq.Result in project commons-dao by reportportal.

the class WidgetContentRepositoryTest method productStatusFilterGroupedWidgetSorting.

@Test
void productStatusFilterGroupedWidgetSorting() {
    String sortingColumn = "statistics$defects$no_defect$nd001";
    Filter filter = buildDefaultFilter(1L);
    List<Sort.Order> orders = filter.getTarget().getCriteriaHolders().stream().map(ch -> new Sort.Order(Sort.Direction.ASC, ch.getFilterCriteria())).collect(Collectors.toList());
    orders.add(new Sort.Order(Sort.Direction.DESC, sortingColumn));
    Sort sort = Sort.by(orders);
    Map<Filter, Sort> filterSortMapping = Maps.newLinkedHashMap();
    filterSortMapping.put(buildDefaultFilter(1L), sort);
    filterSortMapping.put(buildDefaultTestFilter(1L), sort);
    Map<String, String> tags = new LinkedHashMap<>();
    tags.put("firstColumn", "build");
    tags.put("secondColumn", "hello");
    Map<String, List<ProductStatusStatisticsContent>> result = widgetContentRepository.productStatusGroupedByFilterStatistics(filterSortMapping, buildProductStatusContentFields(), tags, false, 10);
    assertNotNull(result);
}
Also used : com.epam.ta.reportportal.entity.widget.content.healthcheck(com.epam.ta.reportportal.entity.widget.content.healthcheck) StatusEnum(com.epam.ta.reportportal.entity.enums.StatusEnum) CRITERIA_STATUS(com.epam.ta.reportportal.commons.querygen.constant.TestItemCriteriaConstant.CRITERIA_STATUS) DSL(org.jooq.impl.DSL) TestItem(com.epam.ta.reportportal.entity.item.TestItem) Activity(com.epam.ta.reportportal.entity.activity.Activity) Autowired(org.springframework.beans.factory.annotation.Autowired) com.epam.ta.reportportal.entity.widget.content(com.epam.ta.reportportal.entity.widget.content) CRITERIA_COMPOSITE_ATTRIBUTE(com.epam.ta.reportportal.commons.querygen.constant.ItemAttributeConstant.CRITERIA_COMPOSITE_ATTRIBUTE) CRITERIA_ACTION(com.epam.ta.reportportal.commons.querygen.constant.ActivityCriteriaConstant.CRITERIA_ACTION) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) BigDecimal(java.math.BigDecimal) Condition(com.epam.ta.reportportal.commons.querygen.Condition) Map(java.util.Map) DSLContext(org.jooq.DSLContext) Sort(org.springframework.data.domain.Sort) CRITERIA_LAUNCH_MODE(com.epam.ta.reportportal.commons.querygen.constant.LaunchCriteriaConstant.CRITERIA_LAUNCH_MODE) RoundingMode(java.math.RoundingMode) Record(org.jooq.Record) BaseTest(com.epam.ta.reportportal.BaseTest) Launch(com.epam.ta.reportportal.entity.launch.Launch) ImmutableMap(com.google.common.collect.ImmutableMap) JTestItemTypeEnum(com.epam.ta.reportportal.jooq.enums.JTestItemTypeEnum) Filter(com.epam.ta.reportportal.commons.querygen.Filter) Timestamp(java.sql.Timestamp) WidgetContentRepositoryConstants(com.epam.ta.reportportal.dao.constant.WidgetContentRepositoryConstants) GeneralCriteriaConstant(com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant) ConvertibleCondition(com.epam.ta.reportportal.commons.querygen.ConvertibleCondition) FilterCondition(com.epam.ta.reportportal.commons.querygen.FilterCondition) Result(org.jooq.Result) Maps(com.google.common.collect.Maps) Sql(org.springframework.test.context.jdbc.Sql) Collectors(java.util.stream.Collectors) CRITERIA_CREATION_DATE(com.epam.ta.reportportal.commons.querygen.constant.ActivityCriteriaConstant.CRITERIA_CREATION_DATE) Test(org.junit.jupiter.api.Test) List(java.util.List) CRITERIA_USER(com.epam.ta.reportportal.commons.querygen.constant.UserCriteriaConstant.CRITERIA_USER) Lists(org.assertj.core.util.Lists) Assertions(org.junit.jupiter.api.Assertions) JStatusEnum(com.epam.ta.reportportal.jooq.enums.JStatusEnum) CRITERIA_ITEM_ATTRIBUTE_KEY(com.epam.ta.reportportal.commons.querygen.constant.ItemAttributeConstant.CRITERIA_ITEM_ATTRIBUTE_KEY) Mode(com.epam.ta.reportportal.ws.model.launch.Mode) ActivityResource(com.epam.ta.reportportal.ws.model.ActivityResource) Filter(com.epam.ta.reportportal.commons.querygen.Filter) Sort(org.springframework.data.domain.Sort) ArrayList(java.util.ArrayList) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Example 17 with Result

use of org.jooq.Result in project commons-dao by reportportal.

the class WidgetContentRepositoryTest method productStatusLaunchGroupedWidgetSorting.

@Test
void productStatusLaunchGroupedWidgetSorting() {
    String sortingColumn = "statistics$defects$no_defect$nd001";
    Filter filter = buildDefaultTestFilter(1L);
    List<Sort.Order> orders = filter.getTarget().getCriteriaHolders().stream().map(ch -> new Sort.Order(Sort.Direction.ASC, ch.getFilterCriteria())).collect(Collectors.toList());
    orders.add(new Sort.Order(Sort.Direction.DESC, sortingColumn));
    Sort sort = Sort.by(orders);
    Map<String, String> tags = new LinkedHashMap<>();
    tags.put("firstColumn", "build");
    tags.put("secondColumn", "hello");
    List<ProductStatusStatisticsContent> result = widgetContentRepository.productStatusGroupedByLaunchesStatistics(filter, buildProductStatusContentFields(), tags, sort, false, 10);
    assertNotNull(result);
}
Also used : com.epam.ta.reportportal.entity.widget.content.healthcheck(com.epam.ta.reportportal.entity.widget.content.healthcheck) StatusEnum(com.epam.ta.reportportal.entity.enums.StatusEnum) CRITERIA_STATUS(com.epam.ta.reportportal.commons.querygen.constant.TestItemCriteriaConstant.CRITERIA_STATUS) DSL(org.jooq.impl.DSL) TestItem(com.epam.ta.reportportal.entity.item.TestItem) Activity(com.epam.ta.reportportal.entity.activity.Activity) Autowired(org.springframework.beans.factory.annotation.Autowired) com.epam.ta.reportportal.entity.widget.content(com.epam.ta.reportportal.entity.widget.content) CRITERIA_COMPOSITE_ATTRIBUTE(com.epam.ta.reportportal.commons.querygen.constant.ItemAttributeConstant.CRITERIA_COMPOSITE_ATTRIBUTE) CRITERIA_ACTION(com.epam.ta.reportportal.commons.querygen.constant.ActivityCriteriaConstant.CRITERIA_ACTION) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) BigDecimal(java.math.BigDecimal) Condition(com.epam.ta.reportportal.commons.querygen.Condition) Map(java.util.Map) DSLContext(org.jooq.DSLContext) Sort(org.springframework.data.domain.Sort) CRITERIA_LAUNCH_MODE(com.epam.ta.reportportal.commons.querygen.constant.LaunchCriteriaConstant.CRITERIA_LAUNCH_MODE) RoundingMode(java.math.RoundingMode) Record(org.jooq.Record) BaseTest(com.epam.ta.reportportal.BaseTest) Launch(com.epam.ta.reportportal.entity.launch.Launch) ImmutableMap(com.google.common.collect.ImmutableMap) JTestItemTypeEnum(com.epam.ta.reportportal.jooq.enums.JTestItemTypeEnum) Filter(com.epam.ta.reportportal.commons.querygen.Filter) Timestamp(java.sql.Timestamp) WidgetContentRepositoryConstants(com.epam.ta.reportportal.dao.constant.WidgetContentRepositoryConstants) GeneralCriteriaConstant(com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant) ConvertibleCondition(com.epam.ta.reportportal.commons.querygen.ConvertibleCondition) FilterCondition(com.epam.ta.reportportal.commons.querygen.FilterCondition) Result(org.jooq.Result) Maps(com.google.common.collect.Maps) Sql(org.springframework.test.context.jdbc.Sql) Collectors(java.util.stream.Collectors) CRITERIA_CREATION_DATE(com.epam.ta.reportportal.commons.querygen.constant.ActivityCriteriaConstant.CRITERIA_CREATION_DATE) Test(org.junit.jupiter.api.Test) List(java.util.List) CRITERIA_USER(com.epam.ta.reportportal.commons.querygen.constant.UserCriteriaConstant.CRITERIA_USER) Lists(org.assertj.core.util.Lists) Assertions(org.junit.jupiter.api.Assertions) JStatusEnum(com.epam.ta.reportportal.jooq.enums.JStatusEnum) CRITERIA_ITEM_ATTRIBUTE_KEY(com.epam.ta.reportportal.commons.querygen.constant.ItemAttributeConstant.CRITERIA_ITEM_ATTRIBUTE_KEY) Mode(com.epam.ta.reportportal.ws.model.launch.Mode) ActivityResource(com.epam.ta.reportportal.ws.model.ActivityResource) Filter(com.epam.ta.reportportal.commons.querygen.Filter) Sort(org.springframework.data.domain.Sort) LinkedHashMap(java.util.LinkedHashMap) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Example 18 with Result

use of org.jooq.Result in project jOOQ by jOOQ.

the class AbstractResultQuery method fetchLater.

@Override
@Deprecated
public final org.jooq.FutureResult<R> fetchLater() {
    ExecutorService executor = newSingleThreadExecutor();
    Future<Result<R>> future = executor.submit(new ResultQueryCallable());
    return new FutureResultImpl<R>(future, executor);
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) Result(org.jooq.Result)

Example 19 with Result

use of org.jooq.Result in project Skree by Skelril.

the class HighScoreDatabaseUtil method getTop.

public static List<Clause<Optional<GameProfile>, Integer>> getTop(ScoreType scoreType, int count) {
    try (Connection con = SQLHandle.getConnection()) {
        DSLContext create = DSL.using(con);
        Result<Record2<String, Integer>> results = create.select(PLAYERS.UUID, HIGH_SCORES.VALUE).from(HIGH_SCORES).join(PLAYERS).on(PLAYERS.ID.equal(HIGH_SCORES.PLAYER_ID)).where(HIGH_SCORES.SCORE_TYPE_ID.equal(scoreType.getId())).orderBy(scoreType.getOrder() == ScoreType.Order.ASC ? HIGH_SCORES.VALUE.asc() : HIGH_SCORES.VALUE.desc()).limit(count).fetch();
        return results.stream().map(record -> new Clause<>(getProfile(record.getValue(PLAYERS.UUID)), record.getValue(HIGH_SCORES.VALUE))).collect(Collectors.toList());
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return Lists.newArrayList();
}
Also used : DSL(org.jooq.impl.DSL) Connection(java.sql.Connection) Sponge(org.spongepowered.api.Sponge) PLAYERS(com.skelril.skree.db.schema.Tables.PLAYERS) UUID(java.util.UUID) Result(org.jooq.Result) Collectors(java.util.stream.Collectors) HIGH_SCORES(com.skelril.skree.db.schema.tables.HighScores.HIGH_SCORES) SQLHandle(com.skelril.skree.db.SQLHandle) ExecutionException(java.util.concurrent.ExecutionException) Record2(org.jooq.Record2) SQLException(java.sql.SQLException) List(java.util.List) Lists(com.google.common.collect.Lists) Record1(org.jooq.Record1) DSLContext(org.jooq.DSLContext) Optional(java.util.Optional) GameProfile(org.spongepowered.api.profile.GameProfile) Clause(com.skelril.nitro.Clause) SQLException(java.sql.SQLException) Connection(java.sql.Connection) DSLContext(org.jooq.DSLContext) Clause(com.skelril.nitro.Clause) Record2(org.jooq.Record2)

Example 20 with Result

use of org.jooq.Result in project jOOQ by jOOQ.

the class MySQLDatabase method getRoutines0.

@Override
protected List<RoutineDefinition> getRoutines0() throws SQLException {
    List<RoutineDefinition> result = new ArrayList<>();
    Result<Record6<String, String, String, byte[], byte[], ProcType>> records = is8() ? create().select(ROUTINES.ROUTINE_SCHEMA, ROUTINES.ROUTINE_NAME, ROUTINES.ROUTINE_COMMENT, inline(new byte[0]).as(PROC.PARAM_LIST), inline(new byte[0]).as(PROC.RETURNS), ROUTINES.ROUTINE_TYPE.coerce(PROC.TYPE).as(ROUTINES.ROUTINE_TYPE)).from(ROUTINES).where(ROUTINES.ROUTINE_SCHEMA.in(getInputSchemata())).orderBy(1, 2, 6).fetch() : create().select(PROC.DB.as(ROUTINES.ROUTINE_SCHEMA), PROC.NAME.as(ROUTINES.ROUTINE_NAME), PROC.COMMENT.as(ROUTINES.ROUTINE_COMMENT), PROC.PARAM_LIST, PROC.RETURNS, PROC.TYPE.as(ROUTINES.ROUTINE_TYPE)).from(PROC).where(PROC.DB.in(getInputSchemata())).orderBy(1, 2, 6).fetch();
    Map<Record, Result<Record6<String, String, String, byte[], byte[], ProcType>>> groups = records.intoGroups(new Field[] { ROUTINES.ROUTINE_SCHEMA, ROUTINES.ROUTINE_NAME });
    // [#1908] This indirection is necessary as MySQL allows for overloading
    // procedures and functions with the same signature.
    groups.forEach((k, overloads) -> {
        overloads.forEach(record -> {
            SchemaDefinition schema = getSchema(record.get(ROUTINES.ROUTINE_SCHEMA));
            String name = record.get(ROUTINES.ROUTINE_NAME);
            String comment = record.get(ROUTINES.ROUTINE_COMMENT);
            String params = is8() ? "" : new String(record.get(PROC.PARAM_LIST));
            String returns = is8() ? "" : new String(record.get(PROC.RETURNS));
            ProcType type = record.get(ROUTINES.ROUTINE_TYPE.coerce(PROC.TYPE).as(ROUTINES.ROUTINE_TYPE));
            if (overloads.size() > 1)
                result.add(new MySQLRoutineDefinition(schema, name, comment, params, returns, type, "_" + type.name()));
            else
                result.add(new MySQLRoutineDefinition(schema, name, comment, params, returns, type, null));
        });
    });
    return result;
}
Also used : RoutineDefinition(org.jooq.meta.RoutineDefinition) SchemaDefinition(org.jooq.meta.SchemaDefinition) ArrayList(java.util.ArrayList) ProcType(org.jooq.meta.mysql.mysql.enums.ProcType) Record6(org.jooq.Record6) Record(org.jooq.Record) Result(org.jooq.Result)

Aggregations

Result (org.jooq.Result)31 Record (org.jooq.Record)24 ArrayList (java.util.ArrayList)23 List (java.util.List)22 Collectors (java.util.stream.Collectors)17 DSLContext (org.jooq.DSLContext)17 BigDecimal (java.math.BigDecimal)13 SQLException (java.sql.SQLException)13 Map (java.util.Map)13 Timestamp (java.sql.Timestamp)12 Optional (java.util.Optional)12 Stream (java.util.stream.Stream)12 Lists (com.google.common.collect.Lists)11 HashMap (java.util.HashMap)11 UUID (java.util.UUID)11 IOException (java.io.IOException)10 Iterator (java.util.Iterator)10 Singleton (javax.inject.Singleton)10 Almura (com.almuradev.almura.Almura)9 ServerNotificationManager (com.almuradev.almura.feature.notification.ServerNotificationManager)9