Skip to content

Commit 191262a

Browse files
committed
Renamed Relationships enum to AssociationTypes
The name `Relationships` has always been ambiguous, since it can refer both to `Topic.Relationships`, as well as other types of topic associations, such as `Topic.Parent` or `Topic.References`. To avoid that ambiguity, we're moving toward the more general name `Associations`. Ideally, the `OnTopic.References` namespace—which provides types associated with topic associations—will be renamed to `OnTopic.Associations`. To avoid a conflict between the `Associations` namespace and an `Associations` enum, the enum is being named `AssociationTypes`. I don't love this name, but it's better than having two different labels for the same concept in the library. This has a lot of downstream impacts, such as properties on `MappedTopicCacheEntry`, the parameters on `ITopicMappingService`, the `RelationshipMap` class, and properties on the `PropertyConfiguration` class. Those downstream impacts will be addressed in subsequent updates.
1 parent 44dc3eb commit 191262a

19 files changed

+97
-93
lines changed

OnTopic.TestDoubles/DummyTopicMappingService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,21 @@ public DummyTopicMappingService() {
3636
\-------------------------------------------------------------------------------------------------------------------------*/
3737
/// <inheritdoc />
3838
[return: NotNullIfNotNull("topic")]
39-
public async Task<object?> MapAsync(Topic? topic, Relationships relationships = Relationships.All)
39+
public async Task<object?> MapAsync(Topic? topic, AssociationTypes relationships = AssociationTypes.All)
4040
=> throw new NotImplementedException();
4141

4242
/*==========================================================================================================================
4343
| METHOD: MAP (T)
4444
\-------------------------------------------------------------------------------------------------------------------------*/
4545
/// <inheritdoc />
46-
public async Task<T?> MapAsync<T>(Topic? topic, Relationships relationships = Relationships.All) where T : class, new()
46+
public async Task<T?> MapAsync<T>(Topic? topic, AssociationTypes relationships = AssociationTypes.All) where T : class, new()
4747
=> throw new NotImplementedException();
4848

4949
/*==========================================================================================================================
5050
| METHOD: MAP (OBJECTS)
5151
\-------------------------------------------------------------------------------------------------------------------------*/
5252
/// <inheritdoc />
53-
public async Task<object?> MapAsync(Topic? topic, object target, Relationships relationships = Relationships.All)
53+
public async Task<object?> MapAsync(Topic? topic, object target, AssociationTypes relationships = AssociationTypes.All)
5454
=> throw new NotImplementedException();
5555

5656
} //Class

