diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/controller/TermController.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/controller/TermController.java index fd203b49d..2a0b7eba0 100644 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/controller/TermController.java +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/controller/TermController.java @@ -5,6 +5,7 @@ import org.opendatadiscovery.oddplatform.api.contract.api.TermApi; import org.opendatadiscovery.oddplatform.api.contract.model.CountableSearchFilter; import org.opendatadiscovery.oddplatform.api.contract.model.DataEntityList; +import org.opendatadiscovery.oddplatform.api.contract.model.DatasetFieldList; import org.opendatadiscovery.oddplatform.api.contract.model.MultipleFacetType; import org.opendatadiscovery.oddplatform.api.contract.model.Ownership; import org.opendatadiscovery.oddplatform.api.contract.model.OwnershipFormData; @@ -19,6 +20,7 @@ import org.opendatadiscovery.oddplatform.api.contract.model.TermSearchFacetsData; import org.opendatadiscovery.oddplatform.api.contract.model.TermSearchFormData; import org.opendatadiscovery.oddplatform.service.DataEntityService; +import org.opendatadiscovery.oddplatform.service.DatasetFieldService; import org.opendatadiscovery.oddplatform.service.term.TermOwnershipService; import org.opendatadiscovery.oddplatform.service.term.TermSearchService; import org.opendatadiscovery.oddplatform.service.term.TermService; @@ -34,6 +36,7 @@ public class TermController implements TermApi { private final TermService termService; private final DataEntityService dataEntityService; + private final DatasetFieldService datasetFieldService; private final TermSearchService termSearchService; private final TermOwnershipService termOwnershipService; @@ -94,6 +97,16 @@ public Mono> getTermLinkedEntities(final Long ter .map(ResponseEntity::ok); } + @Override + public Mono> getTermLinkedColumns(final Long termId, final Integer page, + final Integer size, + final String query, + final ServerWebExchange exchange) { + return datasetFieldService + .listByTerm(termId, query, page, size) + .map(ResponseEntity::ok); + } + @Override public Mono>> createTermTagsRelations(final Long termId, final Mono tagsFormData, diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/dto/DatasetFieldTermsDto.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/dto/DatasetFieldTermsDto.java new file mode 100644 index 000000000..71bca49b6 --- /dev/null +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/dto/DatasetFieldTermsDto.java @@ -0,0 +1,34 @@ +package org.opendatadiscovery.oddplatform.dto; + +import java.util.List; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import org.jooq.JSONB; +import org.opendatadiscovery.oddplatform.model.tables.pojos.DataSourcePojo; +import org.opendatadiscovery.oddplatform.model.tables.pojos.NamespacePojo; + +@EqualsAndHashCode +@ToString +@Data +@Builder +public class DatasetFieldTermsDto { + private Long id; + private String name; + private String internalName; + private String oddrn; + private JSONB type; + private Boolean isKey; + private Boolean isValue; + private String externalDescription; + private String internalDescription; + private Boolean isPrimaryKey; + private Boolean isSortKey; + private String defaultValue; + private List ownership; + private DataSourcePojo dataSource; + private String dataEntityName; + private Long dataEntityId; + private NamespacePojo namespace; +} diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/DatasetFieldListMapper.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/DatasetFieldListMapper.java new file mode 100644 index 000000000..2e03dfb95 --- /dev/null +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/DatasetFieldListMapper.java @@ -0,0 +1,9 @@ +package org.opendatadiscovery.oddplatform.mapper; + +import java.util.List; +import org.opendatadiscovery.oddplatform.api.contract.model.DatasetFieldList; +import org.opendatadiscovery.oddplatform.dto.DatasetFieldTermsDto; + +public interface DatasetFieldListMapper { + DatasetFieldList mapPojos(List item); +} diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/DatasetFieldListMapperImpl.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/DatasetFieldListMapperImpl.java new file mode 100644 index 000000000..e9251e3bb --- /dev/null +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/DatasetFieldListMapperImpl.java @@ -0,0 +1,50 @@ +package org.opendatadiscovery.oddplatform.mapper; + +import java.util.List; +import lombok.RequiredArgsConstructor; +import org.opendatadiscovery.oddplatform.api.contract.model.DataSetFieldType; +import org.opendatadiscovery.oddplatform.api.contract.model.DatasetFieldList; +import org.opendatadiscovery.oddplatform.api.contract.model.PageInfo; +import org.opendatadiscovery.oddplatform.api.contract.model.TermSearchDataSetField; +import org.opendatadiscovery.oddplatform.dto.DataSourceDto; +import org.opendatadiscovery.oddplatform.dto.DatasetFieldTermsDto; +import org.opendatadiscovery.oddplatform.utils.JSONSerDeUtils; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +public class DatasetFieldListMapperImpl implements DatasetFieldListMapper { + private final DataSourceMapper dataSourceMapper; + private final OwnershipMapper ownershipMapper; + + @Override + public DatasetFieldList mapPojos(final List dataFieldsDto) { + final List entities = dataFieldsDto.stream().map(this::mapPojo).toList(); + final PageInfo pageInfo = pageInfo(dataFieldsDto.size()); + return new DatasetFieldList(entities, pageInfo); + } + + private TermSearchDataSetField mapPojo(final DatasetFieldTermsDto dto) { + return new TermSearchDataSetField() + .id(dto.getId()) + .internalName(dto.getInternalName()) + .name(dto.getName()) + .oddrn(dto.getOddrn()) + .defaultValue(dto.getDefaultValue()) + .externalDescription(dto.getExternalDescription()) + .internalDescription(dto.getInternalDescription()) + .isKey(dto.getIsKey()) + .isPrimaryKey(dto.getIsPrimaryKey()) + .isSortKey(dto.getIsSortKey()) + .isValue(dto.getIsValue()) + .type(JSONSerDeUtils.deserializeJson(dto.getType().data(), DataSetFieldType.class)) + .dataEntityId(dto.getDataEntityId()) + .dataEntityName(dto.getDataEntityName()) + .ownership(ownershipMapper.mapDtos(dto.getOwnership())) + .dataSource(dataSourceMapper.mapDto(new DataSourceDto(dto.getDataSource(), dto.getNamespace(), null))); + } + + private PageInfo pageInfo(final long total) { + return new PageInfo(total, false); + } +} diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/mapper/DatasetFieldTermsDtoMapper.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/mapper/DatasetFieldTermsDtoMapper.java new file mode 100644 index 000000000..0e6c4f6c6 --- /dev/null +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/mapper/DatasetFieldTermsDtoMapper.java @@ -0,0 +1,55 @@ +package org.opendatadiscovery.oddplatform.repository.mapper; + +import lombok.RequiredArgsConstructor; +import org.jooq.Record; +import org.opendatadiscovery.oddplatform.dto.DatasetFieldTermsDto; +import org.opendatadiscovery.oddplatform.model.tables.pojos.DataEntityPojo; +import org.opendatadiscovery.oddplatform.model.tables.pojos.DataSourcePojo; +import org.opendatadiscovery.oddplatform.model.tables.pojos.DatasetFieldPojo; +import org.opendatadiscovery.oddplatform.model.tables.pojos.NamespacePojo; +import org.opendatadiscovery.oddplatform.repository.util.JooqRecordHelper; +import org.springframework.stereotype.Component; + +import static org.opendatadiscovery.oddplatform.model.Tables.DATASET_FIELD; +import static org.opendatadiscovery.oddplatform.model.Tables.DATA_ENTITY; +import static org.opendatadiscovery.oddplatform.model.Tables.DATA_SOURCE; +import static org.opendatadiscovery.oddplatform.model.Tables.NAMESPACE; + +@Component +@RequiredArgsConstructor +public class DatasetFieldTermsDtoMapper { + public static final String DATASET_FIELD_CTE_NAME = "dataset_field_cte"; + + private final JooqRecordHelper jooqRecordHelper; + private final DataEntityDtoMapper dataEntityDtoMapper; + + public DatasetFieldTermsDto mapRecordToDto(final Record record) { + final Record deRecord = jooqRecordHelper.remapCte(record, DATASET_FIELD_CTE_NAME, DATASET_FIELD); + + final DatasetFieldPojo datasetFieldPojo + = jooqRecordHelper.extractRelation(deRecord, DATASET_FIELD, DatasetFieldPojo.class); + + final DataEntityPojo dataEntityPojo = + jooqRecordHelper.extractRelation(record, DATA_ENTITY, DataEntityPojo.class); + + return DatasetFieldTermsDto.builder() + .id(datasetFieldPojo.getId()) + .isKey(datasetFieldPojo.getIsKey()) + .name(datasetFieldPojo.getName()) + .internalName(datasetFieldPojo.getInternalName()) + .oddrn(datasetFieldPojo.getOddrn()) + .defaultValue(datasetFieldPojo.getDefaultValue()) + .internalDescription(datasetFieldPojo.getInternalDescription()) + .externalDescription(datasetFieldPojo.getExternalDescription()) + .isValue(datasetFieldPojo.getIsValue()) + .type(datasetFieldPojo.getType()) + .isSortKey(datasetFieldPojo.getIsSortKey()) + .isPrimaryKey(datasetFieldPojo.getIsPrimaryKey()) + .dataSource(jooqRecordHelper.extractRelation(record, DATA_SOURCE, DataSourcePojo.class)) + .ownership(dataEntityDtoMapper.extractOwnershipRelation(record)) + .namespace(jooqRecordHelper.extractRelation(record, NAMESPACE, NamespacePojo.class)) + .dataEntityName(dataEntityPojo.getExternalName()) + .dataEntityId(dataEntityPojo.getId()) + .build(); + } +} diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveDatasetFieldRepository.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveDatasetFieldRepository.java index e81050992..c5e673725 100644 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveDatasetFieldRepository.java +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveDatasetFieldRepository.java @@ -1,6 +1,7 @@ package org.opendatadiscovery.oddplatform.repository.reactive; import java.util.List; +import org.opendatadiscovery.oddplatform.dto.DatasetFieldTermsDto; import org.opendatadiscovery.oddplatform.dto.DatasetFieldWithTagsDto; import org.opendatadiscovery.oddplatform.model.tables.pojos.DatasetFieldPojo; import reactor.core.publisher.Flux; @@ -16,4 +17,7 @@ public interface ReactiveDatasetFieldRepository extends ReactiveCRUDRepository getLastVersionDatasetFieldsByOddrns(final List oddrns); Mono getDataEntityIdByDatasetFieldId(final long datasetFieldId); + + Flux listByTerm(final long termId, final String query, + final int page, final int size); } diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveDatasetFieldRepositoryImpl.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveDatasetFieldRepositoryImpl.java index cd68cca13..27ae69305 100644 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveDatasetFieldRepositoryImpl.java +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveDatasetFieldRepositoryImpl.java @@ -1,18 +1,27 @@ package org.opendatadiscovery.oddplatform.repository.reactive; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Set; +import java.util.stream.Stream; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; +import org.jooq.Condition; +import org.jooq.Field; import org.jooq.Name; import org.jooq.Record; import org.jooq.Record1; +import org.jooq.SelectSeekStepN; +import org.jooq.Table; import org.jooq.impl.DSL; +import org.opendatadiscovery.oddplatform.dto.DatasetFieldTermsDto; import org.opendatadiscovery.oddplatform.dto.DatasetFieldWithTagsDto; import org.opendatadiscovery.oddplatform.model.tables.pojos.DatasetFieldPojo; import org.opendatadiscovery.oddplatform.model.tables.pojos.TagPojo; import org.opendatadiscovery.oddplatform.model.tables.records.DatasetFieldRecord; +import org.opendatadiscovery.oddplatform.repository.mapper.DatasetFieldTermsDtoMapper; import org.opendatadiscovery.oddplatform.repository.util.JooqQueryHelper; import org.opendatadiscovery.oddplatform.repository.util.JooqReactiveOperations; import org.opendatadiscovery.oddplatform.repository.util.JooqRecordHelper; @@ -24,10 +33,16 @@ import static org.jooq.impl.DSL.jsonArrayAgg; import static org.jooq.impl.DSL.name; import static org.jooq.impl.DSL.partitionBy; +import static org.jooq.impl.DSL.select; import static org.opendatadiscovery.oddplatform.model.Tables.DATASET_FIELD; +import static org.opendatadiscovery.oddplatform.model.Tables.DATASET_FIELD_TO_TERM; import static org.opendatadiscovery.oddplatform.model.Tables.DATASET_STRUCTURE; import static org.opendatadiscovery.oddplatform.model.Tables.DATASET_VERSION; import static org.opendatadiscovery.oddplatform.model.Tables.DATA_ENTITY; +import static org.opendatadiscovery.oddplatform.model.Tables.DATA_SOURCE; +import static org.opendatadiscovery.oddplatform.model.Tables.NAMESPACE; +import static org.opendatadiscovery.oddplatform.model.Tables.OWNER; +import static org.opendatadiscovery.oddplatform.model.Tables.OWNERSHIP; import static org.opendatadiscovery.oddplatform.model.Tables.TAG; import static org.opendatadiscovery.oddplatform.model.Tables.TAG_TO_DATASET_FIELD; @@ -36,14 +51,20 @@ public class ReactiveDatasetFieldRepositoryImpl extends ReactiveAbstractCRUDRepository implements ReactiveDatasetFieldRepository { + public static final String DATASET_FIELD_CTE_NAME = "dataset_field_cte"; + public static final String AGG_OWNER_FIELD = "owner"; + public static final String AGG_OWNERSHIP_FIELD = "ownership"; private final JooqRecordHelper jooqRecordHelper; + private final DatasetFieldTermsDtoMapper datasetFieldTermsDtoMapper; public ReactiveDatasetFieldRepositoryImpl(final JooqReactiveOperations jooqReactiveOperations, final JooqQueryHelper jooqQueryHelper, - final JooqRecordHelper jooqRecordHelper) { + final JooqRecordHelper jooqRecordHelper, + final DatasetFieldTermsDtoMapper datasetFieldTermsDtoMapper) { super(jooqReactiveOperations, jooqQueryHelper, DATASET_FIELD, DatasetFieldPojo.class); this.jooqRecordHelper = jooqRecordHelper; + this.datasetFieldTermsDtoMapper = datasetFieldTermsDtoMapper; } @Override @@ -73,7 +94,7 @@ public Flux getLastVersionDatasetFieldsByOddrns(final List getLastVersionDatasetFieldsByOddrns(final List getDataEntityIdByDatasetFieldId(final long datasetFieldId) { - final var query = DSL.select(DATA_ENTITY.ID) + final var query = select(DATA_ENTITY.ID) .from(DATASET_FIELD) .join(DATASET_STRUCTURE).on(DATASET_STRUCTURE.DATASET_FIELD_ID.eq(DATASET_FIELD.ID)) .join(DATASET_VERSION).on(DATASET_STRUCTURE.DATASET_VERSION_ID.eq(DATASET_VERSION.ID)) @@ -103,7 +124,7 @@ public Mono getDataEntityIdByDatasetFieldId(final long datasetFieldId) { @Override public Mono getDatasetFieldWithTags(final long datasetFieldId) { - final var query = DSL.select(DATASET_FIELD.fields()) + final var query = select(DATASET_FIELD.fields()) .select(jsonArrayAgg(field(TAG.asterisk().toString())).as("tags")) .from(DATASET_FIELD) .leftJoin(TAG_TO_DATASET_FIELD).on(DATASET_FIELD.ID.eq(TAG_TO_DATASET_FIELD.DATASET_FIELD_ID)) @@ -115,6 +136,69 @@ public Mono getDatasetFieldWithTags(final long datasetF .map(this::mapRecordToDatasetFieldWithTags); } + @Override + public Flux listByTerm(final long termId, final String query, + final int page, final int size) { + final List> selectFields = new ArrayList<>(Arrays.stream(DATASET_FIELD.fields()).toList()); + final List conditions = new ArrayList<>(); + + if (StringUtils.isNotBlank(query)) { + conditions.add(DATASET_FIELD.NAME.contains(query)); + } + + final SelectSeekStepN records = select(selectFields) + .from(DATASET_FIELD) + .where(conditions) + .orderBy(List.of(field(DATASET_FIELD.ID).desc())); + + final Table datasetCte = records.asTable(DATASET_FIELD_CTE_NAME); + + final List> groupByFields = Stream.of(datasetCte.fields(), NAMESPACE.fields(), + DATA_SOURCE.fields(), + DATA_ENTITY.fields()) + .flatMap(Arrays::stream) + .toList(); + + final List> aggregatedFields = List.of( + jsonArrayAgg(field(OWNER.asterisk().toString())).as(AGG_OWNER_FIELD), + jsonArrayAgg(field(OWNERSHIP.asterisk().toString())).as(AGG_OWNERSHIP_FIELD)); + + final Table fromTable = DSL.table(DATASET_FIELD_CTE_NAME) + .leftJoin(DATA_ENTITY) + .on(DATA_ENTITY.ODDRN.eq(select(DATASET_VERSION.DATASET_ODDRN) + .from(DATASET_VERSION) + .where(DATASET_VERSION.ID.eq( + select(DSL.max(DATASET_STRUCTURE.DATASET_VERSION_ID)) + .from(DATASET_STRUCTURE) + .where( + DATASET_STRUCTURE.DATASET_FIELD_ID.eq( + jooqQueryHelper.getField(datasetCte, DATASET_FIELD.ID))) + .groupBy(DATASET_STRUCTURE.DATASET_FIELD_ID)) + ))) + .leftJoin(DATA_SOURCE) + .on(DATA_SOURCE.ID.eq(DATA_ENTITY.DATA_SOURCE_ID)) + .leftJoin(NAMESPACE).on(NAMESPACE.ID.eq(DATA_ENTITY.NAMESPACE_ID)) + .or(NAMESPACE.ID.eq(DATA_SOURCE.NAMESPACE_ID)) + .leftJoin(OWNERSHIP).on(OWNERSHIP.DATA_ENTITY_ID.eq(DATA_ENTITY.ID)) + .leftJoin(OWNER).on(OWNER.ID.eq(OWNERSHIP.OWNER_ID)) + .leftJoin(DATASET_FIELD_TO_TERM) + .on(DATASET_FIELD_TO_TERM.DATASET_FIELD_ID.eq(jooqQueryHelper.getField(datasetCte, DATASET_FIELD.ID))); + + final var jooqQuery = DSL.with(DATASET_FIELD_CTE_NAME) + .asMaterialized(records) + .select(groupByFields) + .select(aggregatedFields) + .from(fromTable) + .where(DATASET_FIELD_TO_TERM.TERM_ID.eq(termId)) + .groupBy(groupByFields) + .orderBy(List.of(jooqQueryHelper.getField(datasetCte, DATASET_FIELD.ID).desc())) + .limit(size) + .offset((page - 1) * size); + + return jooqReactiveOperations.flux(jooqQuery) + .map(datasetFieldTermsDtoMapper::mapRecordToDto); + } + @NotNull private DatasetFieldWithTagsDto mapRecordToDatasetFieldWithTags(final Record datasetFieldRecord) { final DatasetFieldPojo pojo = datasetFieldRecord.into(DatasetFieldPojo.class); diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveTermRepositoryImpl.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveTermRepositoryImpl.java index feccad459..ab8094ef2 100644 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveTermRepositoryImpl.java +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveTermRepositoryImpl.java @@ -290,13 +290,15 @@ public Mono> findByState(final FacetStateDto state, final int page .select(jsonArrayAgg(field(TERM_OWNERSHIP.asterisk().toString())).as(AGG_OWNERSHIPS_FIELD)) .select(jsonArrayAgg(field(OWNER.asterisk().toString())).as(AGG_OWNERS_FIELD)) .select(jsonArrayAgg(field(TITLE.asterisk().toString())).as(AGG_TITLES_FIELD)) - .select(DSL.countDistinct(DATA_ENTITY_TO_TERM.DATA_ENTITY_ID).as(ENTITIES_COUNT)) + .select(DSL.countDistinct(DATA_ENTITY_TO_TERM.DATA_ENTITY_ID) + .plus(DSL.countDistinct(DATASET_FIELD_TO_TERM.DATASET_FIELD_ID)).as(ENTITIES_COUNT)) .from(termCTE.getName()) .join(NAMESPACE).on(NAMESPACE.ID.eq(termCTE.field(TERM.NAMESPACE_ID))) .leftJoin(TERM_OWNERSHIP).on(TERM_OWNERSHIP.TERM_ID.eq(termCTE.field(TERM.ID))) .leftJoin(OWNER).on(OWNER.ID.eq(TERM_OWNERSHIP.OWNER_ID)) .leftJoin(TITLE).on(TITLE.ID.eq(TERM_OWNERSHIP.TITLE_ID)) .leftJoin(DATA_ENTITY_TO_TERM).on(DATA_ENTITY_TO_TERM.TERM_ID.eq(termCTE.field(TERM.ID))) + .leftJoin(DATASET_FIELD_TO_TERM).on(DATASET_FIELD_TO_TERM.TERM_ID.eq(termCTE.field(TERM.ID))) .groupBy(groupByFields); return jooqReactiveOperations.flux(query) diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/DatasetFieldService.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/DatasetFieldService.java index e1cd41628..db0d15a28 100644 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/DatasetFieldService.java +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/DatasetFieldService.java @@ -3,6 +3,7 @@ import java.util.List; import org.opendatadiscovery.oddplatform.api.contract.model.DataSetFieldDescription; import org.opendatadiscovery.oddplatform.api.contract.model.DatasetFieldDescriptionUpdateFormData; +import org.opendatadiscovery.oddplatform.api.contract.model.DatasetFieldList; import org.opendatadiscovery.oddplatform.api.contract.model.DatasetFieldTagsUpdateFormData; import org.opendatadiscovery.oddplatform.api.contract.model.InternalName; import org.opendatadiscovery.oddplatform.api.contract.model.InternalNameFormData; @@ -25,4 +26,6 @@ Flux updateDatasetFieldTags(final long datasetFieldId, Mono> createOrUpdateDatasetFields(final List fields); Mono updateStatistics(final DatasetStatisticsList datasetStatisticsList); + + Mono listByTerm(final Long termId, final String query, final Integer page, final Integer size); } diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/DatasetFieldServiceImpl.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/DatasetFieldServiceImpl.java index 7a8761488..ae1f6cc5e 100644 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/DatasetFieldServiceImpl.java +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/DatasetFieldServiceImpl.java @@ -18,6 +18,7 @@ import org.opendatadiscovery.oddplatform.annotation.ReactiveTransactional; import org.opendatadiscovery.oddplatform.api.contract.model.DataSetFieldDescription; import org.opendatadiscovery.oddplatform.api.contract.model.DatasetFieldDescriptionUpdateFormData; +import org.opendatadiscovery.oddplatform.api.contract.model.DatasetFieldList; import org.opendatadiscovery.oddplatform.api.contract.model.DatasetFieldTagsUpdateFormData; import org.opendatadiscovery.oddplatform.api.contract.model.InternalName; import org.opendatadiscovery.oddplatform.api.contract.model.InternalNameFormData; @@ -32,6 +33,7 @@ import org.opendatadiscovery.oddplatform.ingestion.contract.model.DataSetStatistics; import org.opendatadiscovery.oddplatform.ingestion.contract.model.DatasetStatisticsList; import org.opendatadiscovery.oddplatform.mapper.DatasetFieldApiMapper; +import org.opendatadiscovery.oddplatform.mapper.DatasetFieldListMapper; import org.opendatadiscovery.oddplatform.mapper.EnumValueMapper; import org.opendatadiscovery.oddplatform.mapper.TagMapper; import org.opendatadiscovery.oddplatform.mapper.TermMapper; @@ -78,6 +80,7 @@ public class DatasetFieldServiceImpl implements DatasetFieldService { private final TagMapper tagMapper; private final EnumValueMapper enumValueMapper; private final TermMapper termMapper; + private final DatasetFieldListMapper datasetFieldListMapper; @Override @ReactiveTransactional @@ -177,6 +180,14 @@ public Mono updateStatistics(final DatasetStatisticsList datasetStatistics .then(); } + @Override + public Mono listByTerm(final Long termId, final String query, + final Integer page, final Integer size) { + return reactiveDatasetFieldRepository.listByTerm(termId, query, page, size) + .collectList() + .map(datasetFieldListMapper::mapPojos); + } + private Mono updateFieldsTags(final Map statisticsDict, final List existingFields) { final Set tagNames = statisticsDict.values().stream()