Skip to content

Commit

Permalink
(issues/1425): Replace "labels" functionality with "tags" instead. (#…
Browse files Browse the repository at this point in the history
…1440)

Co-authored-by: vburlachenko <[email protected]>
Co-authored-by: Vladysl <[email protected]>
Co-authored-by: dabdullin <[email protected]>
  • Loading branch information
4 people authored Sep 28, 2023
1 parent d4f8a9a commit 17afca9
Show file tree
Hide file tree
Showing 110 changed files with 1,061 additions and 2,215 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import static org.opendatadiscovery.oddplatform.dto.policy.PolicyPermissionDto.DATASET_FIELD_DESCRIPTION_UPDATE;
import static org.opendatadiscovery.oddplatform.dto.policy.PolicyPermissionDto.DATASET_FIELD_ENUMS_UPDATE;
import static org.opendatadiscovery.oddplatform.dto.policy.PolicyPermissionDto.DATASET_FIELD_INTERNAL_NAME_UPDATE;
import static org.opendatadiscovery.oddplatform.dto.policy.PolicyPermissionDto.DATASET_FIELD_LABELS_UPDATE;
import static org.opendatadiscovery.oddplatform.dto.policy.PolicyPermissionDto.DATASET_FIELD_TAGS_UPDATE;
import static org.opendatadiscovery.oddplatform.dto.policy.PolicyPermissionDto.DATASET_TEST_RUN_SET_SEVERITY;
import static org.opendatadiscovery.oddplatform.dto.policy.PolicyPermissionDto.DATA_ENTITY_ADD_TERM;
import static org.opendatadiscovery.oddplatform.dto.policy.PolicyPermissionDto.DATA_ENTITY_ADD_TO_GROUP;
Expand All @@ -43,9 +43,6 @@
import static org.opendatadiscovery.oddplatform.dto.policy.PolicyPermissionDto.DATA_SOURCE_DELETE;
import static org.opendatadiscovery.oddplatform.dto.policy.PolicyPermissionDto.DATA_SOURCE_TOKEN_REGENERATE;
import static org.opendatadiscovery.oddplatform.dto.policy.PolicyPermissionDto.DATA_SOURCE_UPDATE;
import static org.opendatadiscovery.oddplatform.dto.policy.PolicyPermissionDto.LABEL_CREATE;
import static org.opendatadiscovery.oddplatform.dto.policy.PolicyPermissionDto.LABEL_DELETE;
import static org.opendatadiscovery.oddplatform.dto.policy.PolicyPermissionDto.LABEL_UPDATE;
import static org.opendatadiscovery.oddplatform.dto.policy.PolicyPermissionDto.NAMESPACE_CREATE;
import static org.opendatadiscovery.oddplatform.dto.policy.PolicyPermissionDto.NAMESPACE_DELETE;
import static org.opendatadiscovery.oddplatform.dto.policy.PolicyPermissionDto.NAMESPACE_UPDATE;
Expand Down Expand Up @@ -120,11 +117,6 @@ public final class SecurityConstants {
TAG_UPDATE),
new SecurityRule(NO_CONTEXT, new PathPatternParserServerWebExchangeMatcher("/api/tags/{tag_id}", DELETE),
TAG_DELETE),
new SecurityRule(NO_CONTEXT, new PathPatternParserServerWebExchangeMatcher("/api/labels", POST), LABEL_CREATE),
new SecurityRule(NO_CONTEXT, new PathPatternParserServerWebExchangeMatcher("/api/labels/{label_id}", PUT),
LABEL_UPDATE),
new SecurityRule(NO_CONTEXT, new PathPatternParserServerWebExchangeMatcher("/api/labels/{label_id}", DELETE),
LABEL_DELETE),
new SecurityRule(NO_CONTEXT, new PathPatternParserServerWebExchangeMatcher("/api/owners", POST), OWNER_CREATE),
new SecurityRule(NO_CONTEXT, new PathPatternParserServerWebExchangeMatcher("/api/owners/{owner_id}", PUT),
OWNER_UPDATE),
Expand Down Expand Up @@ -256,8 +248,8 @@ DATA_ENTITY, new PathPatternParserServerWebExchangeMatcher(
new PathPatternParserServerWebExchangeMatcher("/api/datasetfields/{dataset_field_id}/description", PUT),
DATASET_FIELD_DESCRIPTION_UPDATE),
new SecurityRule(DATASET_FIELD,
new PathPatternParserServerWebExchangeMatcher("/api/datasetfields/{dataset_field_id}/labels", PUT),
DATASET_FIELD_LABELS_UPDATE),
new PathPatternParserServerWebExchangeMatcher("/api/datasetfields/{dataset_field_id}/tags", PUT),
DATASET_FIELD_TAGS_UPDATE),
new SecurityRule(
DATASET_FIELD,
new PathPatternParserServerWebExchangeMatcher("/api/datasetfields/{dataset_field_id}/enum_values", POST),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
import org.opendatadiscovery.oddplatform.api.contract.model.BulkEnumValueFormData;
import org.opendatadiscovery.oddplatform.api.contract.model.DataSetFieldDescription;
import org.opendatadiscovery.oddplatform.api.contract.model.DatasetFieldDescriptionUpdateFormData;
import org.opendatadiscovery.oddplatform.api.contract.model.DatasetFieldLabelsUpdateFormData;
import org.opendatadiscovery.oddplatform.api.contract.model.DatasetFieldTagsUpdateFormData;
import org.opendatadiscovery.oddplatform.api.contract.model.DatasetFieldTermFormData;
import org.opendatadiscovery.oddplatform.api.contract.model.EnumValueList;
import org.opendatadiscovery.oddplatform.api.contract.model.InternalName;
import org.opendatadiscovery.oddplatform.api.contract.model.InternalNameFormData;
import org.opendatadiscovery.oddplatform.api.contract.model.Label;
import org.opendatadiscovery.oddplatform.api.contract.model.LinkedTerm;
import org.opendatadiscovery.oddplatform.api.contract.model.MetricSet;
import org.opendatadiscovery.oddplatform.api.contract.model.Tag;
import org.opendatadiscovery.oddplatform.service.DatasetFieldService;
import org.opendatadiscovery.oddplatform.service.EnumValueService;
import org.opendatadiscovery.oddplatform.service.MetricService;
Expand Down Expand Up @@ -53,13 +53,13 @@ public Mono<ResponseEntity<InternalName>> updateDatasetFieldInternalName(
}

@Override
public Mono<ResponseEntity<Flux<Label>>> updateDatasetFieldLabels(
public Mono<ResponseEntity<Flux<Tag>>> updateDatasetFieldTags(
final Long datasetFieldId,
final Mono<DatasetFieldLabelsUpdateFormData> formDataMono,
final Mono<DatasetFieldTagsUpdateFormData> formDataMono,
final ServerWebExchange exchange) {
final Flux<Label> labels = formDataMono
.flatMapMany(formData -> datasetFieldService.updateDatasetFieldLabels(datasetFieldId, formData));
return Mono.just(ResponseEntity.ok(labels));
final Flux<Tag> tags = formDataMono
.flatMapMany(formData -> datasetFieldService.updateDatasetFieldTags(datasetFieldId, formData));
return Mono.just(ResponseEntity.ok(tags));
}

@Override
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public enum DataEntityFilledField {
INTERNAL_TAGS,
TERMS,
DATASET_FIELD_DESCRIPTION,
DATASET_FIELD_LABELS,
DATASET_FIELD_TAGS,
DATASET_FIELD_ENUMS,
DATASET_FIELD_TERMS,
DATASET_FIELD_INTERNAL_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@Builder
public class DatasetFieldDto {
private DatasetFieldPojo datasetFieldPojo;
private List<LabelDto> labels;
private List<TagDto> tags;
private List<DatasetFieldMetadataDto> metadata;
private List<LinkedTermDto> terms;
private Long parentFieldId;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.opendatadiscovery.oddplatform.dto;

import java.util.Set;
import org.opendatadiscovery.oddplatform.model.tables.pojos.DatasetFieldPojo;
import org.opendatadiscovery.oddplatform.model.tables.pojos.TagPojo;

public record DatasetFieldWithTagsDto(DatasetFieldPojo datasetFieldPojo, Set<TagPojo> tags) {
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.opendatadiscovery.oddplatform.dto;

public enum LabelOrigin {
ALL,
public enum TagOrigin {
INTERNAL,
EXTERNAL,
EXTERNAL_STATISTICS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public enum ActivityEventTypeDto {
DATASET_FIELD_VALUES_UPDATED,
DATASET_FIELD_DESCRIPTION_UPDATED,
DATASET_FIELD_INTERNAL_NAME_UPDATED,
DATASET_FIELD_LABELS_UPDATED,
DATASET_FIELD_TAGS_UPDATED,
DATASET_FIELD_TERM_ASSIGNMENT_UPDATED,
CUSTOM_GROUP_CREATED,
CUSTOM_GROUP_UPDATED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
public record DatasetFieldInformationActivityStateDto(Long id, String name,
@JsonProperty("internal_name") String internalName,
JSONB type, String description,
List<DatasetFieldLabelActivityStateDto> labels) {
List<DatasetFieldTagActivityStateDto> tags) {
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.opendatadiscovery.oddplatform.dto.activity;

public record DatasetFieldTagActivityStateDto(Long id, String name) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public record DataEntityGroupDto(List<String> entitiesOddrns, String groupOddrn)
}

public record DatasetFieldIngestionDto(DatasetFieldPojo field,
List<String> labels,
List<String> tags,
List<DataSetFieldEnumValue> enumValues,
Map<String, Object> metadata) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public enum PolicyPermissionDto {
DATASET_TEST_RUN_SET_SEVERITY(DATA_ENTITY),
DATASET_FIELD_DESCRIPTION_UPDATE(DATA_ENTITY),
DATASET_FIELD_INTERNAL_NAME_UPDATE(DATA_ENTITY),
DATASET_FIELD_LABELS_UPDATE(DATA_ENTITY),
DATASET_FIELD_TAGS_UPDATE(DATA_ENTITY),
DATASET_FIELD_ENUMS_UPDATE(DATA_ENTITY),
DATASET_FIELD_ADD_TERM(DATA_ENTITY),
DATASET_FIELD_DELETE_TERM(DATA_ENTITY),
Expand Down Expand Up @@ -57,9 +57,6 @@ public enum PolicyPermissionDto {
TAG_CREATE(MANAGEMENT),
TAG_UPDATE(MANAGEMENT),
TAG_DELETE(MANAGEMENT),
LABEL_CREATE(MANAGEMENT),
LABEL_UPDATE(MANAGEMENT),
LABEL_DELETE(MANAGEMENT),
OWNER_CREATE(MANAGEMENT),
OWNER_UPDATE(MANAGEMENT),
OWNER_DELETE(MANAGEMENT),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import static org.opendatadiscovery.oddplatform.model.Tables.FILE;
import static org.opendatadiscovery.oddplatform.model.Tables.GROUP_ENTITY_RELATIONS;
import static org.opendatadiscovery.oddplatform.model.Tables.GROUP_PARENT_GROUP_RELATIONS;
import static org.opendatadiscovery.oddplatform.model.Tables.LABEL_TO_DATASET_FIELD;
import static org.opendatadiscovery.oddplatform.model.Tables.LINEAGE;
import static org.opendatadiscovery.oddplatform.model.Tables.LINK;
import static org.opendatadiscovery.oddplatform.model.Tables.MESSAGE;
Expand All @@ -55,6 +54,7 @@
import static org.opendatadiscovery.oddplatform.model.Tables.METRIC_SERIES;
import static org.opendatadiscovery.oddplatform.model.Tables.OWNERSHIP;
import static org.opendatadiscovery.oddplatform.model.Tables.SEARCH_ENTRYPOINT;
import static org.opendatadiscovery.oddplatform.model.Tables.TAG_TO_DATASET_FIELD;
import static org.opendatadiscovery.oddplatform.model.Tables.TAG_TO_DATA_ENTITY;

@Component
Expand Down Expand Up @@ -200,8 +200,8 @@ private void deleteDatasetsInformation(final DSLContext dslContext,
.where(ENUM_VALUE.DATASET_FIELD_ID.in(datasetFieldIds))
.execute();

dslContext.deleteFrom(LABEL_TO_DATASET_FIELD)
.where(LABEL_TO_DATASET_FIELD.DATASET_FIELD_ID.in(datasetFieldIds))
dslContext.deleteFrom(TAG_TO_DATASET_FIELD)
.where(TAG_TO_DATASET_FIELD.DATASET_FIELD_ID.in(datasetFieldIds))
.execute();

dslContext.deleteFrom(DATASET_FIELD_TO_TERM)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ ActivityState mapState(final JSONB jsonb, final ActivityEventTypeDto eventTypeDt
case BUSINESS_NAME_UPDATED -> mapBusinessNameState(jsonb);
case DATA_ENTITY_STATUS_UPDATED -> mapDataEntityStatusState(jsonb);
case DATASET_FIELD_VALUES_UPDATED -> mapDatasetFieldValuesState(jsonb);
case DATASET_FIELD_DESCRIPTION_UPDATED, DATASET_FIELD_LABELS_UPDATED, DATASET_FIELD_INTERNAL_NAME_UPDATED ->
case DATASET_FIELD_DESCRIPTION_UPDATED, DATASET_FIELD_TAGS_UPDATED, DATASET_FIELD_INTERNAL_NAME_UPDATED ->
mapDatasetFieldInformationState(jsonb);
case DATASET_FIELD_TERM_ASSIGNMENT_UPDATED -> mapDatasetFieldTermState(jsonb);
case CUSTOM_GROUP_CREATED, CUSTOM_GROUP_UPDATED -> mapCustomGroupState(jsonb);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.opendatadiscovery.oddplatform.model.tables.pojos.DatasetFieldPojo;
import org.opendatadiscovery.oddplatform.utils.JSONSerDeUtils;

@Mapper(config = MapperConfig.class, uses = {LabelMapper.class, MetadataFieldValueMapper.class, TermMapper.class})
@Mapper(config = MapperConfig.class, uses = {TagMapper.class, MetadataFieldValueMapper.class, TermMapper.class})
public interface DatasetFieldApiMapper {

@Mapping(source = "datasetFieldPojo", target = ".")
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

@Mapper(config = MapperConfig.class)
public interface DatasetFieldIngestionMapper {
@Mapping(target = "labels", source = "tags")
@Mapping(target = "field", source = ".")
@Mapping(target = "metadata", source = "field.metadata", qualifiedByName = "mapFieldMetadata")
@Mapping(target = "enumValues", source = "enumValues", qualifiedByName = "prepareEnumValues")
Expand All @@ -38,12 +37,12 @@ public interface DatasetFieldIngestionMapper {
@Mapping(target = "externalDescription", source = "description")
DatasetFieldPojo mapFieldToPojo(final DataSetField field);

default List<String> mapLabels(final List<Tag> labels) {
if (CollectionUtils.isEmpty(labels)) {
default List<String> mapTags(final List<Tag> tags) {
if (CollectionUtils.isEmpty(tags)) {
return emptyList();
}

return labels.stream().map(Tag::getName).toList();
return tags.stream().map(Tag::getName).toList();
}

default JSONB mapType(final DataSetFieldType type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private Map<Field<?>, Object> buildUpdatedFieldsMap(final DataEntityFilledField
case TERMS -> Map.of(DATA_ENTITY_FILLED.TERMS_FILLED, isFilled);
case DATASET_FIELD_DESCRIPTION -> Map.of(DATA_ENTITY_FILLED.DATASET_FIELD_DESCRIPTION_FILLED, isFilled);
case DATASET_FIELD_INTERNAL_NAME -> Map.of(DATA_ENTITY_FILLED.DATASET_FIELD_INTERNAL_NAME_FILLED, isFilled);
case DATASET_FIELD_LABELS -> Map.of(DATA_ENTITY_FILLED.DATASET_FIELD_LABELS_FILLED, isFilled);
case DATASET_FIELD_TAGS -> Map.of(DATA_ENTITY_FILLED.DATASET_FIELD_TAGS_FILLED, isFilled);
case DATASET_FIELD_ENUMS -> Map.of(DATA_ENTITY_FILLED.DATASET_FIELD_ENUMS_FILLED, isFilled);
case DATASET_FIELD_TERMS -> Map.of(DATA_ENTITY_FILLED.DATASET_FIELD_TERMS_FILLED, isFilled);
case MANUALLY_CREATED -> Map.of(DATA_ENTITY_FILLED.MANUALLY_CREATED, isFilled);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.opendatadiscovery.oddplatform.repository.reactive;

import java.util.List;
import org.opendatadiscovery.oddplatform.dto.DatasetFieldWithLabelsDto;
import org.opendatadiscovery.oddplatform.dto.DatasetFieldWithTagsDto;
import org.opendatadiscovery.oddplatform.model.tables.pojos.DatasetFieldPojo;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
Expand All @@ -11,7 +11,7 @@ public interface ReactiveDatasetFieldRepository extends ReactiveCRUDRepository<D

Mono<DatasetFieldPojo> updateInternalName(final long datasetFieldId, final String internalName);

Mono<DatasetFieldWithLabelsDto> getDatasetFieldWithLabels(final long datasetFieldId);
Mono<DatasetFieldWithTagsDto> getDatasetFieldWithTags(final long datasetFieldId);

Flux<DatasetFieldPojo> getLastVersionDatasetFieldsByOddrns(final List<String> oddrns);

Expand Down
Loading

0 comments on commit 17afca9

Please sign in to comment.