-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1416 - added datasetField to term usage count. (#1457)
- Loading branch information
Showing
10 changed files
with
270 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...latform-api/src/main/java/org/opendatadiscovery/oddplatform/dto/DatasetFieldTermsDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
9 changes: 9 additions & 0 deletions
9
...rm-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/DatasetFieldListMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
50 changes: 50 additions & 0 deletions
50
...pi/src/main/java/org/opendatadiscovery/oddplatform/mapper/DatasetFieldListMapperImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
.../java/org/opendatadiscovery/oddplatform/repository/mapper/DatasetFieldTermsDtoMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.