-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add relationships to datasets (#1654)
Co-authored-by: ayemets-corcentric <[email protected]> Co-authored-by: vburlachenko <[email protected]>
- Loading branch information
1 parent
90efc54
commit 883b47d
Showing
34 changed files
with
905 additions
and
508 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
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
14 changes: 14 additions & 0 deletions
14
...rm-api/src/main/java/org/opendatadiscovery/oddplatform/dto/ErdRelationshipDetailsDto.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,14 @@ | ||
package org.opendatadiscovery.oddplatform.dto; | ||
|
||
import java.util.List; | ||
import lombok.Builder; | ||
import org.apache.commons.lang3.tuple.Pair; | ||
import org.opendatadiscovery.oddplatform.model.tables.pojos.DatasetFieldPojo; | ||
import org.opendatadiscovery.oddplatform.model.tables.pojos.ErdRelationshipDetailsPojo; | ||
|
||
@Builder | ||
public record ErdRelationshipDetailsDto(ErdRelationshipDetailsPojo pojo, | ||
List<Pair< | ||
Pair<String, DatasetFieldPojo>, | ||
Pair<String, DatasetFieldPojo>>> fieldPairList) { | ||
} |
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
39 changes: 25 additions & 14 deletions
39
...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 |
---|---|---|
@@ -1,31 +1,42 @@ | ||
package org.opendatadiscovery.oddplatform.mapper; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.IntStream; | ||
import org.apache.commons.lang3.tuple.Pair; | ||
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.opendatadiscovery.oddplatform.dto.ErdRelationshipDetailsDto; | ||
import org.opendatadiscovery.oddplatform.model.tables.pojos.DatasetFieldPojo; | ||
import org.springframework.stereotype.Component; | ||
import org.thymeleaf.util.ArrayUtils; | ||
|
||
@Component | ||
public class ErdRelationshipMapper { | ||
public ERDRelationshipDetails mapPojoToDetails(final ErdRelationshipDetailsPojo erd) { | ||
public ERDRelationshipDetails mapPojoToDetails(final ErdRelationshipDetailsDto erd) { | ||
if (erd == null) { | ||
return null; | ||
} | ||
|
||
return new ERDRelationshipDetails() | ||
.erdRelationshipId(erd.getId()) | ||
.fieldsPairs(mapPairs(erd.getSourceDatasetFieldOddrn(), erd.getTargetDatasetFieldOddrn())) | ||
.isIdentifying(erd.getIsIdentifying()) | ||
.cardinality(erd.getCardinality()); | ||
.erdRelationshipId(erd.pojo().getId()) | ||
.fieldsPairs(mapPairs(erd.fieldPairList())) | ||
.isIdentifying(erd.pojo().getIsIdentifying()) | ||
.cardinality(erd.pojo().getCardinality()); | ||
} | ||
|
||
private List<ERDRelationshipPairs> mapPairs(final String[] source, final String[] target) { | ||
if (ArrayUtils.isEmpty(source)) { | ||
return null; | ||
private List<ERDRelationshipPairs> mapPairs(final List<Pair<Pair<String, DatasetFieldPojo>, | ||
Pair<String, DatasetFieldPojo>>> fieldPairsList) { | ||
if (fieldPairsList.isEmpty()) { | ||
return Collections.emptyList(); | ||
} | ||
|
||
return IntStream.range(0, source.length).mapToObj(i -> new ERDRelationshipPairs() | ||
.sourceDatasetFieldOddrn(source[i]) | ||
.targetDatasetFieldOddrn(target[i])).collect(Collectors.toList()); | ||
return fieldPairsList.stream().map(fieldPairs -> new ERDRelationshipPairs() | ||
.sourceDatasetFieldOddrn(fieldPairs.getLeft().getKey()) | ||
.sourceDatasetFieldId( | ||
fieldPairs.getLeft().getValue() != null ? fieldPairs.getLeft().getValue().getId() : null) | ||
.targetDatasetFieldOddrn(fieldPairs.getRight().getKey()) | ||
.targetDatasetFieldId( | ||
fieldPairs.getRight().getValue() != null ? fieldPairs.getRight().getValue().getId() : null)) | ||
.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
58 changes: 0 additions & 58 deletions
58
...api/src/main/java/org/opendatadiscovery/oddplatform/mapper/RelationshipDetailsMapper.java
This file was deleted.
Oops, something went wrong.
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
11 changes: 0 additions & 11 deletions
11
...datadiscovery/oddplatform/repository/reactive/ReactiveRelationshipsDetailsRepository.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.