Skip to content

Commit 634e826

Browse files
authored
1705 - sort the default catalog view firstly based on status in the following sequence:STABLE, DEPRECIATED,DRAFT,UNASSIGNED,DELETED (#1707)
1 parent 545306e commit 634e826

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveDataEntityRepositoryImpl.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,14 +699,25 @@ public Mono<List<DataEntityDimensionsDto>> findByState(final FacetStateDto state
699699
.leftJoin(GROUP_ENTITY_RELATIONS)
700700
.on(GROUP_ENTITY_RELATIONS.DATA_ENTITY_ODDRN.eq(jooqQueryHelper.getField(deCte, DATA_ENTITY.ODDRN)));
701701

702+
final List<OrderField<?>> orderFields = new ArrayList<>();
703+
704+
orderFields.add(DSL.case_(deCte.field(DATA_ENTITY.STATUS))
705+
.when(DataEntityStatusDto.STABLE.getId(), 1)
706+
.when(DataEntityStatusDto.DEPRECATED.getId(), 2)
707+
.when(DataEntityStatusDto.DRAFT.getId(), 3)
708+
.when(DataEntityStatusDto.UNASSIGNED.getId(), 4)
709+
.when(DataEntityStatusDto.DELETED.getId(), 5));
710+
711+
orderFields.addAll(getOrderFields(cteConfig, deCte));
712+
702713
final var query = DSL.with(deCteName)
703714
.asMaterialized(dataEntitySelect)
704715
.select(groupByFields)
705716
.select(aggregatedFields)
706717
.from(fromTable)
707718
.where(conditions)
708719
.groupBy(groupByFields)
709-
.orderBy(getOrderFields(cteConfig, deCte))
720+
.orderBy(orderFields)
710721
.limit(DSL.val(size))
711722
.offset(DSL.val((page - 1) * size));
712723

0 commit comments

Comments
 (0)