Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Generator/DTO/Relationship.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public record Relationship(
string TableSchema,
string LookupDisplayName,
string RelationshipSchema,
string? IntersectEntitySchemaName,
string RelationshipType,
bool IsExplicit,
string PublisherName,
Expand Down
2 changes: 1 addition & 1 deletion Generator/DataverseService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public DataverseService(
.Select(entMeta =>
{
var relevantAttributes = entMeta.Attributes.Where(attr => attributesInSolution.Contains(attr.MetadataId!.Value)).ToList();
var relevantManyToManyRelations = relationshipService.ConvertManyToManyRelationships(entMeta.ManyToManyRelationships.Where(rel => relationshipsInSolution.Contains(rel.MetadataId!.Value)), entMeta.LogicalName, inclusionMap, publisherMap, componentSolutionMap, entMeta.MetadataId!.Value);
var relevantManyToManyRelations = relationshipService.ConvertManyToManyRelationships(entMeta.ManyToManyRelationships.Where(rel => relationshipsInSolution.Contains(rel.MetadataId!.Value)), entMeta.LogicalName, logicalToSchema, inclusionMap, publisherMap, componentSolutionMap, entMeta.MetadataId!.Value);
var relevantOneToManyRelations = relationshipService.ConvertOneToManyRelationships(entMeta.OneToManyRelationships.Where(rel => relationshipsInSolution.Contains(rel.MetadataId!.Value)), true, logicalToSchema, attributeLogicalToSchema, inclusionMap, publisherMap, componentSolutionMap, entMeta.MetadataId!.Value);
var relevantManyToOneRelations = relationshipService.ConvertOneToManyRelationships(entMeta.ManyToOneRelationships.Where(rel => relationshipsInSolution.Contains(rel.MetadataId!.Value)), false, logicalToSchema, attributeLogicalToSchema, inclusionMap, publisherMap, componentSolutionMap, entMeta.MetadataId!.Value);
var relevantRelationships = relevantManyToManyRelations.Concat(relevantManyToOneRelations).Concat(relevantOneToManyRelations).ToList();
Expand Down
15 changes: 13 additions & 2 deletions Generator/Services/RelationshipService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public Dictionary<string, string> ParseTableGroups()
public IEnumerable<Relationship> ConvertManyToManyRelationships(
IEnumerable<ManyToManyRelationshipMetadata> relationships,
string entityLogicalName,
Dictionary<string, ExtendedEntityInformation> logicalToSchema,
Dictionary<Guid, bool> inclusionMap,
Dictionary<Guid, (string Name, string Prefix)> publisherMap,
Dictionary<Guid, List<SolutionInfo>> componentSolutionMap,
Expand All @@ -103,12 +104,21 @@ public IEnumerable<Relationship> ConvertManyToManyRelationships(
var relationshipSolutions = componentSolutionMap.GetValueOrDefault(rel.MetadataId!.Value)
?? componentSolutionMap.GetValueOrDefault(entityMetadataId, new List<SolutionInfo>());

var relatedTable = rel.Entity1LogicalName.Equals(entityLogicalName, StringComparison.OrdinalIgnoreCase)
? rel.Entity2LogicalName
: rel.Entity1LogicalName;

var relatedSchemaName = logicalToSchema.ContainsKey(relatedTable)
? logicalToSchema[relatedTable].Name
: relatedTable;

return new Relationship(
rel.IsCustomRelationship ?? false,
$"{rel.Entity1AssociatedMenuConfiguration.Label.ToLabelString()} ⟷ {rel.Entity2AssociatedMenuConfiguration.Label.ToLabelString()}",
entityLogicalName,
$"{rel.Entity1LogicalName} ⟷ {rel.Entity2LogicalName}",
relatedSchemaName,
"-",
rel.SchemaName,
rel.IntersectEntityName,
"N:N",
inclusionMap[rel.MetadataId!.Value],
pName,
Expand Down Expand Up @@ -154,6 +164,7 @@ public IEnumerable<Relationship> ConvertOneToManyRelationships(
tableSchema,
lookupName,
rel.SchemaName,
null,
!isOneToMany ? "N:1" : "1:N",
inclusionMap[rel.MetadataId!.Value],
pName,
Expand Down
23 changes: 23 additions & 0 deletions Website/components/datamodelview/Relationships.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const Relationships = ({ entity, search = "", onVisibleCountChange }: IRe
const [typeFilter, setTypeFilter] = useState<string>("all")
const [searchQuery, setSearchQuery] = useState("")
const [hideImplicitRelationships, setHideImplicitRelationships] = useState<boolean>(true)
const [hideOutOfSolutionRelationships, setHideOutOfSolutionRelationships] = useState<boolean>(true)

const theme = useTheme();

Expand Down Expand Up @@ -88,6 +89,11 @@ export const Relationships = ({ entity, search = "", onVisibleCountChange }: IRe

filteredRelationships = filteredRelationships.filter(rel => rel.IsExplicit || !hideImplicitRelationships);

// Filter out relationships where related table is not in solution
if (hideOutOfSolutionRelationships) {
filteredRelationships = filteredRelationships.filter(rel => isEntityInSolution(rel.TableSchema));
}

if (!sortColumn || !sortDirection) return filteredRelationships

return [...filteredRelationships].sort((a, b) => {
Expand Down Expand Up @@ -225,6 +231,21 @@ export const Relationships = ({ entity, search = "", onVisibleCountChange }: IRe
}
</Button>
</Tooltip>
<Tooltip title={hideOutOfSolutionRelationships ? "Show relationships to tables not in solution" : "Hide relationships to tables not in solution"}>
<Button
variant="outlined"
size="small"
onClick={() => setHideOutOfSolutionRelationships(!hideOutOfSolutionRelationships)}
className="min-w-0 p-0 h-8 w-8 md:h-10 md:w-10"
sx={{
borderColor: 'border.main'
}}
>
{
hideOutOfSolutionRelationships ? <ContentPasteOffRounded className="text-xs md:text-base" /> : <ContentPasteSearchRounded className="text-xs md:text-base" />
}
</Button>
</Tooltip>
{(searchQuery || typeFilter !== "all") && (
<Button
variant="text"
Expand Down Expand Up @@ -441,6 +462,8 @@ export const Relationships = ({ entity, search = "", onVisibleCountChange }: IRe
</TableCell>
<TableCell className="break-words py-1 md:py-1.5 text-xs md:text-sm">
{relationship.RelationshipSchema}
{relationship.IntersectEntitySchemaName &&
(<Typography variant="body2" className="text-xs md:text-sm text-secondary"><b>Intersecting table:</b> {relationship.IntersectEntitySchemaName}</Typography>)}
</TableCell>
</TableRow>
)}
Expand Down
1 change: 1 addition & 0 deletions Website/lib/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ export type RelationshipType = {
TableSchema: string,
LookupDisplayName: string,
RelationshipSchema: string,
IntersectEntitySchemaName: string | null,
IsExplicit: boolean,
RelationshipType: "N:N" | "1:N" | "N:1",
CascadeConfiguration: CascadeConfigurationType | null,
Expand Down
Loading