OnTopic.Tests/TopicMappingServiceTest.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -305,23 +305,23 @@ public async Task Map_AlternateAttributeKey_ReturnsMappedModel() {
305305
| TEST: MAPPED TOPIC CACHE ENTRY: GET MISSING RELATIONSHIPS: RETURNS DIFFERENCE
306306
\-------------------------------------------------------------------------------------------------------------------------*/
307307
/// <summary>
308-
/// Establishes a <see cref="MappedTopicCacheEntry"/> with a set of <see cref="Relationships"/>, and then confirms that
309-
/// its <see cref="MappedTopicCacheEntry.GetMissingRelationships(Relationships)"/> correctly returns the missing
308+
/// Establishes a <see cref="MappedTopicCacheEntry"/> with a set of <see cref="AssociationTypes"/>, and then confirms that
309+
/// its <see cref="MappedTopicCacheEntry.GetMissingRelationships(AssociationTypes)"/> correctly returns the missing
310310
/// relationships.
311311
/// </summary>
312312
[TestMethod]
313313
public void MappedTopicCacheEntry_GetMissingRelationships_ReturnsDifference() {
314314

315315
var cacheEntry = new MappedTopicCacheEntry() {
316-
Relationships = Relationships.Children | Relationships.Parents
316+
Relationships = AssociationTypes.Children | AssociationTypes.Parents
317317
};
318-
var relationships = Relationships.Children | Relationships.References;
318+
var relationships = AssociationTypes.Children | AssociationTypes.References;
319319

320320
var difference = cacheEntry.GetMissingRelationships(relationships);
321321

322-
Assert.IsTrue(difference.HasFlag(Relationships.References));
323-
Assert.IsFalse(difference.HasFlag(Relationships.Children));
324-
Assert.IsFalse(difference.HasFlag(Relationships.Parents));
322+
Assert.IsTrue(difference.HasFlag(AssociationTypes.References));
323+
Assert.IsFalse(difference.HasFlag(AssociationTypes.Children));
324+
Assert.IsFalse(difference.HasFlag(AssociationTypes.Parents));
325325

326326
}
327327

OnTopic.Tests/ViewModels/AscendentTopicViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace OnTopic.Tests.ViewModels {
1111
| VIEW MODEL: ASCENDENT
1212
\---------------------------------------------------------------------------------------------------------------------------*/
1313
/// <summary>
14-
/// Provides a simple view model with a single property (<see cref="Parent"/>) for mapping ascendent relationships.
14+
/// Provides a simple view model with a single property (<see cref="Parent"/>) for mapping ascendent associations.
1515
/// </summary>
1616
/// <remarks>
1717
/// <para>
@@ -24,7 +24,7 @@ namespace OnTopic.Tests.ViewModels {
2424
/// </remarks>
2525
public class AscendentTopicViewModel: KeyOnlyTopicViewModel {
2626

27-
[Follow(Relationships.Parents)]
27+
[Follow(AssociationTypes.Parents)]
2828
public AscendentTopicViewModel? Parent { get; set; }
2929

3030
} //Class

OnTopic.Tests/ViewModels/CircularTopicViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ namespace OnTopic.Tests.ViewModels {
1919
/// </remarks>
2020
public class CircularTopicViewModel {
2121

22-
[Follow(Relationships.Parents)]
22+
[Follow(AssociationTypes.Parents)]
2323
public CircularTopicViewModel? Parent { get; set; }
2424

25-
[Follow(Relationships.Children | Relationships.Parents)]
25+
[Follow(AssociationTypes.Children | AssociationTypes.Parents)]
2626
public Collection<CircularTopicViewModel> Children { get; } = new();
2727

2828
} //Class

OnTopic.Tests/ViewModels/DescendentTopicViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace OnTopic.Tests.ViewModels {
1313
| VIEW MODEL: DESCENDENT
1414
\---------------------------------------------------------------------------------------------------------------------------*/
1515
/// <summary>
16-
/// Provides a simple view model with a single property (<see cref="Children"/>) for mapping descending relationships.
16+
/// Provides a simple view model with a single property (<see cref="Children"/>) for mapping descending associations.
1717
/// </summary>
1818
/// <remarks>
1919
/// <para>
@@ -26,7 +26,7 @@ namespace OnTopic.Tests.ViewModels {
2626
/// </remarks>
2727
public record DescendentTopicViewModel: TopicViewModel {
2828

29-
[Follow(Relationships.Children)]
29+
[Follow(AssociationTypes.Children)]
3030
public TopicViewModelCollection<DescendentTopicViewModel> Children { get; } = new();
3131

3232
} //Class

OnTopic.Tests/ViewModels/Metadata/ContentTypeDescriptorTopicViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class ContentTypeDescriptorTopicViewModel {
2323
public Collection<AttributeDescriptorTopicViewModel> AttributeDescriptors { get; } = new();
2424

2525
[Collection(CollectionType.MappedCollection)]
26-
[Follow(Relationships.None)]
26+
[Follow(AssociationTypes.None)]
2727
public Collection<ContentTypeDescriptorTopicViewModel> PermittedContentTypes { get; } = new();
2828

2929
} //Class

OnTopic.Tests/ViewModels/RelationTopicViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace OnTopic.Tests.ViewModels {
2525
/// </remarks>
2626
public class RelationTopicViewModel: KeyOnlyTopicViewModel {
2727

28-
[Follow(Relationships.Children)]
28+
[Follow(AssociationTypes.Children)]
2929
public Collection<RelationTopicViewModel> Cousins { get; } = new();
3030

3131
} //Class

OnTopic.Tests/ViewModels/RelationWithChildrenTopicViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace OnTopic.Tests.ViewModels {
2525
/// </remarks>
2626
public class RelationWithChildrenTopicViewModel: RelationTopicViewModel {
2727

28-
[Follow(Relationships.Relationships)]
28+
[Follow(AssociationTypes.Relationships)]
2929
public Collection<RelationWithChildrenTopicViewModel> Children { get; } = new();
3030

3131
} //Class

OnTopic.ViewModels/TopicViewModel.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ public record TopicViewModel: ITopicViewModel {
8686
/// </summary>
8787
/// <remarks>
8888
/// If the current <see cref="TopicViewModel"/> is being mapped as part of another <see cref="TopicViewModel"/>, then the
89-
/// <see cref="Parent"/> property will only be mapped if that relationship includes a <see cref="FollowAttribute"/>
90-
/// with a value including <see cref="Relationships.Parents"/>. If it does, all <see cref="Parent"/> topics will be mapped
91-
/// up to the root of the site. No other relationships on the <see cref="Parent"/> view models will be mapped, even if
92-
/// they are annotated with a <see cref="FollowAttribute"/>.
89+
/// <see cref="Parent"/> property will only be mapped if that association includes a <see cref="FollowAttribute"/> with a
90+
/// value including <see cref="AssociationTypes.Parents"/>. If it does, all <see cref="Parent"/> topics will be mapped up
91+
/// to the root of the site. No other associations on the <see cref="Parent"/> view models will be mapped, even if they
92+
/// are annotated with a <see cref="FollowAttribute"/>.
9393
/// </remarks>
94-
[Follow(Relationships.Parents)]
94+
[Follow(AssociationTypes.Parents)]
9595
public TopicViewModel? Parent { get; init; }
9696

9797
} //Class

OnTopic/Mapping/Annotations/Relationships.cs renamed to OnTopic/Mapping/Annotations/AssociationTypes.cs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,34 @@
99
namespace OnTopic.Mapping.Annotations {
1010

1111
/*============================================================================================================================
12-
| ENUM: RELATIONSHIPS
12+
| ENUM: ASSOCIATION TYPES
1313
\---------------------------------------------------------------------------------------------------------------------------*/
1414
/// <summary>
15-
/// Allows one or more relationship types to be specified.
15+
/// Allows one or more associations types to be specified.
1616
/// </summary>
1717
/// <remarks>
1818
/// <para>
19-
/// The <see cref="TopicMappingService"/> and <see cref="FollowAttribute"/> use the <see cref="Relationships"/> enum to
20-
/// determine what relationships should be mapped—or followed as part of the mapping process. This helps constrain the
21-
/// scope of the object graph to only include the data needed for a given view, or vice verse. That said, the <see
22-
/// cref="Relationships"/> enum can be used any place where the code needs to model multiple types of relationships
23-
/// relevant to the <see cref="Topic"/> class and its view models.
19+
/// The <see cref="TopicMappingService"/> and <see cref="FollowAttribute"/> use the <see cref="AssociationTypes"/> enum to
20+
/// determine what associations should be mapped—or followedas part of the mapping process. This helps constrain the
21+
/// scope of the object graph to only include the data needed for a given view, or vice verse. That said, the <see cref="
22+
/// AssociationTypes"/> enum can be used any place where the code needs to model multiple types of associations relevant
23+
/// to the <see cref="Topic"/> class and its view models.
2424
/// </para>
2525
/// <para>
26-
/// This differs from <see cref="CollectionType"/>, which only allows <i>one</i> collection to be specified.
26+
/// The<see cref="AssociationTypes"/> enum is <i>similar</i> to the<see cref="CollectionType"/> enum—and, in fact, they
27+
/// share several members. They differ in that <see cref="CollectionType"/> <i>exclusively</i> models <i>collections</i>,
28+
/// whereas <see cref="AssociationTypes"/> also models other types of associations, such as <see cref="Topic.Parent"/>,
29+
/// and <see cref="AssociationTypes"/> allows <i>multiple</i> associations to be selected.
2730
/// </para>
2831
/// </remarks>
2932
[Flags]
30-
public enum Relationships {
33+
public enum AssociationTypes {
3134

3235
/*==========================================================================================================================
3336
| NONE
3437
\-------------------------------------------------------------------------------------------------------------------------*/
3538
/// <summary>
36-
/// Do not follow any relationships.
39+
/// Do not follow any associations.
3740
/// </summary>
3841
None = 0,
3942

@@ -65,8 +68,8 @@ public enum Relationships {
6568
| INCOMING RELATIONSHIPS
6669
\-------------------------------------------------------------------------------------------------------------------------*/
6770
/// <summary>
68-
/// Map <see cref="Topic.IncomingRelationships"/> references, or properties marked as <see
69-
/// cref="CollectionType.IncomingRelationship"/>.
71+
/// Map <see cref="Topic.IncomingRelationships"/> references, or properties marked as <see cref="CollectionType.
72+
/// IncomingRelationship"/>.
7073
/// </summary>
7174
IncomingRelationships = 1 << 3,
7275

@@ -89,8 +92,8 @@ public enum Relationships {
8992
/// Map topic pointer references, such as <see cref="Topic.BaseTopic"/>.
9093
/// </summary>
9194
/// <remarks>
92-
/// By convention, <see cref="References"/> types refer to a <see cref="AttributeDescriptor"/>, <see
93-
/// cref="AttributeKeyAttribute.Key"/>, or property identifier ending in <c>Id</c>.
95+
/// By convention, <see cref="References"/> types refer to a <see cref="AttributeDescriptor"/>, <see cref="
96+
/// AttributeKeyAttribute.Key"/>, or property identifier ending in <c>Id</c>.
9497
/// </remarks>
9598
References = 1 << 5,
9699

0 commit comments

Comments
 (0)