-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1576 - implementation of ingest relationships API and GET Relationshi…
…ps API
- Loading branch information
Showing
27 changed files
with
481 additions
and
441 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
35 changes: 35 additions & 0 deletions
35
...pi/src/main/java/org/opendatadiscovery/oddplatform/controller/RelationshipController.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,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<ResponseEntity<DatasetRelationshipList>> 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<ResponseEntity<DatasetRelationship>> getRelationshipsById(final Long relationshipId, | ||
final ServerWebExchange exchange) { | ||
return relationshipsService.getRelationshipById(relationshipId) | ||
.map(ResponseEntity::ok); | ||
} | ||
} |
8 changes: 6 additions & 2 deletions
8
odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/dto/RelationshipDto.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 |
---|---|---|
@@ -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) { | ||
} |
24 changes: 0 additions & 24 deletions
24
...orm-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ErdRelationShipMapper.java
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
...orm-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/ErdRelationshipMapper.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,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<ERDRelationshipPairs> 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()); | ||
} | ||
} |
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
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
4 changes: 2 additions & 2 deletions
4
...va/org/opendatadiscovery/oddplatform/mapper/ingestion/DatasetRelationIngestionMapper.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 |
---|---|---|
@@ -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); | ||
} |
Oops, something went wrong.