Skip to content

Commit

Permalink
1456 - created new entity DataSourceSafe without token which used in … (
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladysl committed Oct 13, 2023
1 parent edb15cf commit 3ca6572
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class DataEntityMapperImpl implements DataEntityMapper {
private static DataEntityClassAndTypeDictionary TYPE_DICTIONARY = null;

private final DataSourceMapper dataSourceMapper;
private final DataSourceSafeMapper dataSourceSafeMapper;
private final OwnershipMapper ownershipMapper;
private final TagMapper tagMapper;
private final MetadataFieldValueMapper metadataFieldValueMapper;
Expand All @@ -86,7 +87,7 @@ public DataEntity mapPojo(final DataEntityDimensionsDto dto) {
.entityClasses(entityClasses.stream().map(this::mapEntityClass).toList())
.type(type)
.ownership(ownershipMapper.mapDtos(dto.getOwnership()))
.dataSource(dataSourceMapper.mapDto(new DataSourceDto(dto.getDataSource(), dto.getNamespace(), null)))
.dataSource(dataSourceSafeMapper.mapDto(new DataSourceDto(dto.getDataSource(), dto.getNamespace(), null)))
.dataEntityGroups(groups);

if (entityClasses.contains(DataEntityClassDto.DATA_SET)) {
Expand Down Expand Up @@ -250,7 +251,7 @@ public DataEntityDetails mapDtoDetails(final DataEntityDetailsDto dto) {
.type(type)
.status(dataEntityStatusMapper.mapStatus(pojo))
.ownership(ownershipMapper.mapDtos(dto.getOwnership()))
.dataSource(dataSourceMapper.mapDto(new DataSourceDto(dto.getDataSource(), dto.getNamespace(), null)))
.dataSource(dataSourceSafeMapper.mapDto(new DataSourceDto(dto.getDataSource(), dto.getNamespace(), null)))
.tags(tagMapper.mapToTagList(dto.getTags()))
.metadataFieldValues(metadataFieldValueMapper.mapDtos(dto.getMetadata()))
.terms(linkedTerms)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.opendatadiscovery.oddplatform.mapper;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.opendatadiscovery.oddplatform.api.contract.model.DataSourceSafe;
import org.opendatadiscovery.oddplatform.dto.DataSourceDto;

@Mapper(
config = MapperConfig.class,
uses = {NamespaceMapper.class}
)
public interface DataSourceSafeMapper {
@Mapping(source = "dataSource", target = ".")
DataSourceSafe mapDto(DataSourceDto dataSourceDto);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.opendatadiscovery.oddplatform.api.contract.model.DataSetStructure;
import org.opendatadiscovery.oddplatform.api.contract.model.DataSource;
import org.opendatadiscovery.oddplatform.api.contract.model.DataSourceFormData;
import org.opendatadiscovery.oddplatform.api.contract.model.DataSourceSafe;
import org.opendatadiscovery.oddplatform.api.contract.model.MetricSet;
import org.opendatadiscovery.oddplatform.api.contract.model.SearchFacetsData;
import org.opendatadiscovery.oddplatform.api.contract.model.SearchFilterState;
Expand Down Expand Up @@ -53,6 +54,12 @@ protected DataSource createDataSource(final DataSourceFormData dataSource) {
return ingestDataSource(dataSource);
}

protected DataSourceSafe createDataSourceSafeFromDataSource(final DataSource dataSource) {
return new DataSourceSafe(dataSource.getId(), dataSource.getOddrn(), dataSource.getName())
.description(dataSource.getDescription())
.namespace(dataSource.getNamespace());
}

private DataSource ingestDataSource(final DataSourceFormData dataSource) {
return webTestClient.post()
.uri("/api/datasources")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public void backwardsIncompatibleAlertIngestionTest() {
final long foundEntityId = extractIngestedEntityIdAndAssert(createdDataSource);

final var expectedDataEntityDetails = IngestionModelMapper
.buildExpectedBaseDEDetails(foundEntityId, datasetToIngest, createdDataSource)
.buildExpectedBaseDEDetails(foundEntityId, datasetToIngest,
createDataSourceSafeFromDataSource(createdDataSource))
.stats(new DataSetStats()
.consumersCount(0L)
.fieldsCount((long) datasetToIngest.getDataset().getFieldList().size())
Expand All @@ -98,7 +99,8 @@ public void backwardsIncompatibleAlertIngestionTest() {
ingestAndAssert(dataEntityList);

final var updatedExpectedDataEntityDetails = IngestionModelMapper
.buildExpectedBaseDEDetails(foundEntityId, datasetToIngest, createdDataSource)
.buildExpectedBaseDEDetails(foundEntityId, datasetToIngest,
createDataSourceSafeFromDataSource(createdDataSource))
.stats(new DataSetStats()
.consumersCount(0L)
.fieldsCount((long) datasetToIngest.getDataset().getFieldList().size())
Expand Down Expand Up @@ -152,7 +154,8 @@ public void failedJobAlertIngestionTest() {
final long jobId = extractIngestedEntityIdAndAssert(createdDataSource);

final DataEntityDetails expectedDataEntityDetails =
IngestionModelMapper.buildExpectedBaseDEDetails(jobId, job, createdDataSource);
IngestionModelMapper.buildExpectedBaseDEDetails(jobId, job,
createDataSourceSafeFromDataSource(createdDataSource));

assertDataEntityDetailsEqual(expectedDataEntityDetails, (expected, actual) -> {
assertThat(actual.getSourceList()).isEmpty();
Expand Down Expand Up @@ -218,7 +221,8 @@ public void failedDQTestAlertIngestionTest() {
.forEach((expectedOddrn, dataEntity) -> {
final long entityId = ingestionMap.get(expectedOddrn);
final DataEntityDetails expectedDetails =
IngestionModelMapper.buildExpectedBaseDEDetails(entityId, dataEntity, createdDataSource);
IngestionModelMapper.buildExpectedBaseDEDetails(entityId, dataEntity,
createDataSourceSafeFromDataSource(createdDataSource));

if (dataEntity.getDataset() != null) {
expectedDetails.setStats(new DataSetStats()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public void enumValuesComplexTest() {
final long foundEntityId = extractIngestedEntityIdAndAssert(createdDataSource);

final var expectedDataEntityDetails = IngestionModelMapper
.buildExpectedBaseDEDetails(foundEntityId, datasetToIngest, createdDataSource)
.buildExpectedBaseDEDetails(foundEntityId, datasetToIngest,
createDataSourceSafeFromDataSource(createdDataSource))
.stats(new DataSetStats()
.consumersCount(0L)
.fieldsCount((long) datasetToIngest.getDataset().getFieldList().size())
Expand Down Expand Up @@ -155,7 +156,8 @@ public void rewritingInternalEnumStateTest() {
final long foundEntityId = extractIngestedEntityIdAndAssert(createdDataSource);

final var expectedDataEntityDetails = IngestionModelMapper
.buildExpectedBaseDEDetails(foundEntityId, datasetToIngest, createdDataSource)
.buildExpectedBaseDEDetails(foundEntityId, datasetToIngest,
createDataSourceSafeFromDataSource(createdDataSource))
.stats(new DataSetStats()
.consumersCount(0L)
.fieldsCount((long) datasetToIngest.getDataset().getFieldList().size())
Expand Down Expand Up @@ -222,7 +224,8 @@ public void externalStatisticsTagStateIngestionTest() {
final long foundEntityId = extractIngestedEntityIdAndAssert(createdDataSource);

final var expectedDataEntityDetails = IngestionModelMapper
.buildExpectedBaseDEDetails(foundEntityId, datasetToIngest, createdDataSource)
.buildExpectedBaseDEDetails(foundEntityId, datasetToIngest,
createDataSourceSafeFromDataSource(createdDataSource))
.stats(new DataSetStats()
.consumersCount(0L)
.fieldsCount((long) datasetToIngest.getDataset().getFieldList().size())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public void simpleDatasetIngestionTest() {
final long foundEntityId = extractIngestedEntityIdAndAssert(createdDataSource);

final var expectedDataEntityDetails = IngestionModelMapper
.buildExpectedBaseDEDetails(foundEntityId, datasetToIngest, createdDataSource)
.buildExpectedBaseDEDetails(foundEntityId, datasetToIngest,
createDataSourceSafeFromDataSource(createdDataSource))
.stats(new DataSetStats()
.consumersCount(0L)
.fieldsCount((long) datasetToIngest.getDataset().getFieldList().size())
Expand Down Expand Up @@ -107,7 +108,8 @@ public void changeDatasetStructureTest() {
final long foundEntityId = extractIngestedEntityIdAndAssert(createdDataSource);

final var expectedDataEntityDetails = IngestionModelMapper
.buildExpectedBaseDEDetails(foundEntityId, datasetToIngest, createdDataSource)
.buildExpectedBaseDEDetails(foundEntityId, datasetToIngest,
createDataSourceSafeFromDataSource(createdDataSource))
.stats(new DataSetStats()
.consumersCount(0L)
.fieldsCount((long) datasetToIngest.getDataset().getFieldList().size())
Expand Down Expand Up @@ -142,7 +144,8 @@ public void changeDatasetStructureTest() {
ingestAndAssert(dataEntityList);

final var updatedExpectedDataEntityDetails = IngestionModelMapper
.buildExpectedBaseDEDetails(foundEntityId, datasetToIngest, createdDataSource)
.buildExpectedBaseDEDetails(foundEntityId, datasetToIngest,
createDataSourceSafeFromDataSource(createdDataSource))
.stats(new DataSetStats()
.consumersCount(0L)
.fieldsCount((long) datasetToIngest.getDataset().getFieldList().size())
Expand Down Expand Up @@ -213,7 +216,8 @@ public void updateHollowDatasetSchemaTest() {
assertThat(dataEntityId).isNotNull();

final DataEntityDetails expectedDetails = IngestionModelMapper
.buildExpectedBaseDEDetails(dataEntityId, dataEntity, createdDataSource);
.buildExpectedBaseDEDetails(dataEntityId, dataEntity,
createDataSourceSafeFromDataSource(createdDataSource));

if (dataEntity.getDataset() != null) {
expectedDetails.setStats(new DataSetStats()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ public void simpleLineageIngestionTest() {
assertThat(dataEntityId).isNotNull();

final DataEntityDetails expectedDetails = IngestionModelMapper
.buildExpectedBaseDEDetails(dataEntityId, dataEntity, createdDataSource);
.buildExpectedBaseDEDetails(dataEntityId, dataEntity,
createDataSourceSafeFromDataSource(createdDataSource));

if (dataEntity.getDataset() != null) {
expectedDetails.setStats(new DataSetStats()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public void simpleMetadataIngestionTest() {
final long foundEntityId = extractIngestedEntityIdAndAssert(createdDataSource);

final var expectedDataEntityDetails = IngestionModelMapper
.buildExpectedBaseDEDetails(foundEntityId, datasetToIngest, createdDataSource)
.buildExpectedBaseDEDetails(foundEntityId, datasetToIngest,
createDataSourceSafeFromDataSource(createdDataSource))
.stats(new DataSetStats()
.consumersCount(0L)
.fieldsCount((long) datasetToIngest.getDataset().getFieldList().size())
Expand Down Expand Up @@ -78,7 +79,8 @@ public void simpleMetadataIngestionTest() {
ingestAndAssert(dataEntityList);

final var expectedUpdatedDataEntityDetails = IngestionModelMapper
.buildExpectedBaseDEDetails(foundEntityId, datasetToIngest, createdDataSource)
.buildExpectedBaseDEDetails(foundEntityId, datasetToIngest,
createDataSourceSafeFromDataSource(createdDataSource))
.stats(new DataSetStats()
.consumersCount(0L)
.fieldsCount((long) datasetToIngest.getDataset().getFieldList().size())
Expand All @@ -95,7 +97,8 @@ public void simpleMetadataIngestionTest() {
ingestAndAssert(dataEntityList);

final var expectedEmptyMetadataDataEntityDetails = IngestionModelMapper
.buildExpectedBaseDEDetails(foundEntityId, datasetToIngest, createdDataSource)
.buildExpectedBaseDEDetails(foundEntityId, datasetToIngest,
createDataSourceSafeFromDataSource(createdDataSource))
.stats(new DataSetStats()
.consumersCount(0L)
.fieldsCount((long) datasetToIngest.getDataset().getFieldList().size())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.opendatadiscovery.oddplatform.api.contract.model.DataSetField;
import org.opendatadiscovery.oddplatform.api.contract.model.DataSetFieldStat;
import org.opendatadiscovery.oddplatform.api.contract.model.DataSetFieldType;
import org.opendatadiscovery.oddplatform.api.contract.model.DataSource;
import org.opendatadiscovery.oddplatform.api.contract.model.DataSourceSafe;
import org.opendatadiscovery.oddplatform.api.contract.model.DateTimeFieldStat;
import org.opendatadiscovery.oddplatform.api.contract.model.EnumValue;
import org.opendatadiscovery.oddplatform.api.contract.model.IntegerFieldStat;
Expand All @@ -33,7 +33,7 @@
public class IngestionModelMapper {
public static DataEntityDetails buildExpectedBaseDEDetails(final long entityId,
final DataEntity dataEntity,
final DataSource dataSource) {
final DataSourceSafe dataSource) {
return new DataEntityDetails()
.id(entityId)
.sourceCreatedAt(dataEntity.getCreatedAt())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ void setUp() {
new DateTimeMapperImpl()
)
),
new DataSourceSafeMapperImpl(
new NamespaceMapperImpl()
),
new OwnershipMapperImpl(
new OwnerMapperImpl(),
new TitleMapperImpl()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.opendatadiscovery.oddplatform.mapper.DataEntityRunMapperImpl;
import org.opendatadiscovery.oddplatform.mapper.DataEntityStatusMapper;
import org.opendatadiscovery.oddplatform.mapper.DataSourceMapperImpl;
import org.opendatadiscovery.oddplatform.mapper.DataSourceSafeMapperImpl;
import org.opendatadiscovery.oddplatform.mapper.DatasetFieldApiMapperImpl;
import org.opendatadiscovery.oddplatform.mapper.DatasetVersionMapperImpl;
import org.opendatadiscovery.oddplatform.mapper.DateTimeMapperImpl;
Expand Down Expand Up @@ -81,6 +82,9 @@ void setUp() {
new DateTimeMapperImpl()
)
),
new DataSourceSafeMapperImpl(
new NamespaceMapperImpl()
),
new OwnershipMapperImpl(
new OwnerMapperImpl(),
new TitleMapperImpl()
Expand Down
23 changes: 20 additions & 3 deletions odd-platform-specification/components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ components:
ownership:
$ref: '#/components/schemas/OwnershipList'
data_source:
$ref: '#/components/schemas/DataSource'
$ref: '#/components/schemas/DataSourceSafe'
entity_classes:
type: array
items:
Expand Down Expand Up @@ -1210,6 +1210,25 @@ components:
- oddrn
- name

DataSourceSafe:
type: object
properties:
id:
type: integer
format: int64
namespace:
$ref: '#/components/schemas/Namespace'
oddrn:
type: string
name:
type: string
description:
type: string
required:
- id
- oddrn
- name

DataSourceList:
type: object
properties:
Expand Down Expand Up @@ -1462,8 +1481,6 @@ components:
$ref: '#/components/schemas/BinaryFieldStat'
datetime_stats:
$ref: '#/components/schemas/DateTimeFieldStat'
required:
- name

BooleanFieldStat:
type: object
Expand Down

0 comments on commit 3ca6572

Please sign in to comment.