Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into 1447
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladysl committed Oct 12, 2023
2 parents 4590eff + d94453d commit 8ac3568
Show file tree
Hide file tree
Showing 51 changed files with 929 additions and 221 deletions.
5 changes: 3 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,9 @@ ij_xml_space_around_equals_in_attribute = false
ij_xml_space_inside_empty_tag = false
ij_xml_text_wrap = normal

[{*.ats,*.ts}]
ij_continuation_indent_size = 4
[{*.ats,*.ts,*.tsx}]
indent_size = 2
ij_continuation_indent_size = 2
ij_typescript_align_imports = false
ij_typescript_align_multiline_array_initializer_expression = false
ij_typescript_align_multiline_binary_operation = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -84,7 +87,7 @@ public Mono<ResponseEntity<TermDetails>> getTermDetails(final Long termId,
}

@Override
public Mono<ResponseEntity<DataEntityList>> getTermLinkedItems(final Long termId, final Integer page,
public Mono<ResponseEntity<DataEntityList>> getTermLinkedEntities(final Long termId, final Integer page,
final Integer size,
final String query,
final Integer entityClassId,
Expand All @@ -94,6 +97,16 @@ public Mono<ResponseEntity<DataEntityList>> getTermLinkedItems(final Long termId
.map(ResponseEntity::ok);
}

@Override
public Mono<ResponseEntity<DatasetFieldList>> 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<ResponseEntity<Flux<Tag>>> createTermTagsRelations(final Long termId,
final Mono<TagsFormData> tagsFormData,
Expand Down
Original file line number Diff line number Diff line change
@@ -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<OwnershipDto> ownership;
private DataSourcePojo dataSource;
private String dataEntityName;
private Long dataEntityId;
private NamespacePojo namespace;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public class TermDetailsDto {

public TermDetailsDto(final TermRefDto termRefDto) {
this.tags = null;
this.termDto = new TermDto(termRefDto, null, null);
this.termDto = new TermDto(termRefDto, null, null, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
public class TermDto {
private final TermRefDto termRefDto;
private final Integer entitiesUsingCount;
private final Integer columnsUsingCount;
private final Set<TermOwnershipDto> ownerships;
}
Original file line number Diff line number Diff line change
@@ -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<DatasetFieldTermsDto> item);
}
Original file line number Diff line number Diff line change
@@ -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<DatasetFieldTermsDto> dataFieldsDto) {
final List<TermSearchDataSetField> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ default TermList mapToPage(final Page<TermDto> page) {
@Mapping(source = "dto.termDto.termRefDto.namespace", target = "namespace")
@Mapping(source = "dto.termDto.ownerships", target = "ownership")
@Mapping(source = "dto.termDto.entitiesUsingCount", target = "entitiesUsingCount")
@Mapping(source = "dto.termDto.columnsUsingCount", target = "columnsUsingCount")
TermDetails mapToDetails(final TermDetailsDto dto);

@Mapping(source = "dto.termRefDto.term", target = ".")
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -16,4 +17,7 @@ public interface ReactiveDatasetFieldRepository extends ReactiveCRUDRepository<D
Flux<DatasetFieldPojo> getLastVersionDatasetFieldsByOddrns(final List<String> oddrns);

Mono<Long> getDataEntityIdByDatasetFieldId(final long datasetFieldId);

Flux<DatasetFieldTermsDto> listByTerm(final long termId, final String query,
final int page, final int size);
}
Loading

0 comments on commit 8ac3568

Please sign in to comment.