Skip to content

Commit 0e2059a

Browse files
committed
Merge branch 'release/1.2.0'
This update builds off of OnTopic Library 4.3.0 in improving performance and reliability when importing and saving large topic graphs. Most notably, this includes the ability to dynamically update the content type and attribute schemas based on the in-memory topic graph, thus addressing potential conflicts between the current configuration and the imported configuration. This is especially critical when bootstrapping an empty database with a reference configuration, which is now supported. In addition, a number of updated have been made to better maintain referential integrity, such as support for implicit topic references—i.e., references that point to other topics. Those are now translated to unique topic keys on `Export()`, and then translated back to topic identifiers on `Import()`. Features - Support translating implicit topic references from `Topic.Id` to `Topic.GetUniqueKey()` on `Export()` (0993ea3) and then back to `Topic.Id` on `Import()` (37d7a82) in order to maintain referential integrity of topic references saved as attributes (2467351); this can be controlled through the new `ExportOptions.TranslateTopicPointers` option (b32304b). - Built-in support for resolving explicit references (such as relationships and `DerivedTopic`s) which point to topics which haven't yet been `Import()`ed; the `Import()` will attempt to resolve these once the graph has been fully imported (96f1473). Bug Fixes - Fixed bug in which `ParentID` and `TopicID` were included as part of `Export()`, which introduced referential integrity conflicts on `Import()`; this could result in `DerivedTopic`s being updated to point to different topics (60ab46b). Code Changes - Updated `Export()` to use newly centralized `Topic.GetByUniqueKey()` extension method instead of its own local helper function (930538e). - Updated `Import()` to use newly centralized `AttributeValueCollection.IsDirty()` instead of its own locally defined logic (b9143a5). - Updated `Import()` to use newly created `Topic.IsNew` property for detecting if topic references are valid (94f1efc). Maintenance - Updated various internal dependencies
2 parents ea10979 + 99b67ee commit 0e2059a

11 files changed

+491
-124
lines changed

GitVersion.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
assembly-versioning-scheme: MajorMinorPatch
2-
mode: ContinuousDelivery
3-
branches: {}
2+
mode: ContinuousDeployment
3+
branches:
4+
master:
5+
mode: ContinuousDelivery
46
ignore:
57
sha: []

OnTopic.Data.Transfer.Tests/DeserializationTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public void Deserialize_AttributeData_ReturnsExpectedResults() {
100100
var json = $"{{" +
101101
$"\"Key\":\"{sourceData.Key}\"," +
102102
$"\"Value\":null," +
103-
$"\"LastModified\":\"{sourceData.LastModified.ToString("o")}\"" +
103+
$"\"LastModified\":\"{sourceData.LastModified:o}\"" +
104104
$"}}";
105105

106106

@@ -153,7 +153,7 @@ public void Deserialize_TopicGraph_ReturnsExpectedResults() {
153153
$"{{" +
154154
$"\"Key\":\"{sourceAttributeData.Key}\"," +
155155
$"\"Value\":null," +
156-
$"\"LastModified\":\"{sourceAttributeData.LastModified.ToString("o")}\"" +
156+
$"\"LastModified\":\"{sourceAttributeData.LastModified:o}\"" +
157157
$"}}"+
158158
$"]," +
159159
$"\"Relationships\":[" +

OnTopic.Data.Transfer.Tests/ExportOptionsTest.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,32 @@ public void Export_TopicWithRelationships_ExcludesExternalReferences() {
9595

9696
}
9797

98+
/*==========================================================================================================================
99+
| TEST: EXPORT WITH TOPIC POINTERS: EXTERNAL TOPIC POINTER: EXPORTS UNIQUE KEY
100+
\-------------------------------------------------------------------------------------------------------------------------*/
101+
/// <summary>
102+
/// Creates a <see cref="Topic"/> with an arbitrary <see cref="AttributeValue"/> that points to another topic. Confirms
103+
/// that it is converted to a <c>UniqueKey</c> if valid, and otherwise left as is.
104+
/// </summary>
105+
[TestMethod]
106+
public void ExportWithTopicPointers_ExternalTopicPointer_ExportsUniqueKey() {
107+
108+
var parentTopic = TopicFactory.Create("Root", "Container", 5);
109+
var topic = TopicFactory.Create("Topic", "Container", parentTopic);
110+
111+
topic.Attributes.SetValue("SomeId", "5");
112+
113+
var topicData = topic.Export(
114+
new ExportOptions() {
115+
IncludeExternalReferences = true
116+
}
117+
);
118+
119+
topicData.Attributes.TryGetValue("SomeId", out var someAttribute);
120+
121+
Assert.AreEqual<string>("Root", someAttribute.Value);
122+
123+
}
124+
98125
} //Class
99126
} //Namespace

