Skip to content

Commit

Permalink
1705 - sort the default catalog view firstly based on status in the f…
Browse files Browse the repository at this point in the history
…ollowing sequence:STABLE, DEPRECIATED,DRAFT,UNASSIGNED,DELETED (#1707)
  • Loading branch information
Vladysl authored Sep 19, 2024
1 parent 545306e commit 634e826
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -699,14 +699,25 @@ public Mono<List<DataEntityDimensionsDto>> findByState(final FacetStateDto state
.leftJoin(GROUP_ENTITY_RELATIONS)
.on(GROUP_ENTITY_RELATIONS.DATA_ENTITY_ODDRN.eq(jooqQueryHelper.getField(deCte, DATA_ENTITY.ODDRN)));

final List<OrderField<?>> orderFields = new ArrayList<>();

orderFields.add(DSL.case_(deCte.field(DATA_ENTITY.STATUS))
.when(DataEntityStatusDto.STABLE.getId(), 1)
.when(DataEntityStatusDto.DEPRECATED.getId(), 2)
.when(DataEntityStatusDto.DRAFT.getId(), 3)
.when(DataEntityStatusDto.UNASSIGNED.getId(), 4)
.when(DataEntityStatusDto.DELETED.getId(), 5));

orderFields.addAll(getOrderFields(cteConfig, deCte));

final var query = DSL.with(deCteName)
.asMaterialized(dataEntitySelect)
.select(groupByFields)
.select(aggregatedFields)
.from(fromTable)
.where(conditions)
.groupBy(groupByFields)
.orderBy(getOrderFields(cteConfig, deCte))
.orderBy(orderFields)
.limit(DSL.val(size))
.offset(DSL.val((page - 1) * size));

Expand Down

0 comments on commit 634e826

Please sign in to comment.