diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/controller/DatasetController.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/controller/DatasetController.java index eb63f633a..fd58b1f60 100644 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/controller/DatasetController.java +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/controller/DatasetController.java @@ -5,11 +5,8 @@ import org.opendatadiscovery.oddplatform.api.contract.model.DataSetStructure; import org.opendatadiscovery.oddplatform.api.contract.model.DataSetVersionDiffList; import org.opendatadiscovery.oddplatform.api.contract.model.DatasetRelationshipList; -import org.opendatadiscovery.oddplatform.api.contract.model.ERDRelationshipDetailsList; -import org.opendatadiscovery.oddplatform.api.contract.model.GraphRelationshipDetailsList; +import org.opendatadiscovery.oddplatform.api.contract.model.RelationshipsType; import org.opendatadiscovery.oddplatform.service.DatasetVersionService; -import org.opendatadiscovery.oddplatform.service.ERDRelationshipsService; -import org.opendatadiscovery.oddplatform.service.GraphRelationshipsService; import org.opendatadiscovery.oddplatform.service.RelationshipsService; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RestController; @@ -21,8 +18,6 @@ public class DatasetController implements DataSetApi { private final DatasetVersionService datasetVersionService; private final RelationshipsService relationshipsService; - private final ERDRelationshipsService erdRelationshipsService; - private final GraphRelationshipsService graphRelationshipsService; @Override public Mono> getDataSetStructureByVersionId( @@ -56,26 +51,9 @@ public Mono> getDataSetStructureDiff(fina @Override public Mono> getDataSetRelationships(final Long dataEntityId, + final RelationshipsType type, final ServerWebExchange exchange) { - return relationshipsService.getRelationsByDatasetId(dataEntityId) - .map(ResponseEntity::ok); - } - - @Override - public Mono> - getDataSetErdRelationshipsById(final Long dataEntityId, - final Long relationshipsId, - final ServerWebExchange exchange) { - return erdRelationshipsService.getDataSetErdRelationshipsById(dataEntityId, relationshipsId) - .map(ResponseEntity::ok); - } - - @Override - public Mono> - getDataSetGraphRelationshipsById(final Long dataEntityId, - final Long relationshipsId, - final ServerWebExchange exchange) { - return graphRelationshipsService.getDataSetGraphRelationshipsById(relationshipsId) + return relationshipsService.getRelationsByDatasetId(dataEntityId, type) .map(ResponseEntity::ok); } } diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/controller/RelationshipController.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/controller/RelationshipController.java new file mode 100644 index 000000000..50e29dfb2 --- /dev/null +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/controller/RelationshipController.java @@ -0,0 +1,35 @@ +package org.opendatadiscovery.oddplatform.controller; + +import lombok.RequiredArgsConstructor; +import org.opendatadiscovery.oddplatform.api.contract.api.RelationshipApi; +import org.opendatadiscovery.oddplatform.api.contract.model.DatasetRelationship; +import org.opendatadiscovery.oddplatform.api.contract.model.DatasetRelationshipList; +import org.opendatadiscovery.oddplatform.api.contract.model.RelationshipsType; +import org.opendatadiscovery.oddplatform.service.RelationshipsService; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Mono; + +@RestController +@RequiredArgsConstructor +public class RelationshipController implements RelationshipApi { + private final RelationshipsService relationshipsService; + + @Override + public Mono> getRelationships(final Integer page, + final Integer size, + final RelationshipsType type, + final String query, + final ServerWebExchange exchange) { + return relationshipsService.getRelationships(page, size, type, query) + .map(ResponseEntity::ok); + } + + @Override + public Mono> getRelationshipsById(final Long relationshipId, + final ServerWebExchange exchange) { + return relationshipsService.getRelationshipById(relationshipId) + .map(ResponseEntity::ok); + } +} diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/dto/RelationshipDto.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/dto/RelationshipDto.java index d828dbf3e..09904904a 100644 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/dto/RelationshipDto.java +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/dto/RelationshipDto.java @@ -1,10 +1,14 @@ package org.opendatadiscovery.oddplatform.dto; import org.opendatadiscovery.oddplatform.model.tables.pojos.DataEntityPojo; -import org.opendatadiscovery.oddplatform.model.tables.pojos.RelationshipPojo; +import org.opendatadiscovery.oddplatform.model.tables.pojos.ErdRelationshipDetailsPojo; +import org.opendatadiscovery.oddplatform.model.tables.pojos.GraphRelationshipPojo; +import org.opendatadiscovery.oddplatform.model.tables.pojos.RelationshipsPojo; -public record RelationshipDto(RelationshipPojo relationshipPojo, +public record RelationshipDto(RelationshipsPojo relationshipPojo, DataEntityPojo sourceDataEntity, DataEntityPojo targetDataEntity, + ErdRelationshipDetailsPojo erdRelationshipDetailsPojo, + GraphRelationshipPojo graphRelationshipPojo, boolean isErd) { } diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ErdRelationShipMapper.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ErdRelationShipMapper.java deleted file mode 100644 index bb78d9fa5..000000000 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ErdRelationShipMapper.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.opendatadiscovery.oddplatform.mapper; - -import java.util.List; -import org.mapstruct.Mapper; -import org.opendatadiscovery.oddplatform.api.contract.model.ERDRelationshipDetails; -import org.opendatadiscovery.oddplatform.model.tables.pojos.ErdRelationshipPojo; - -@Mapper(config = MapperConfig.class, - uses = { - DateTimeMapper.class, - DataEntityMapper.class, - }) -public abstract class ErdRelationShipMapper { - public List pojoListToDetailsList(final List erds) { - return erds.stream() - .map(erd -> new ERDRelationshipDetails() - .erdRelationshipsId(erd.getId()) - .sourceDatasetFieldOddrn(erd.getSourceDatasetFieldOddrn()) - .targetDatasetFieldOddrn(erd.getTargetDatasetFieldOddrn()) - .isIdentifying(erd.getIsIdentifying()) - .cardinality(erd.getCardinality())) - .toList(); - } -} \ No newline at end of file diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ErdRelationshipMapper.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ErdRelationshipMapper.java new file mode 100644 index 000000000..49e14b513 --- /dev/null +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ErdRelationshipMapper.java @@ -0,0 +1,31 @@ +package org.opendatadiscovery.oddplatform.mapper; + +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import org.opendatadiscovery.oddplatform.api.contract.model.ERDRelationshipDetails; +import org.opendatadiscovery.oddplatform.api.contract.model.ERDRelationshipPairs; +import org.opendatadiscovery.oddplatform.model.tables.pojos.ErdRelationshipDetailsPojo; +import org.springframework.stereotype.Component; +import org.thymeleaf.util.ArrayUtils; + +@Component +public class ErdRelationshipMapper { + public ERDRelationshipDetails mapPojoToDetails(final ErdRelationshipDetailsPojo erd) { + return new ERDRelationshipDetails() + .erdRelationshipsId(erd.getId()) + .fieldsPairs(mapPairs(erd.getSourceDatasetFieldOddrn(), erd.getTargetDatasetFieldOddrn())) + .isIdentifying(erd.getIsIdentifying()) + .cardinality(erd.getCardinality()); + } + + private List mapPairs(final String[] source, final String[] target) { + if (ArrayUtils.isEmpty(source)) { + return null; + } + + return IntStream.range(0, source.length).mapToObj(i -> new ERDRelationshipPairs() + .sourceDatasetFieldOddrn(source[i]) + .targetDatasetFieldOddrn(target[i])).collect(Collectors.toList()); + } +} \ No newline at end of file diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/GraphRelationshipMapper.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/GraphRelationshipMapper.java index ff0c8ac95..c168b7fc0 100644 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/GraphRelationshipMapper.java +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/GraphRelationshipMapper.java @@ -6,40 +6,29 @@ import java.util.List; import java.util.Map; import org.jooq.JSONB; -import org.mapstruct.Mapper; -import org.opendatadiscovery.oddplatform.api.contract.model.DatasetRelationship; import org.opendatadiscovery.oddplatform.api.contract.model.GraphRelationshipAttributes; import org.opendatadiscovery.oddplatform.api.contract.model.GraphRelationshipDetails; -import org.opendatadiscovery.oddplatform.api.contract.model.GraphRelationshipDetailsList; import org.opendatadiscovery.oddplatform.model.tables.pojos.GraphRelationshipPojo; +import org.springframework.stereotype.Component; -@Mapper(config = MapperConfig.class, - uses = { - DateTimeMapper.class, - DataEntityMapper.class, - }) -public abstract class GraphRelationshipMapper { - public GraphRelationshipDetailsList mapToDetails(final DatasetRelationship relationship, - final List graphList) { - return new GraphRelationshipDetailsList() - .datasetRelationship(relationship) - .items(mapPojoListToDetailsList(graphList)); - } - - private List mapPojoListToDetailsList(final List graphList) { - return graphList.stream() - .map(this::mapPojoToDetails) - .toList(); - } - +@Component +public class GraphRelationshipMapper { public GraphRelationshipDetails mapPojoToDetails(final GraphRelationshipPojo pojo) { + if (pojo == null) { + return null; + } + return new GraphRelationshipDetails() - .graphRelationshipsId(pojo.getId()) - .isDirected(pojo.getIsDerected()) + .graphRelationshipId(pojo.getId()) + .isDirected(pojo.getIsDirected()) .attributes(mapGraphAttributes(pojo.getSpecificAttributes())); } private List mapGraphAttributes(final JSONB specificAttributes) { + if (specificAttributes == null) { + return List.of(); + } + final ObjectReader reader = new ObjectMapper().readerFor(Map.class); try { diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/RelationshipMapper.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/RelationshipMapper.java index 3fd303e12..8435d9040 100644 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/RelationshipMapper.java +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/RelationshipMapper.java @@ -2,19 +2,21 @@ import java.util.List; import java.util.stream.Collectors; -import org.mapstruct.Mapper; +import lombok.RequiredArgsConstructor; import org.opendatadiscovery.oddplatform.api.contract.model.DatasetRelationship; import org.opendatadiscovery.oddplatform.api.contract.model.DatasetRelationshipList; import org.opendatadiscovery.oddplatform.api.contract.model.DatasetRelationshipType; import org.opendatadiscovery.oddplatform.api.contract.model.PageInfo; import org.opendatadiscovery.oddplatform.dto.RelationshipDto; +import org.opendatadiscovery.oddplatform.utils.Page; +import org.springframework.stereotype.Component; + +@RequiredArgsConstructor +@Component +public class RelationshipMapper { + private final ErdRelationshipMapper erdRelationshipMapper; + private final GraphRelationshipMapper graphRelationshipMapper; -@Mapper(config = MapperConfig.class, - uses = { - DateTimeMapper.class, - DataEntityMapper.class, - }) -public abstract class RelationshipMapper { public DatasetRelationshipList mapListToRelationshipList(final List relationshipDtos) { return new DatasetRelationshipList() .items(mapToRelationshipList(relationshipDtos)) @@ -36,6 +38,14 @@ public DatasetRelationship mapToDatasetRelationship(final RelationshipDto item) .targetDatasetOddrn(item.relationshipPojo().getTargetDatasetOddrn()) .sourceDataEntityId(item.sourceDataEntity() != null ? item.sourceDataEntity().getId() : null) .targetDataEntityId(item.targetDataEntity() != null ? item.targetDataEntity().getId() : null) - .type(item.isErd() ? DatasetRelationshipType.ERD : DatasetRelationshipType.GRAPH); + .type(item.isErd() ? DatasetRelationshipType.ERD : DatasetRelationshipType.GRAPH) + .erdRelationship(erdRelationshipMapper.mapPojoToDetails(item.erdRelationshipDetailsPojo())) + .graphRelationship(graphRelationshipMapper.mapPojoToDetails(item.graphRelationshipPojo())); + } + + public DatasetRelationshipList mapListToRelationshipPage(final Page relationshipDtoPage) { + return new DatasetRelationshipList() + .items(mapToRelationshipList(relationshipDtoPage.getData())) + .pageInfo(new PageInfo().total((relationshipDtoPage.getTotal())).hasNext(relationshipDtoPage.isHasNext())); } } diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ingestion/DatasetERDRelationIngestionMapper.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ingestion/DatasetERDRelationIngestionMapper.java index d905ee778..19439afe0 100644 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ingestion/DatasetERDRelationIngestionMapper.java +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ingestion/DatasetERDRelationIngestionMapper.java @@ -4,12 +4,12 @@ import java.util.Map; import org.opendatadiscovery.oddplatform.ingestion.contract.model.ERDRelationship; import org.opendatadiscovery.oddplatform.ingestion.contract.model.Relationship; -import org.opendatadiscovery.oddplatform.model.tables.pojos.ErdRelationshipPojo; -import org.opendatadiscovery.oddplatform.model.tables.pojos.RelationshipPojo; +import org.opendatadiscovery.oddplatform.model.tables.pojos.ErdRelationshipDetailsPojo; +import org.opendatadiscovery.oddplatform.model.tables.pojos.RelationshipsPojo; public interface DatasetERDRelationIngestionMapper { - Map> mapERDRelations(final List erdRelationship, - final Long dataSourceId); + Map mapERDRelations(final List erdRelationship, + final Long dataSourceId); - List mapERDRelation(ERDRelationship field); + ErdRelationshipDetailsPojo mapERDRelation(ERDRelationship field); } diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ingestion/DatasetERDRelationIngestionMapperImpl.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ingestion/DatasetERDRelationIngestionMapperImpl.java index 63f33737e..ab9a621a8 100644 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ingestion/DatasetERDRelationIngestionMapperImpl.java +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ingestion/DatasetERDRelationIngestionMapperImpl.java @@ -1,6 +1,5 @@ package org.opendatadiscovery.oddplatform.mapper.ingestion; -import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -8,8 +7,8 @@ import org.apache.commons.collections4.CollectionUtils; import org.opendatadiscovery.oddplatform.ingestion.contract.model.ERDRelationship; import org.opendatadiscovery.oddplatform.ingestion.contract.model.Relationship; -import org.opendatadiscovery.oddplatform.model.tables.pojos.ErdRelationshipPojo; -import org.opendatadiscovery.oddplatform.model.tables.pojos.RelationshipPojo; +import org.opendatadiscovery.oddplatform.model.tables.pojos.ErdRelationshipDetailsPojo; +import org.opendatadiscovery.oddplatform.model.tables.pojos.RelationshipsPojo; import org.springframework.stereotype.Component; @Component @@ -18,8 +17,9 @@ public class DatasetERDRelationIngestionMapperImpl implements DatasetERDRelation private final DatasetRelationIngestionMapper relationIngestionMapper; @Override - public Map> mapERDRelations(final List relationships, - final Long dataSourceId) { + public Map + mapERDRelations(final List relationships, + final Long dataSourceId) { if (CollectionUtils.isEmpty(relationships)) { return Map.of(); } @@ -27,21 +27,15 @@ public Map> mapERDRelations(final Li return relationships.stream() .filter(item -> item.getErdRelationship() != null) .collect(Collectors.toMap(item -> relationIngestionMapper.mapToPojo(item, dataSourceId), - relationship -> new ArrayList<>(mapERDRelation(relationship.getErdRelationship())), (a, b) -> b)); + relationship -> mapERDRelation(relationship.getErdRelationship()), (a, b) -> b)); } @Override - public List mapERDRelation(final ERDRelationship erd) { - final List erdRelationshipPojos = new ArrayList<>(); - - for (int i = 0; i < erd.getSourceDatasetFieldOddrnsList().size(); i++) { - erdRelationshipPojos.add(new ErdRelationshipPojo() - .setSourceDatasetFieldOddrn(erd.getSourceDatasetFieldOddrnsList().get(i)) - .setTargetDatasetFieldOddrn(erd.getTargetDatasetFieldOddrnsList().get(i)) - .setCardinality(erd.getCardinality().getValue()) - .setIsIdentifying(erd.getIsIdentifying())); - } - - return erdRelationshipPojos; + public ErdRelationshipDetailsPojo mapERDRelation(final ERDRelationship erd) { + return new ErdRelationshipDetailsPojo() + .setSourceDatasetFieldOddrn(erd.getSourceDatasetFieldOddrnsList().toArray(String[]::new)) + .setTargetDatasetFieldOddrn(erd.getTargetDatasetFieldOddrnsList().toArray(String[]::new)) + .setCardinality(erd.getCardinality().getValue()) + .setIsIdentifying(erd.getIsIdentifying()); } } diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ingestion/DatasetGraphRelationIngestionMapper.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ingestion/DatasetGraphRelationIngestionMapper.java index eba402a26..74c2fa423 100644 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ingestion/DatasetGraphRelationIngestionMapper.java +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ingestion/DatasetGraphRelationIngestionMapper.java @@ -5,10 +5,10 @@ import org.opendatadiscovery.oddplatform.ingestion.contract.model.GraphRelationship; import org.opendatadiscovery.oddplatform.ingestion.contract.model.Relationship; import org.opendatadiscovery.oddplatform.model.tables.pojos.GraphRelationshipPojo; -import org.opendatadiscovery.oddplatform.model.tables.pojos.RelationshipPojo; +import org.opendatadiscovery.oddplatform.model.tables.pojos.RelationshipsPojo; public interface DatasetGraphRelationIngestionMapper { - Map mapGraphRelations(final List relationships, + Map mapGraphRelations(final List relationships, final Long dataSourceId); GraphRelationshipPojo mapGraphRelation(final GraphRelationship field); diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ingestion/DatasetGraphRelationIngestionMapperImpl.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ingestion/DatasetGraphRelationIngestionMapperImpl.java index 0f10ca4c5..88926de0a 100644 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ingestion/DatasetGraphRelationIngestionMapperImpl.java +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ingestion/DatasetGraphRelationIngestionMapperImpl.java @@ -9,7 +9,7 @@ import org.opendatadiscovery.oddplatform.ingestion.contract.model.GraphRelationship; import org.opendatadiscovery.oddplatform.ingestion.contract.model.Relationship; import org.opendatadiscovery.oddplatform.model.tables.pojos.GraphRelationshipPojo; -import org.opendatadiscovery.oddplatform.model.tables.pojos.RelationshipPojo; +import org.opendatadiscovery.oddplatform.model.tables.pojos.RelationshipsPojo; import org.opendatadiscovery.oddplatform.utils.JSONSerDeUtils; import org.springframework.stereotype.Component; @@ -19,7 +19,7 @@ public class DatasetGraphRelationIngestionMapperImpl implements DatasetGraphRela private final DatasetRelationIngestionMapper relationIngestionMapper; @Override - public Map mapGraphRelations(final List relationships, + public Map mapGraphRelations(final List relationships, final Long dataSourceId) { if (CollectionUtils.isEmpty(relationships)) { return Map.of(); @@ -34,7 +34,7 @@ public Map mapGraphRelations(final List @Override public GraphRelationshipPojo mapGraphRelation(final GraphRelationship graphRelationship) { return new GraphRelationshipPojo() - .setIsDerected(graphRelationship.getIsDirected()) + .setIsDirected(graphRelationship.getIsDirected()) .setSpecificAttributes(JSONB.valueOf(JSONSerDeUtils.serializeJson(graphRelationship.getAttributes()))); } } diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ingestion/DatasetRelationIngestionMapper.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ingestion/DatasetRelationIngestionMapper.java index fc7a330fc..3675b5437 100644 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ingestion/DatasetRelationIngestionMapper.java +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ingestion/DatasetRelationIngestionMapper.java @@ -1,8 +1,8 @@ package org.opendatadiscovery.oddplatform.mapper.ingestion; import org.opendatadiscovery.oddplatform.ingestion.contract.model.Relationship; -import org.opendatadiscovery.oddplatform.model.tables.pojos.RelationshipPojo; +import org.opendatadiscovery.oddplatform.model.tables.pojos.RelationshipsPojo; public interface DatasetRelationIngestionMapper { - RelationshipPojo mapToPojo(final Relationship relationship, final Long dataSourceId); + RelationshipsPojo mapToPojo(final Relationship relationship, final Long dataSourceId); } diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ingestion/DatasetRelationIngestionMapperImpl.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ingestion/DatasetRelationIngestionMapperImpl.java index a4797b26f..0beaef992 100644 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ingestion/DatasetRelationIngestionMapperImpl.java +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ingestion/DatasetRelationIngestionMapperImpl.java @@ -3,7 +3,7 @@ import lombok.RequiredArgsConstructor; import org.opendatadiscovery.oddplatform.dto.RelationshipStatusDto; import org.opendatadiscovery.oddplatform.ingestion.contract.model.Relationship; -import org.opendatadiscovery.oddplatform.model.tables.pojos.RelationshipPojo; +import org.opendatadiscovery.oddplatform.model.tables.pojos.RelationshipsPojo; import org.opendatadiscovery.oddplatform.service.ingestion.util.DateTimeUtil; import org.springframework.stereotype.Component; @@ -11,12 +11,12 @@ @RequiredArgsConstructor public class DatasetRelationIngestionMapperImpl implements DatasetRelationIngestionMapper { @Override - public RelationshipPojo mapToPojo(final Relationship relationship, final Long dataSourceId) { + public RelationshipsPojo mapToPojo(final Relationship relationship, final Long dataSourceId) { if (relationship == null) { return null; } - final RelationshipPojo relationshipPojo = new RelationshipPojo(); + final RelationshipsPojo relationshipPojo = new RelationshipsPojo(); relationshipPojo.setName(relationship.getName()); relationshipPojo.setDataSourceId(dataSourceId); diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveERDRelationshipsRepository.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveERDRelationshipsRepository.java index 921f3f974..c3b16aa77 100644 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveERDRelationshipsRepository.java +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveERDRelationshipsRepository.java @@ -1,11 +1,9 @@ package org.opendatadiscovery.oddplatform.repository.reactive; import java.util.List; -import org.opendatadiscovery.oddplatform.model.tables.pojos.ErdRelationshipPojo; +import org.opendatadiscovery.oddplatform.model.tables.pojos.ErdRelationshipDetailsPojo; import reactor.core.publisher.Mono; -public interface ReactiveERDRelationshipsRepository extends ReactiveCRUDRepository { - Mono deleteByRelationId(final Long relationshipId); - - Mono> findERDSByRelationIds(final List relationshipId); +public interface ReactiveERDRelationshipsRepository extends ReactiveCRUDRepository { + Mono> findERDSByRelationIds(final List relationshipId); } diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveERDRelationshipsRepositoryImpl.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveERDRelationshipsRepositoryImpl.java index 2e6f2af6a..312c80462 100644 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveERDRelationshipsRepositoryImpl.java +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveERDRelationshipsRepositoryImpl.java @@ -6,47 +6,39 @@ import org.jooq.SelectConditionStep; import org.jooq.impl.DSL; import org.opendatadiscovery.oddplatform.annotation.ReactiveTransactional; -import org.opendatadiscovery.oddplatform.model.tables.pojos.ErdRelationshipPojo; -import org.opendatadiscovery.oddplatform.model.tables.records.ErdRelationshipRecord; +import org.opendatadiscovery.oddplatform.model.tables.pojos.ErdRelationshipDetailsPojo; +import org.opendatadiscovery.oddplatform.model.tables.records.ErdRelationshipDetailsRecord; import org.opendatadiscovery.oddplatform.repository.util.JooqQueryHelper; import org.opendatadiscovery.oddplatform.repository.util.JooqReactiveOperations; import org.opendatadiscovery.oddplatform.repository.util.JooqRecordHelper; import org.springframework.stereotype.Repository; import reactor.core.publisher.Mono; -import static org.opendatadiscovery.oddplatform.model.Tables.ERD_RELATIONSHIP; +import static org.opendatadiscovery.oddplatform.model.Tables.ERD_RELATIONSHIP_DETAILS; @Slf4j @Repository public class ReactiveERDRelationshipsRepositoryImpl - extends ReactiveAbstractCRUDRepository + extends ReactiveAbstractCRUDRepository implements ReactiveERDRelationshipsRepository { private final JooqRecordHelper jooqRecordHelper; public ReactiveERDRelationshipsRepositoryImpl(final JooqReactiveOperations jooqReactiveOperations, final JooqQueryHelper jooqQueryHelper, final JooqRecordHelper jooqRecordHelper) { - super(jooqReactiveOperations, jooqQueryHelper, ERD_RELATIONSHIP, ErdRelationshipPojo.class); + super(jooqReactiveOperations, jooqQueryHelper, ERD_RELATIONSHIP_DETAILS, ErdRelationshipDetailsPojo.class); this.jooqRecordHelper = jooqRecordHelper; } @Override - @ReactiveTransactional - public Mono deleteByRelationId(final Long relationshipId) { - return jooqReactiveOperations.mono(DSL.deleteFrom(ERD_RELATIONSHIP) - .where(ERD_RELATIONSHIP.RELATIONSHIP_ID.eq(relationshipId))) - .then(Mono.empty()); - } - - @Override - public Mono> findERDSByRelationIds(final List relationshipId) { + public Mono> findERDSByRelationIds(final List relationshipId) { final SelectConditionStep query = DSL.select() - .from(ERD_RELATIONSHIP) - .where(ERD_RELATIONSHIP.RELATIONSHIP_ID.in(relationshipId)); + .from(ERD_RELATIONSHIP_DETAILS) + .where(ERD_RELATIONSHIP_DETAILS.RELATIONSHIP_ID.in(relationshipId)); return jooqReactiveOperations.flux(query) - .map(r -> r.into(ErdRelationshipPojo.class)) + .map(r -> r.into(ErdRelationshipDetailsPojo.class)) .collectList(); } } \ No newline at end of file diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveRelationshipsRepository.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveRelationshipsRepository.java index e6a266236..478d884f9 100644 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveRelationshipsRepository.java +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveRelationshipsRepository.java @@ -1,18 +1,23 @@ package org.opendatadiscovery.oddplatform.repository.reactive; import java.util.Set; +import org.opendatadiscovery.oddplatform.api.contract.model.RelationshipsType; import org.opendatadiscovery.oddplatform.dto.RelationshipDto; -import org.opendatadiscovery.oddplatform.model.tables.pojos.RelationshipPojo; +import org.opendatadiscovery.oddplatform.model.tables.pojos.RelationshipsPojo; +import org.opendatadiscovery.oddplatform.utils.Page; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; -public interface ReactiveRelationshipsRepository extends ReactiveCRUDRepository { +public interface ReactiveRelationshipsRepository extends ReactiveCRUDRepository { - Flux getRelationshipByDatasetOddrns(final Set oddrns); + Flux getRelationshipByDatasetOddrns(final Set oddrns); - Flux getRelationshipByDataSourceId(final Long dataSourceId); - - Flux getRelationsByDatasetId(final Long dataEntityId); + Flux getRelationshipByDataSourceId(final Long dataSourceId); Mono getRelationshipById(final Long relationshipId); + + Flux getRelationsByDatasetIdAndType(final Long dataEntityId, final RelationshipsType type); + + Mono> getRelationships(final Integer page, final Integer size, + final String inputQuery, final RelationshipsType type); } diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveRelationshipsRepositoryImpl.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveRelationshipsRepositoryImpl.java index c38c4b857..81d2e5545 100644 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveRelationshipsRepositoryImpl.java +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/reactive/ReactiveRelationshipsRepositoryImpl.java @@ -1,35 +1,48 @@ package org.opendatadiscovery.oddplatform.repository.reactive; +import java.util.Arrays; +import java.util.List; import java.util.Set; +import java.util.stream.Stream; import lombok.extern.slf4j.Slf4j; +import org.jooq.Field; import org.jooq.Record; import org.jooq.Record1; +import org.jooq.ResultQuery; +import org.jooq.Select; import org.jooq.SelectConditionStep; -import org.jooq.SelectOrderByStep; +import org.jooq.SelectOnConditionStep; +import org.jooq.SortOrder; import org.jooq.Table; import org.jooq.impl.DSL; +import org.opendatadiscovery.oddplatform.api.contract.model.RelationshipsType; import org.opendatadiscovery.oddplatform.dto.RelationshipDto; import org.opendatadiscovery.oddplatform.dto.RelationshipStatusDto; import org.opendatadiscovery.oddplatform.model.tables.pojos.DataEntityPojo; -import org.opendatadiscovery.oddplatform.model.tables.pojos.RelationshipPojo; +import org.opendatadiscovery.oddplatform.model.tables.pojos.ErdRelationshipDetailsPojo; +import org.opendatadiscovery.oddplatform.model.tables.pojos.GraphRelationshipPojo; +import org.opendatadiscovery.oddplatform.model.tables.pojos.RelationshipsPojo; import org.opendatadiscovery.oddplatform.model.tables.records.DataEntityRecord; -import org.opendatadiscovery.oddplatform.model.tables.records.RelationshipRecord; +import org.opendatadiscovery.oddplatform.model.tables.records.RelationshipsRecord; import org.opendatadiscovery.oddplatform.repository.util.JooqQueryHelper; import org.opendatadiscovery.oddplatform.repository.util.JooqReactiveOperations; import org.opendatadiscovery.oddplatform.repository.util.JooqRecordHelper; +import org.opendatadiscovery.oddplatform.repository.util.OrderByField; +import org.opendatadiscovery.oddplatform.utils.Page; import org.springframework.stereotype.Repository; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import static org.jooq.impl.DSL.select; import static org.opendatadiscovery.oddplatform.model.Tables.DATA_ENTITY; -import static org.opendatadiscovery.oddplatform.model.Tables.ERD_RELATIONSHIP; -import static org.opendatadiscovery.oddplatform.model.Tables.RELATIONSHIP; +import static org.opendatadiscovery.oddplatform.model.Tables.ERD_RELATIONSHIP_DETAILS; +import static org.opendatadiscovery.oddplatform.model.Tables.GRAPH_RELATIONSHIP; +import static org.opendatadiscovery.oddplatform.model.Tables.RELATIONSHIPS; @Slf4j @Repository public class ReactiveRelationshipsRepositoryImpl - extends ReactiveAbstractSoftDeleteCRUDRepository + extends ReactiveAbstractSoftDeleteCRUDRepository implements ReactiveRelationshipsRepository { private static final String DATA_ENTITY_CTE = "data_entity_cte"; private static final String SOURCE_DATA_ENTITY = "source_data_entity"; @@ -41,29 +54,29 @@ public class ReactiveRelationshipsRepositoryImpl public ReactiveRelationshipsRepositoryImpl(final JooqReactiveOperations jooqReactiveOperations, final JooqQueryHelper jooqQueryHelper, final JooqRecordHelper jooqRecordHelper) { - super(jooqReactiveOperations, jooqQueryHelper, RELATIONSHIP, RelationshipPojo.class); + super(jooqReactiveOperations, jooqQueryHelper, RELATIONSHIPS, RelationshipsPojo.class); this.jooqRecordHelper = jooqRecordHelper; } @Override - public Flux getRelationshipByDatasetOddrns(final Set oddrns) { - return jooqReactiveOperations.flux(DSL.select(RELATIONSHIP) - .from(RELATIONSHIP) - .where(RELATIONSHIP.SOURCE_DATASET_ODDRN.in(oddrns).or(RELATIONSHIP.TARGET_DATASET_ODDRN.in(oddrns)))) - .map(r -> r.into(RelationshipPojo.class)); + public Flux getRelationshipByDatasetOddrns(final Set oddrns) { + return jooqReactiveOperations.flux(DSL.select(RELATIONSHIPS) + .from(RELATIONSHIPS) + .where(RELATIONSHIPS.SOURCE_DATASET_ODDRN.in(oddrns).or(RELATIONSHIPS.TARGET_DATASET_ODDRN.in(oddrns)))) + .map(r -> r.into(RelationshipsPojo.class)); } @Override - public Flux getRelationshipByDataSourceId(final Long dataSourceId) { - return jooqReactiveOperations.flux(select(RELATIONSHIP) - .from(RELATIONSHIP) - .where(RELATIONSHIP.DATA_SOURCE_ID.eq(dataSourceId))) - .map(r -> r.into(RelationshipPojo.class)); + public Flux getRelationshipByDataSourceId(final Long dataSourceId) { + return jooqReactiveOperations.flux(select(RELATIONSHIPS) + .from(RELATIONSHIPS) + .where(RELATIONSHIPS.DATA_SOURCE_ID.eq(dataSourceId))) + .map(r -> r.into(RelationshipsPojo.class)); } @Override - public Flux getRelationsByDatasetId(final Long dataEntityId) { + public Flux getRelationsByDatasetIdAndType(final Long dataEntityId, final RelationshipsType type) { final SelectConditionStep> dataEntitySelect = DSL.select(DATA_ENTITY.ODDRN) .from(DATA_ENTITY) .where(DATA_ENTITY.ID.eq(dataEntityId)); @@ -72,28 +85,32 @@ public Flux getRelationsByDatasetId(final Long dataEntityId) { final Table srcDataEntity = DATA_ENTITY.asTable(SOURCE_DATA_ENTITY); final Table trgtDataEntity = DATA_ENTITY.asTable(TARGET_DATA_ENTITY); - final SelectOrderByStep query = - DSL.select(RELATIONSHIP.asterisk(), srcDataEntity.asterisk(), trgtDataEntity.asterisk()) - .select(DSL.exists( - DSL.select().from(ERD_RELATIONSHIP).where(ERD_RELATIONSHIP.RELATIONSHIP_ID.eq(RELATIONSHIP.ID))) - .as(IS_ERD_RELATION) - ) - .from(dataEntityCTE) - .join(RELATIONSHIP) - .on((dataEntityCTE.field(DATA_ENTITY.ODDRN).eq(RELATIONSHIP.SOURCE_DATASET_ODDRN) - .or(dataEntityCTE.field(DATA_ENTITY.ODDRN).eq(RELATIONSHIP.TARGET_DATASET_ODDRN) - )) - .and(RELATIONSHIP.RELATIONSHIP_STATUS.notEqual(RelationshipStatusDto.DELETED.getId())) - ) - .leftJoin(srcDataEntity) - .on(RELATIONSHIP.SOURCE_DATASET_ODDRN.eq(srcDataEntity.field(DATA_ENTITY.ODDRN))) - .leftJoin(trgtDataEntity) - .on(RELATIONSHIP.TARGET_DATASET_ODDRN.eq(trgtDataEntity.field(DATA_ENTITY.ODDRN))); + final SelectOnConditionStep relationshipGenericQuery = + getRelationshipGenericQuery(srcDataEntity, trgtDataEntity); + + final SelectOnConditionStep joinStep = relationshipGenericQuery + .join(dataEntityCTE) + .on((dataEntityCTE.field(DATA_ENTITY.ODDRN).eq(RELATIONSHIPS.SOURCE_DATASET_ODDRN) + .or(dataEntityCTE.field(DATA_ENTITY.ODDRN).eq(RELATIONSHIPS.TARGET_DATASET_ODDRN))) + .and(RELATIONSHIPS.RELATIONSHIP_STATUS.notEqual(RelationshipStatusDto.DELETED.getId())) + ); + + final ResultQuery query = switch (type) { + case ERD -> joinStep.where(DSL.notExists( + select().from(GRAPH_RELATIONSHIP) + .where(GRAPH_RELATIONSHIP.RELATIONSHIP_ID.eq(RELATIONSHIPS.ID)))); + case GRAPH -> joinStep.where(DSL.notExists( + select().from(ERD_RELATIONSHIP_DETAILS) + .where(ERD_RELATIONSHIP_DETAILS.RELATIONSHIP_ID.eq(RELATIONSHIPS.ID)))); + default -> joinStep; + }; return jooqReactiveOperations.flux(query) - .map(r -> new RelationshipDto(r.into(RELATIONSHIP).into(RelationshipPojo.class), + .map(r -> new RelationshipDto(r.into(RELATIONSHIPS).into(RelationshipsPojo.class), r.into(srcDataEntity).into(DataEntityPojo.class), r.into(trgtDataEntity).into(DataEntityPojo.class), + r.into(ERD_RELATIONSHIP_DETAILS).into(ErdRelationshipDetailsPojo.class), + r.into(GRAPH_RELATIONSHIP).into(GraphRelationshipPojo.class), r.get(IS_ERD_RELATION, Boolean.class)) ); } @@ -103,24 +120,113 @@ public Mono getRelationshipById(final Long relationshipId) { final Table srcDataEntity = DATA_ENTITY.asTable(SOURCE_DATA_ENTITY); final Table trgtDataEntity = DATA_ENTITY.asTable(TARGET_DATA_ENTITY); - final SelectConditionStep query = - DSL.select(RELATIONSHIP.asterisk(), srcDataEntity.asterisk(), trgtDataEntity.asterisk()) - .select(DSL.exists( - DSL.select().from(ERD_RELATIONSHIP).where(ERD_RELATIONSHIP.RELATIONSHIP_ID.eq(RELATIONSHIP.ID))) - .as(IS_ERD_RELATION) - ) - .from(RELATIONSHIP) - .leftJoin(srcDataEntity) - .on(RELATIONSHIP.SOURCE_DATASET_ODDRN.eq(srcDataEntity.field(DATA_ENTITY.ODDRN))) - .leftJoin(trgtDataEntity) - .on(RELATIONSHIP.TARGET_DATASET_ODDRN.eq(trgtDataEntity.field(DATA_ENTITY.ODDRN))) - .where(RELATIONSHIP.ID.eq(relationshipId)); + final SelectOnConditionStep relationshipGenericQuery = + getRelationshipGenericQuery(srcDataEntity, trgtDataEntity); + + final SelectConditionStep query = relationshipGenericQuery.where(RELATIONSHIPS.ID.eq(relationshipId)); return jooqReactiveOperations.mono(query) - .map(r -> new RelationshipDto(r.into(RELATIONSHIP).into(RelationshipPojo.class), + .map(r -> new RelationshipDto(r.into(RELATIONSHIPS).into(RelationshipsPojo.class), r.into(srcDataEntity).into(DataEntityPojo.class), r.into(trgtDataEntity).into(DataEntityPojo.class), + r.into(ERD_RELATIONSHIP_DETAILS).into(ErdRelationshipDetailsPojo.class), + r.into(GRAPH_RELATIONSHIP).into(GraphRelationshipPojo.class), r.get(IS_ERD_RELATION, Boolean.class)) ); } + + @Override + public Mono> getRelationships(final Integer page, final Integer size, + final String inputQuery, final RelationshipsType type) { + final Table srcDataEntity = DATA_ENTITY.asTable(SOURCE_DATA_ENTITY); + final Table trgtDataEntity = DATA_ENTITY.asTable(TARGET_DATA_ENTITY); + + final Select homogeneousQuery = DSL.selectFrom(RELATIONSHIPS) + .where(listCondition(inputQuery)); + + final Select relationshipSelect = + paginate(homogeneousQuery, + List.of(new OrderByField(RELATIONSHIPS.ID, SortOrder.ASC)), (page - 1) * size, size); + + final Table relationshipCTE = relationshipSelect.asTable("relationship_cte"); + + final List> groupByFields = + Stream.of(relationshipCTE.fields(), srcDataEntity.fields(), + trgtDataEntity.fields(), ERD_RELATIONSHIP_DETAILS.fields(), GRAPH_RELATIONSHIP.fields()) + .flatMap(Arrays::stream) + .toList(); + + final SelectOnConditionStep generalQuery = DSL.with(relationshipCTE.getName()) + .as(relationshipSelect) + .select(relationshipCTE.fields()) + .select(srcDataEntity.asterisk(), + trgtDataEntity.asterisk(), + ERD_RELATIONSHIP_DETAILS.asterisk(), + GRAPH_RELATIONSHIP.asterisk()) + .select(DSL.exists( + DSL.select().from(ERD_RELATIONSHIP_DETAILS) + .where(ERD_RELATIONSHIP_DETAILS.RELATIONSHIP_ID.eq(relationshipCTE.field(RELATIONSHIPS.ID)))) + .as(IS_ERD_RELATION) + ) + .from(relationshipCTE.getName()) + .leftJoin(srcDataEntity) + .on(relationshipCTE.field(RELATIONSHIPS.SOURCE_DATASET_ODDRN).eq(srcDataEntity.field(DATA_ENTITY.ODDRN))) + .leftJoin(trgtDataEntity) + .on(relationshipCTE.field(RELATIONSHIPS.TARGET_DATASET_ODDRN).eq(trgtDataEntity.field(DATA_ENTITY.ODDRN))) + .leftJoin(ERD_RELATIONSHIP_DETAILS) + .on(ERD_RELATIONSHIP_DETAILS.RELATIONSHIP_ID.eq(relationshipCTE.field(RELATIONSHIPS.ID))) + .leftJoin(GRAPH_RELATIONSHIP) + .on(GRAPH_RELATIONSHIP.RELATIONSHIP_ID.eq(relationshipCTE.field(RELATIONSHIPS.ID))); + + final ResultQuery resultQuery = switch (type) { + case ERD -> generalQuery + .where(DSL.notExists( + select().from(GRAPH_RELATIONSHIP) + .where(GRAPH_RELATIONSHIP.RELATIONSHIP_ID.eq(relationshipCTE.field(RELATIONSHIPS.ID))))) + .groupBy(groupByFields); + case GRAPH -> generalQuery + .where(DSL.notExists( + select().from(ERD_RELATIONSHIP_DETAILS) + .where(ERD_RELATIONSHIP_DETAILS.RELATIONSHIP_ID.eq(relationshipCTE.field(RELATIONSHIPS.ID))))) + .groupBy(groupByFields); + default -> generalQuery.groupBy(groupByFields); + }; + + return jooqReactiveOperations.flux(resultQuery) + .collectList() + .flatMap(record -> jooqQueryHelper.pageifyResult( + record, + r -> new RelationshipDto( + jooqRecordHelper.remapCte(r, relationshipCTE.getName(), RELATIONSHIPS) + .into(RelationshipsPojo.class), + r.into(srcDataEntity).into(DataEntityPojo.class), + r.into(trgtDataEntity).into(DataEntityPojo.class), + r.into(ERD_RELATIONSHIP_DETAILS).into(ErdRelationshipDetailsPojo.class), + r.into(GRAPH_RELATIONSHIP).into(GraphRelationshipPojo.class), + r.get(IS_ERD_RELATION, Boolean.class)), + fetchCount(inputQuery))); + } + + private SelectOnConditionStep getRelationshipGenericQuery(final Table srcDataEntity, + final Table trgtDataEntity) { + return DSL.select(RELATIONSHIPS.asterisk(), + srcDataEntity.asterisk(), + trgtDataEntity.asterisk(), + ERD_RELATIONSHIP_DETAILS.asterisk(), + GRAPH_RELATIONSHIP.asterisk()) + .select(DSL.exists( + DSL.select().from(ERD_RELATIONSHIP_DETAILS) + .where(ERD_RELATIONSHIP_DETAILS.RELATIONSHIP_ID.eq(RELATIONSHIPS.ID))) + .as(IS_ERD_RELATION) + ) + .from(RELATIONSHIPS) + .leftJoin(srcDataEntity) + .on(RELATIONSHIPS.SOURCE_DATASET_ODDRN.eq(srcDataEntity.field(DATA_ENTITY.ODDRN))) + .leftJoin(trgtDataEntity) + .on(RELATIONSHIPS.TARGET_DATASET_ODDRN.eq(trgtDataEntity.field(DATA_ENTITY.ODDRN))) + .leftJoin(ERD_RELATIONSHIP_DETAILS) + .on(ERD_RELATIONSHIP_DETAILS.RELATIONSHIP_ID.eq(RELATIONSHIPS.ID)) + .leftJoin(GRAPH_RELATIONSHIP) + .on(GRAPH_RELATIONSHIP.RELATIONSHIP_ID.eq(RELATIONSHIPS.ID)); + } } diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/ERDRelationshipsService.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/ERDRelationshipsService.java deleted file mode 100644 index 7fa196f7d..000000000 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/ERDRelationshipsService.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.opendatadiscovery.oddplatform.service; - -import org.opendatadiscovery.oddplatform.api.contract.model.ERDRelationshipDetailsList; -import reactor.core.publisher.Mono; - -public interface ERDRelationshipsService { - Mono getDataSetErdRelationshipsById(final Long dataEntityId, - final Long relationshipsId); -} diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/ERDRelationshipsServiceImpl.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/ERDRelationshipsServiceImpl.java deleted file mode 100644 index 5456f7101..000000000 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/ERDRelationshipsServiceImpl.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.opendatadiscovery.oddplatform.service; - -import java.util.List; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.opendatadiscovery.oddplatform.api.contract.model.ERDRelationshipDetailsList; -import org.opendatadiscovery.oddplatform.mapper.ErdRelationShipMapper; -import org.opendatadiscovery.oddplatform.repository.reactive.ReactiveERDRelationshipsRepository; -import org.springframework.stereotype.Service; -import reactor.core.publisher.Mono; - -@Service -@Slf4j -@RequiredArgsConstructor -public class ERDRelationshipsServiceImpl implements ERDRelationshipsService { - private final ReactiveERDRelationshipsRepository erdRelationshipsRepository; - private final RelationshipsService relationshipsService; - private final ErdRelationShipMapper erdRelationShipMapper; - - @Override - public Mono getDataSetErdRelationshipsById(final Long dataEntityId, - final Long relationshipsId) { - return relationshipsService.getRelationshipById(relationshipsId) - .flatMap(item -> erdRelationshipsRepository.findERDSByRelationIds(List.of(relationshipsId)) - .map(erds -> new ERDRelationshipDetailsList() - .datasetRelationship(item) - .items(erdRelationShipMapper.pojoListToDetailsList(erds)))); - } -} diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/GraphRelationshipsService.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/GraphRelationshipsService.java deleted file mode 100644 index 027864f19..000000000 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/GraphRelationshipsService.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.opendatadiscovery.oddplatform.service; - -import org.opendatadiscovery.oddplatform.api.contract.model.GraphRelationshipDetailsList; -import reactor.core.publisher.Mono; - -public interface GraphRelationshipsService { - Mono getDataSetGraphRelationshipsById(final Long relationshipsId); -} diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/GraphRelationshipsServiceImpl.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/GraphRelationshipsServiceImpl.java deleted file mode 100644 index 8de3cb0a6..000000000 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/GraphRelationshipsServiceImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.opendatadiscovery.oddplatform.service; - -import java.util.List; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.opendatadiscovery.oddplatform.api.contract.model.GraphRelationshipDetailsList; -import org.opendatadiscovery.oddplatform.mapper.GraphRelationshipMapper; -import org.opendatadiscovery.oddplatform.repository.reactive.ReactiveGraphRelationshipsRepository; -import org.springframework.stereotype.Service; -import reactor.core.publisher.Mono; - -@Service -@Slf4j -@RequiredArgsConstructor -public class GraphRelationshipsServiceImpl implements GraphRelationshipsService { - private final ReactiveGraphRelationshipsRepository graphRelationshipsRepository; - private final RelationshipsService relationshipsService; - private final GraphRelationshipMapper graphRelationshipMapper; - - @Override - public Mono getDataSetGraphRelationshipsById(final Long relationshipsId) { - return relationshipsService.getRelationshipById(relationshipsId) - .flatMap(item -> graphRelationshipsRepository.findGraphsByRelationIds(List.of(relationshipsId)) - .map(graph -> graphRelationshipMapper.mapToDetails(item, graph))); - } -} diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/RelationshipsIngestionServiceImpl.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/RelationshipsIngestionServiceImpl.java index 27571b4fd..c355d9560 100644 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/RelationshipsIngestionServiceImpl.java +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/RelationshipsIngestionServiceImpl.java @@ -14,9 +14,9 @@ import org.opendatadiscovery.oddplatform.ingestion.contract.model.RelationshipList; import org.opendatadiscovery.oddplatform.mapper.ingestion.DatasetERDRelationIngestionMapper; import org.opendatadiscovery.oddplatform.mapper.ingestion.DatasetGraphRelationIngestionMapper; -import org.opendatadiscovery.oddplatform.model.tables.pojos.ErdRelationshipPojo; +import org.opendatadiscovery.oddplatform.model.tables.pojos.ErdRelationshipDetailsPojo; import org.opendatadiscovery.oddplatform.model.tables.pojos.GraphRelationshipPojo; -import org.opendatadiscovery.oddplatform.model.tables.pojos.RelationshipPojo; +import org.opendatadiscovery.oddplatform.model.tables.pojos.RelationshipsPojo; import org.opendatadiscovery.oddplatform.repository.reactive.ReactiveDataSourceRepository; import org.opendatadiscovery.oddplatform.repository.reactive.ReactiveERDRelationshipsRepository; import org.opendatadiscovery.oddplatform.repository.reactive.ReactiveGraphRelationshipsRepository; @@ -44,15 +44,15 @@ public Mono ingestRelationships(final RelationshipList relationshipList) { } private Mono processRelationships(final List items, final Long dataSourceId) { - final Map> erdMap = + final Map erdMap = erdRelationIngestionMapper.mapERDRelations(items, dataSourceId); - final Map graphMap = + final Map graphMap = graphRelationIngestionMapper.mapGraphRelations(items, dataSourceId); final Set ingestedRelations = new HashSet<>(); - ingestedRelations.addAll(erdMap.keySet().stream().map(RelationshipPojo::getRelationshipOddrn).toList()); - ingestedRelations.addAll(graphMap.keySet().stream().map(RelationshipPojo::getRelationshipOddrn).toList()); + ingestedRelations.addAll(erdMap.keySet().stream().map(RelationshipsPojo::getRelationshipOddrn).toList()); + ingestedRelations.addAll(graphMap.keySet().stream().map(RelationshipsPojo::getRelationshipOddrn).toList()); return relationshipsRepository.getRelationshipByDataSourceId(dataSourceId) .collectList() @@ -61,41 +61,29 @@ private Mono processRelationships(final List items, final Lo .then(removeRelationships(existedPojos, ingestedRelations))); } - private Mono handleERDRelations(final List existedPojos, - final Map> erdMap) { - final Map> erdToCreate = new HashMap<>(); - final Map>> erdToUpdateMap = new HashMap<>(); + private Mono handleERDRelations(final List existedPojos, + final Map erdMap) { + final Map erdToCreate = new HashMap<>(); + final Map> erdToUpdateMap = new HashMap<>(); - erdMap.forEach((key, value) -> { - final RelationshipPojo oldPojo = getExistedRelationByOddrn(existedPojos, key); - - if (oldPojo != null) { - key.setId(oldPojo.getId()); - erdToUpdateMap.put(key.getId(), Pair.of(key, value)); - } else { - erdToCreate.put(key, value); - } - }); + fillUpdateAndCreateMaps(existedPojos, erdMap, erdToUpdateMap, erdToCreate); return updateExistedERDRelations(erdToUpdateMap) .then( Flux.fromIterable(erdToCreate.entrySet()) .flatMap(element -> relationshipsRepository.create(element.getKey()) .flatMap(relationshipPojo -> { - final List toCreate = - element.getValue().stream() - .map(item -> item.setRelationshipId(relationshipPojo.getId())) - .toList(); - - return erdRelationshipsRepository.bulkCreate(toCreate).collectList(); + final ErdRelationshipDetailsPojo toCreate = + element.getValue().setRelationshipId(relationshipPojo.getId()); + return erdRelationshipsRepository.create(toCreate); }) ).collectList() ) .then(); } - private Mono> - updateExistedERDRelations(final Map>> erdToUpdateMap) { + private Mono> + updateExistedERDRelations(final Map> erdToUpdateMap) { final List relationshipIds = erdToUpdateMap.values() .stream() .map(relationshipPojoListPair -> relationshipPojoListPair.getKey().getId()) @@ -103,66 +91,44 @@ private Mono handleERDRelations(final List existedPojos, return erdRelationshipsRepository.findERDSByRelationIds(relationshipIds) .flatMap(existedErds -> { - final Set toCreate = new HashSet<>(); - final Set toUpdate = new HashSet<>(); - final Set toDelete = new HashSet<>(); - - for (final ErdRelationshipPojo erdPojo : existedErds) { - final List ingestErd = - erdToUpdateMap.get(erdPojo.getRelationshipId()).getValue(); - final ErdRelationshipPojo pojoToUpdate = ingestErd.stream() - .filter(ingestPojo -> - ingestPojo.getSourceDatasetFieldOddrn().equals(erdPojo.getSourceDatasetFieldOddrn()) - && ingestPojo.getTargetDatasetFieldOddrn().equals(erdPojo.getTargetDatasetFieldOddrn())) - .findFirst() - .orElse(null); - - if (pojoToUpdate == null) { - toDelete.add(erdPojo.getId()); - } else { - pojoToUpdate.setId(erdPojo.getId()); - pojoToUpdate.setRelationshipId(erdPojo.getRelationshipId()); - toUpdate.add(pojoToUpdate); - } - } - - for (final Pair> value : erdToUpdateMap.values()) { - value.getValue().stream() - .filter(erdRelationshipPojo -> erdRelationshipPojo.getRelationshipId() == null) - .forEach(erdRelationshipPojo -> { - erdRelationshipPojo.setRelationshipId(value.getKey().getId()); - toCreate.add(erdRelationshipPojo); - }); - } - - final List relationsToUpdate = erdToUpdateMap.values().stream() - .map(Pair::getKey) - .toList(); - - return Flux.fromIterable(relationsToUpdate).collectList() - .flatMap(element -> relationshipsRepository.bulkUpdate(relationsToUpdate).collectList()) - .then(erdRelationshipsRepository.delete(toDelete).collectList()) - .then(erdRelationshipsRepository.bulkUpdate(toUpdate).collectList()) - .then(erdRelationshipsRepository.bulkCreate(toCreate).collectList()); + final Set toUpdate = new HashSet<>(); + + existedErds.forEach(existedErd -> { + final ErdRelationshipDetailsPojo ingested + = erdToUpdateMap.get(existedErd.getRelationshipId()).getValue(); + ingested.setId(existedErd.getId()); + ingested.setRelationshipId(existedErd.getRelationshipId()); + toUpdate.add(ingested); + }); + + return Flux.fromIterable(erdToUpdateMap.values().stream() + .map(Pair::getKey) + .toList() + ).collectList() + .flatMap(element -> relationshipsRepository.bulkUpdate(element).collectList()) + .then(erdRelationshipsRepository.bulkUpdate(toUpdate).collectList()); }); } - private Mono handleGraphRelations(final List existedPojos, - final Map graphMap) { - final Map graphToCreate = new HashMap<>(); - final Map> graphToUpdate = new HashMap<>(); - - graphMap.forEach((key, value) -> { - final RelationshipPojo oldPojo = getExistedRelationByOddrn(existedPojos, key); - - if (oldPojo != null) { - key.setId(oldPojo.getId()); - graphToUpdate.put(key.getId(), Pair.of(key, value)); - } else { - graphToCreate.put(key, value); - } - }); + private Mono handleGraphRelations(final List existedPojos, + final Map graphMap) { + final Map graphToCreate = new HashMap<>(); + final Map> graphToUpdate = new HashMap<>(); + + fillUpdateAndCreateMaps(existedPojos, graphMap, graphToUpdate, graphToCreate); + + return updateExistedGraphRelations(graphToUpdate).then(Flux.fromIterable(graphToCreate.entrySet()) + .flatMap(element -> relationshipsRepository.create(element.getKey()) + .flatMap(relationshipPojo -> { + element.getValue().setRelationshipId(relationshipPojo.getId()); + return graphRelationshipsRepository.create(element.getValue()); + }) + ).collectList() + ).then(); + } + private Mono> + updateExistedGraphRelations(final Map> graphToUpdate) { final List relationshipIds = graphToUpdate.values() .stream() .map(relationshipPojoListPair -> relationshipPojoListPair.getKey().getId()) @@ -171,31 +137,23 @@ private Mono handleGraphRelations(final List existedPojo return graphRelationshipsRepository.findGraphsByRelationIds(relationshipIds) .flatMap(item -> { final Set toUpdate = new HashSet<>(); - for (final GraphRelationshipPojo graphPojo : item) { + item.forEach(graphPojo -> { final GraphRelationshipPojo ingestedPojo = graphToUpdate.get(graphPojo.getRelationshipId()).getValue(); - ingestedPojo.setId(graphPojo.getId()); ingestedPojo.setRelationshipId(graphPojo.getRelationshipId()); toUpdate.add(ingestedPojo); - } + }); return Flux.fromIterable(graphToUpdate.values()) .flatMap(element -> relationshipsRepository.update(element.getKey())).collectList() .then(graphRelationshipsRepository.bulkUpdate(toUpdate).collectList()); - }).then(Flux.fromIterable(graphToCreate.entrySet()) - .flatMap(element -> relationshipsRepository.create(element.getKey()) - .flatMap(relationshipPojo -> { - element.getValue().setRelationshipId(relationshipPojo.getId()); - return graphRelationshipsRepository.create(element.getValue()); - }) - ).collectList() - ).then(); + }); } - private Mono removeRelationships(final List existedPojos, + private Mono removeRelationships(final List existedPojos, final Set ingestedRelations) { - final List toRemove = + final List toRemove = existedPojos.stream().filter(existedPojo -> !ingestedRelations.contains(existedPojo.getRelationshipOddrn())) .map(item -> item.setRelationshipStatus(RelationshipStatusDto.DELETED.getId())).toList(); @@ -203,8 +161,24 @@ private Mono removeRelationships(final List existedPojos .flatMap(items -> relationshipsRepository.bulkUpdate(items).collectList()).then(); } - private RelationshipPojo getExistedRelationByOddrn(final List existedPojos, - final RelationshipPojo key) { + private void fillUpdateAndCreateMaps(final List existedPojos, + final Map ingestMap, + final Map toUpdateMap, + final Map toCreatteMap) { + ingestMap.forEach((key, value) -> { + final RelationshipsPojo oldPojo = getExistedRelationByOddrn(existedPojos, key); + + if (oldPojo != null) { + key.setId(oldPojo.getId()); + toUpdateMap.put(key.getId(), Pair.of(key, value)); + } else { + toCreatteMap.put(key, value); + } + }); + } + + private RelationshipsPojo getExistedRelationByOddrn(final List existedPojos, + final RelationshipsPojo key) { return existedPojos.stream() .filter(existedPojo -> key.getRelationshipOddrn().equals(existedPojo.getRelationshipOddrn())) diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/RelationshipsService.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/RelationshipsService.java index 1caf8b134..2badce032 100644 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/RelationshipsService.java +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/RelationshipsService.java @@ -2,10 +2,16 @@ import org.opendatadiscovery.oddplatform.api.contract.model.DatasetRelationship; import org.opendatadiscovery.oddplatform.api.contract.model.DatasetRelationshipList; +import org.opendatadiscovery.oddplatform.api.contract.model.RelationshipsType; import reactor.core.publisher.Mono; public interface RelationshipsService { - Mono getRelationsByDatasetId(final Long dataEntityId); + Mono getRelationsByDatasetId(final Long dataEntityId, final RelationshipsType type); Mono getRelationshipById(final Long relationshipId); + + Mono getRelationships(final Integer page, + final Integer size, + final RelationshipsType type, + final String query); } diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/RelationshipsServiceImpl.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/RelationshipsServiceImpl.java index c25d61a9b..4d832a997 100644 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/RelationshipsServiceImpl.java +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/service/RelationshipsServiceImpl.java @@ -3,6 +3,7 @@ import lombok.RequiredArgsConstructor; import org.opendatadiscovery.oddplatform.api.contract.model.DatasetRelationship; import org.opendatadiscovery.oddplatform.api.contract.model.DatasetRelationshipList; +import org.opendatadiscovery.oddplatform.api.contract.model.RelationshipsType; import org.opendatadiscovery.oddplatform.exception.NotFoundException; import org.opendatadiscovery.oddplatform.mapper.RelationshipMapper; import org.opendatadiscovery.oddplatform.repository.reactive.ReactiveRelationshipsRepository; @@ -16,8 +17,9 @@ public class RelationshipsServiceImpl implements RelationshipsService { private final RelationshipMapper relationshipMapper; @Override - public Mono getRelationsByDatasetId(final Long dataEntityId) { - return relationshipsRepository.getRelationsByDatasetId(dataEntityId) + public Mono getRelationsByDatasetId(final Long dataEntityId, + final RelationshipsType type) { + return relationshipsRepository.getRelationsByDatasetIdAndType(dataEntityId, type) .collectList() .map(relationshipMapper::mapListToRelationshipList); } @@ -28,4 +30,11 @@ public Mono getRelationshipById(final Long relationshipId) .switchIfEmpty(Mono.error(() -> new NotFoundException("Relationship", relationshipId))) .map(relationshipMapper::mapToDatasetRelationship); } + + @Override + public Mono getRelationships(final Integer page, final Integer size, + final RelationshipsType type, final String query) { + return relationshipsRepository.getRelationships(page, size, query, type) + .map(relationshipMapper::mapListToRelationshipPage); + } } diff --git a/odd-platform-api/src/main/resources/db/migration/V0_0_87__create_relation_tables.sql b/odd-platform-api/src/main/resources/db/migration/V0_0_87__create_relation_tables.sql index 139529937..04338ae42 100644 --- a/odd-platform-api/src/main/resources/db/migration/V0_0_87__create_relation_tables.sql +++ b/odd-platform-api/src/main/resources/db/migration/V0_0_87__create_relation_tables.sql @@ -1,4 +1,4 @@ -CREATE TABLE IF NOT EXISTS relationship +CREATE TABLE IF NOT EXISTS relationships ( id bigserial PRIMARY KEY, name varchar(512), @@ -14,26 +14,26 @@ CREATE TABLE IF NOT EXISTS relationship CONSTRAINT relationship_fk_data_source FOREIGN KEY (data_source_id) REFERENCES data_source (id) ); -CREATE TABLE IF NOT EXISTS erd_relationship +CREATE TABLE IF NOT EXISTS erd_relationship_details ( id bigserial PRIMARY KEY, relationship_id bigint, - source_dataset_field_oddrn varchar(512), - target_dataset_field_oddrn varchar(512), + source_dataset_field_oddrn varchar(512)[], + target_dataset_field_oddrn varchar(512)[], is_identifying boolean, cardinality varchar(256), - CONSTRAINT erd_relationship_fk_relationship FOREIGN KEY (relationship_id) REFERENCES relationship (id) + CONSTRAINT erd_relationship_fk_relationship FOREIGN KEY (relationship_id) REFERENCES relationships (id) ); CREATE TABLE IF NOT EXISTS graph_relationship ( id bigserial PRIMARY KEY, relationship_id bigint, - is_derected boolean, + is_directed boolean, specific_attributes jsonb, - CONSTRAINT graph_relationship_fk_relationship FOREIGN KEY (relationship_id) REFERENCES relationship (id) + CONSTRAINT graph_relationship_fk_relationship FOREIGN KEY (relationship_id) REFERENCES relationships (id) ); diff --git a/odd-platform-specification/components.yaml b/odd-platform-specification/components.yaml index cfb599780..241f8d4fa 100644 --- a/odd-platform-specification/components.yaml +++ b/odd-platform-specification/components.yaml @@ -3969,6 +3969,10 @@ components: type: string type: $ref: '#/components/schemas/DatasetRelationshipType' + erd_relationship: + $ref: '#/components/schemas/ERDRelationshipDetails' + graph_relationship: + $ref: '#/components/schemas/GraphRelationshipDetails' required: - name - oddrn @@ -3982,53 +3986,38 @@ components: - ERD - GRAPH - ERDRelationshipDetailsList: - type: object - properties: - dataset_relationship: - $ref: '#/components/schemas/DatasetRelationship' - items: - type: array - items: - $ref: '#/components/schemas/ERDRelationshipDetails' - required: - - items - ERDRelationshipDetails: type: object properties: erd_relationships_id: type: integer format: int64 - source_dataset_field_oddrn: - type: string - target_dataset_field_oddrn: - type: string + fields_pairs: + type: array + items: + $ref: '#/components/schemas/ERDRelationshipPairs' is_identifying: type: boolean cardinality: type: string required: - - erd_relationships_id - - source_dataset_field_oddrn - - target_dataset_field_oddrn + - fields_pairs - GraphRelationshipDetailsList: + ERDRelationshipPairs: type: object properties: - dataset_relationship: - $ref: '#/components/schemas/DatasetRelationship' - items: - type: array - items: - $ref: '#/components/schemas/GraphRelationshipDetails' + source_dataset_field_oddrn: + type: string + target_dataset_field_oddrn: + type: string required: - - items + - source_dataset_field_oddrn + - target_dataset_field_oddrn GraphRelationshipDetails: type: object properties: - graph_relationships_id: + graph_relationship_id: type: integer format: int64 is_directed: @@ -4049,6 +4038,13 @@ components: - field - value + RelationshipsType: + type: string + enum: + - ERD + - GRAPH + - ALL + parameters: PageParam: name: page @@ -4214,14 +4210,21 @@ components: type: integer format: int64 - RelationshipsIdParam: - name: relationships_id + RelationshipIdParam: + name: relationship_id in: path required: true schema: type: integer format: int64 + RelationshipTypeParam: + name: type + in: query + required: true + schema: + $ref: '#/components/schemas/RelationshipsType' + responses: Deleted: description: The resource has been successfully deleted diff --git a/odd-platform-specification/openapi.yaml b/odd-platform-specification/openapi.yaml index f47be3220..03abdc754 100644 --- a/odd-platform-specification/openapi.yaml +++ b/odd-platform-specification/openapi.yaml @@ -1775,6 +1775,7 @@ paths: operationId: getDataSetRelationships parameters: - $ref: './components.yaml/#/components/parameters/DataEntityIdParam' + - $ref: './components.yaml/#/components/parameters/RelationshipTypeParam' responses: '200': description: OK @@ -1785,42 +1786,6 @@ paths: tags: - dataSet - /api/datasets/{data_entity_id}/graphrelationships/{relationships_id}: - get: - summary: Get list of relationships for dataset - description: Get information about DataSet's relationships for dataset by DataSet's id - operationId: getDataSetGraphRelationshipsById - parameters: - - $ref: './components.yaml/#/components/parameters/DataEntityIdParam' - - $ref: './components.yaml/#/components/parameters/RelationshipsIdParam' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: './components.yaml/#/components/schemas/GraphRelationshipDetailsList' - tags: - - dataSet - - /api/datasets/{data_entity_id}/erdrelationships/{relationships_id}: - get: - summary: Get list of relationships for dataset - description: Get information about DataSet's relationships for dataset by DataSet's id - operationId: getDataSetErdRelationshipsById - parameters: - - $ref: './components.yaml/#/components/parameters/DataEntityIdParam' - - $ref: './components.yaml/#/components/parameters/RelationshipsIdParam' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: './components.yaml/#/components/schemas/ERDRelationshipDetailsList' - tags: - - dataSet - /api/datasets/{data_entity_id}/structure/{version_id}: get: summary: Get DataSet structure information @@ -3864,4 +3829,41 @@ paths: '204': $ref: './components.yaml/#/components/responses/Deleted' tags: - - referenceData \ No newline at end of file + - referenceData + + /api/relationships: + get: + summary: Get list of relationships + description: Get information about DataSet's relationships + operationId: getRelationships + parameters: + - $ref: './components.yaml/#/components/parameters/PageParam' + - $ref: './components.yaml/#/components/parameters/SizeParam' + - $ref: './components.yaml/#/components/parameters/SearchParam' + - $ref: './components.yaml/#/components/parameters/RelationshipTypeParam' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: './components.yaml/#/components/schemas/DatasetRelationshipList' + tags: + - relationship + + /api/relationships/{relationships_id}: + get: + summary: Get relationships by id + description: Get information about DataSet's relationships for dataset by id + operationId: getRelationshipsById + parameters: + - $ref: './components.yaml/#/components/parameters/RelationshipIdParam' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: './components.yaml/#/components/schemas/DatasetRelationship' + tags: + - relationship \ No newline at end of file