OnTopic.Data.Transfer.Tests/ImportOptionsTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ public void ImportAsReplace_TopicDataWithNestedTopic_DeletedOrphanedChildren() {
309309

310310
var topic = TopicFactory.Create("Test", "Container");
311311
var nestedTopics = TopicFactory.Create("Nested", "List", topic);
312-
var nestedTopic1 = TopicFactory.Create("Nested1", "Page", 1, nestedTopics);
312+
_ = TopicFactory.Create("Nested1", "Page", 1, nestedTopics);
313313
var nestedTopic2 = TopicFactory.Create("Nested2", "Page", 2, nestedTopics);
314314
var topicData = new TopicData() {
315315
Key = topic.Key,

OnTopic.Data.Transfer.Tests/LastModifiedImportStrategyTest.cs

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,21 @@ public class LastModifiedImportStrategyTest {
2727
private Tuple<Topic, TopicData> GetTopicWithNewerTopicData(
2828
DateTime? targetDate = null,
2929
DateTime? sourceDate = null,
30-
string sourceRelationshipKey = null,
3130
bool isDirty = true
3231
) {
3332

3433
var topic = TopicFactory.Create("Test", "Container", 1);
35-
var relatedTopic = TopicFactory.Create("Related", "Container");
3634
var topicData = new TopicData() {
3735
Key = topic.Key,
3836
UniqueKey = topic.GetUniqueKey(),
3937
ContentType = "Page"
4038
};
41-
var relationshipData = new RelationshipData() {
42-
Key = "Related"
43-
};
4439

4540
targetDate ??= DateTime.Now.AddDays(1);
4641
sourceDate ??= DateTime.Now.AddHours(1);
47-
sourceRelationshipKey ??= relatedTopic.GetUniqueKey();
4842

4943
topic.Attributes.SetValue("LastModifiedBy", "Old Value", isDirty);
5044
topic.Attributes.SetValue("LastModified", targetDate.ToString(), isDirty);
51-
topic.Relationships.SetTopic("Related", relatedTopic);
5245

5346
topicData.Attributes.Add(
5447
new AttributeData() {
@@ -66,9 +59,6 @@ private Tuple<Topic, TopicData> GetTopicWithNewerTopicData(
6659
}
6760
);
6861

69-
topicData.Relationships.Add(relationshipData);
70-
relationshipData.Relationships.Add(sourceRelationshipKey);
71-
7262
return new Tuple<Topic, TopicData>(topic, topicData);
7363

7464
}
@@ -255,32 +245,6 @@ public void ImportAsTargetValue_TopicDataWithLastModified_SkipsExistingValue() {
255245

256246
}
257247

258-
/*==========================================================================================================================
259-
| TEST: IMPORT AS SYSTEM: TOPIC DATA WITH CHANGES: REPLACES NEWER VALUE
260-
\-------------------------------------------------------------------------------------------------------------------------*/
261-
/// <summary>
262-
/// Creates a <see cref="TopicData"/> with a newer <c>LastModified</c> value and ensures that the existing
263-
/// <c>LastModified</c> attribute value is overwritten when using <see cref="LastModifiedImportStrategy.System"/> and
264-
/// other values have changed.
265-
/// </summary>
266-
[TestMethod]
267-
public void ImportAsSystem_TopicDataWithChanges_ReplacesNewerValue() {
268-
269-
var tomorrow = DateTime.Now.AddDays(1);
270-
var nextWeek = DateTime.Now.AddDays(7);
271-
var (topic, topicData) = GetTopicWithNewerTopicData(tomorrow, nextWeek, "NewRelationship", false);
272-
273-
topic.Import(
274-
topicData,
275-
new ImportOptions() {
276-
LastModifiedStrategy = LastModifiedImportStrategy.System
277-
}
278-
);
279-
280-
Assert.IsTrue(topic.Attributes.GetDateTime("LastModified", nextWeek) <= DateTime.Now);
281-
282-
}
283-
284248
/*==========================================================================================================================
285249
| TEST: IMPORT AS SYSTEM: TOPIC DATA WITHOUT CHANGES: SKIPS EXISTING VALUE
286250
\-------------------------------------------------------------------------------------------------------------------------*/
@@ -294,7 +258,7 @@ public void ImportAsSystem_TopicDataWithoutChanges_SkipsExistingValue() {
294258

295259
var nextWeek = DateTime.Now.AddDays(7);
296260
var tomorrow = DateTime.Now.AddDays(1);
297-
var (topic, topicData) = GetTopicWithNewerTopicData(tomorrow, nextWeek, null, false);
261+
var (topic, topicData) = GetTopicWithNewerTopicData(tomorrow, nextWeek, false);
298262

299263
topic.Import(
300264
topicData,

OnTopic.Data.Transfer.Tests/OnTopic.Data.Transfer.Tests.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
11-
<PackageReference Include="MSTest.TestAdapter" Version="2.1.0" />
12-
<PackageReference Include="MSTest.TestFramework" Version="2.1.0" />
13-
<PackageReference Include="coverlet.collector" Version="1.2.0">
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
11+
<PackageReference Include="MSTest.TestAdapter" Version="2.1.1" />
12+
<PackageReference Include="MSTest.TestFramework" Version="2.1.1" />
13+
<PackageReference Include="coverlet.collector" Version="1.3.0">
1414
<PrivateAssets>all</PrivateAssets>
1515
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1616
</PackageReference>
17-
<PackageReference Include="OnTopic" Version="4.1.0" />
17+
<PackageReference Include="OnTopic" Version="4.3.0" />
1818
</ItemGroup>
1919

2020
<ItemGroup>

OnTopic.Data.Transfer.Tests/SerializationTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public void Serialize_AttributeData_ReturnsExpectedResults() {
9393
var expected = $"{{" +
9494
$"\"Key\":\"{attributeData.Key}\"," +
9595
$"\"Value\":null," +
96-
$"\"LastModified\":\"{attributeData.LastModified.ToString("o")}\"" +
96+
$"\"LastModified\":\"{attributeData.LastModified:o}\"" +
9797
$"}}";
9898

9999
var json = JsonSerializer.Serialize(attributeData);
@@ -143,7 +143,7 @@ public void Serialize_TopicGraph_ReturnsExpectedResults() {
143143
$"{{" +
144144
$"\"Key\":\"{attributeData.Key}\"," +
145145
$"\"Value\":null," +
146-
$"\"LastModified\":\"{attributeData.LastModified.ToString("o")}\"" +
146+
$"\"LastModified\":\"{attributeData.LastModified:o}\"" +
147147
$"}}"+
148148
$"]," +
149149
$"\"Relationships\":[" +

0 commit comments

Comments
 (0)