Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support external tags #816

Merged
merged 13 commits into from
Jul 15, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public DataEntityDetailsDto(final DataEntityPojo dataEntity,
final NamespacePojo namespace,
final List<OwnershipDto> ownership,
final DataSourcePojo dataSource,
final Collection<TagPojo> tags,
final Collection<TagDto> tags,
final Collection<MetadataDto> metadata,
final Collection<DatasetVersionPojo> datasetVersions,
final DataEntityGroupDimensionsDto dataEntityGroupDimensionsDto,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class DataEntityDimensionsDto extends DataEntityDto {
protected NamespacePojo namespace;
protected List<OwnershipDto> ownership;
protected DataSourcePojo dataSource;
protected Collection<TagPojo> tags;
protected Collection<TagDto> tags;
protected Collection<DataEntityPojo> parentGroups;

protected DataEntityGroupDimensionsDto groupsDto;
Expand All @@ -40,7 +40,7 @@ public DataEntityDimensionsDto(final DataEntityPojo dataEntity,
final NamespacePojo namespace,
final List<OwnershipDto> ownership,
final DataSourcePojo dataSource,
final Collection<TagPojo> tags,
final Collection<TagDto> tags,
final DataEntityGroupDimensionsDto groupsDto,
final DataSetDetailsDto dataSetDetailsDto,
final DataTransformerDetailsDto dataTransformerDetailsDto,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package org.opendatadiscovery.oddplatform.dto;

import java.util.Set;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.opendatadiscovery.oddplatform.model.tables.pojos.DatasetFieldPojo;
import org.opendatadiscovery.oddplatform.model.tables.pojos.LabelPojo;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class DatasetFieldDto {
private DatasetFieldPojo datasetFieldPojo;
private Set<LabelPojo> labelPojos;
private List<LabelDto> labels;
private Long parentFieldId;
private Integer enumValueCount;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.opendatadiscovery.oddplatform.dto;

import org.opendatadiscovery.oddplatform.model.tables.pojos.LabelPojo;

public record LabelDto(LabelPojo pojo, Boolean external) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

import org.opendatadiscovery.oddplatform.model.tables.pojos.TagPojo;

public record TagDto(TagPojo tagPojo, Long usedCount) {
public record TagDto(TagPojo tagPojo, Long usedCount, Boolean external) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class DataEntityIngestionDto {
protected Set<DataEntityClassDto> entityClasses;
protected DataEntityTypeDto type;
protected Map<String, Object> metadata;
protected List<String> tags;
protected String specificAttributesJson;

protected DataSetIngestionDto dataSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public EnrichedDataEntityIngestionDto(final long id,
final boolean updated) {
super(ingestionDto.name, ingestionDto.oddrn, ingestionDto.dataSourceId, ingestionDto.externalDescription,
ingestionDto.createdAt, ingestionDto.updatedAt, ingestionDto.entityClasses, ingestionDto.type,
ingestionDto.metadata, ingestionDto.specificAttributesJson, ingestionDto.dataSet,
ingestionDto.metadata, ingestionDto.tags, ingestionDto.specificAttributesJson, ingestionDto.dataSet,
ingestionDto.dataTransformer, ingestionDto.dataConsumer, ingestionDto.datasetQualityTest,
ingestionDto.dataInput, ingestionDto.dataEntityGroup);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public interface DatasetFieldApiMapper {
@Mapping(source = "datasetFieldPojo", target = ".")
@Mapping(source = "datasetFieldPojo.type", target = "type", qualifiedByName = "deserializeType")
@Mapping(source = "datasetFieldPojo.stats", target = "stats", qualifiedByName = "deserializeStats")
@Mapping(source = "labelPojos", target = "labels")
DataSetField mapDto(final DatasetFieldDto datasetFieldDto);

@Named("deserializeType")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
package org.opendatadiscovery.oddplatform.mapper;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.opendatadiscovery.oddplatform.api.contract.model.Label;
import org.opendatadiscovery.oddplatform.api.contract.model.LabelFormData;
import org.opendatadiscovery.oddplatform.api.contract.model.LabelsResponse;
import org.opendatadiscovery.oddplatform.api.contract.model.PageInfo;
import org.opendatadiscovery.oddplatform.dto.LabelDto;
import org.opendatadiscovery.oddplatform.model.tables.pojos.LabelPojo;
import org.opendatadiscovery.oddplatform.utils.Page;

@Mapper(config = MapperConfig.class)
public interface LabelMapper {
Label mapToLabel(final LabelPojo label);
@Mapping(source = "dto.pojo", target = ".")
Label mapToLabel(final LabelDto dto);

LabelPojo mapToPojo(final LabelFormData form);
Label mapToLabel(final LabelPojo pojo);

LabelPojo mapToPojo(final String name);

LabelPojo applyToPojo(@MappingTarget final LabelPojo pojo, final LabelFormData form);

default LabelsResponse mapToLabelResponse(final Page<LabelPojo> page) {
default LabelsResponse mapToLabelResponse(final Page<LabelDto> page) {
return new LabelsResponse()
.items(page.getData().stream().map(this::mapToLabel).toList())
.pageInfo(new PageInfo().total(page.getTotal()).hasNext(page.isHasNext()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public interface TagMapper {

Tag mapToTag(final TagPojo pojo);

List<Tag> mapToTagList(final Collection<TagPojo> pojos);
List<Tag> mapToTagList(final Collection<TagDto> dtos);

default TagsResponse mapToTagsResponse(final Page<TagDto> page) {
return new TagsResponse()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.jooq.JSONB;
Expand All @@ -34,6 +35,7 @@
import org.opendatadiscovery.oddplatform.ingestion.contract.model.DataSetField;
import org.opendatadiscovery.oddplatform.ingestion.contract.model.DataSetFieldType;
import org.opendatadiscovery.oddplatform.ingestion.contract.model.DataTransformer;
import org.opendatadiscovery.oddplatform.ingestion.contract.model.Tag;
import org.opendatadiscovery.oddplatform.model.tables.pojos.DataEntityPojo;
import org.opendatadiscovery.oddplatform.utils.JSONSerDeUtils;
import org.opendatadiscovery.oddplatform.utils.Pair;
Expand Down Expand Up @@ -83,6 +85,10 @@ public DataEntityIngestionDto createIngestionDto(final DataEntity dataEntity, fi
builder = builder.metadata(dataEntity.getMetadata().get(0).getMetadata());
}

if (CollectionUtils.isNotEmpty(dataEntity.getTags())) {
builder = builder.tags(dataEntity.getTags().stream().map(Tag::getName).toList());
}

if (entityClasses.contains(DATA_SET)) {
builder = builder.dataSet(createDatasetIngestionDto(dataEntity.getDataset()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ Page<DataEntityDimensionsDto> findByState(final FacetStateDto state,

void calculateSearchEntrypoints(final Collection<Long> dataEntityIds);

void calculateDataEntityVectors(final Collection<Long> ids);

void calculateNamespaceVectors(final Collection<Long> ids);

void calculateDataSourceVectors(final Collection<Long> ids);

void calculateMetadataVectors(final Collection<Long> ids);

List<DataEntityDto> getQuerySuggestions(final String query, final Integer entityClassId,
Expand Down
Loading