Skip to content

Commit 058ff76

Browse files
authored
Merge pull request #7 from Ignia/MappingUpdate
Topic Mapping Service Update (3.6)
2 parents 590fda1 + 02d003f commit 058ff76

128 files changed

Lines changed: 3668 additions & 1851 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Ignia.Topics.Data.Caching/CachedTopicRepository.cs

Lines changed: 16 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Diagnostics.Contracts;
88
using Ignia.Topics.Collections;
99
using Ignia.Topics.Repositories;
10+
using Ignia.Topics.Querying;
1011

1112
namespace Ignia.Topics.Data.Caching {
1213

@@ -50,6 +51,11 @@ public CachedTopicRepository(ITopicRepository dataProvider) : base() {
5051
\-----------------------------------------------------------------------------------------------------------------------*/
5152
_dataProvider = dataProvider;
5253

54+
/*------------------------------------------------------------------------------------------------------------------------
55+
| Ensure topics are loaded
56+
\-----------------------------------------------------------------------------------------------------------------------*/
57+
_cache = _dataProvider.Load();
58+
5359
}
5460

5561
/*==========================================================================================================================
@@ -64,54 +70,35 @@ public CachedTopicRepository(ITopicRepository dataProvider) : base() {
6470
| METHOD: LOAD
6571
\-------------------------------------------------------------------------------------------------------------------------*/
6672
/// <summary>
67-
/// Loads a topic (and, optionally, all of its descendents) based on the specified unique identifier.
73+
/// Loads a topic (and, optionally, all of its descendants) based on the specified unique identifier.
6874
/// </summary>
6975
/// <param name="topicId">The topic identifier.</param>
7076
/// <param name="isRecursive">Determines whether or not to recurse through and load a topic's children.</param>
7177
/// <returns>A topic object.</returns>
7278
public override Topic Load(int topicId, bool isRecursive = true) {
7379

7480
/*------------------------------------------------------------------------------------------------------------------------
75-
| Validate contracts
81+
| Handle request for entire tree
7682
\-----------------------------------------------------------------------------------------------------------------------*/
77-
Contract.Ensures(Contract.Result<Topic>() != null);
78-
79-
/*------------------------------------------------------------------------------------------------------------------------
80-
| Ensure topics are loaded
81-
\-----------------------------------------------------------------------------------------------------------------------*/
82-
if (_cache == null) {
83-
_cache = _dataProvider.Load();
83+
if (topicId < 0) {
84+
return _cache;
8485
}
8586

8687
/*------------------------------------------------------------------------------------------------------------------------
87-
| Lookup by TopicId
88+
| Recursive search
8889
\-----------------------------------------------------------------------------------------------------------------------*/
89-
if (topicId >= 0) {
90-
return GetTopic(_cache, topicId);
91-
}
92-
93-
/*------------------------------------------------------------------------------------------------------------------------
94-
| Return entire cache
95-
\-----------------------------------------------------------------------------------------------------------------------*/
96-
return _cache;
90+
return _cache.FindFirst(t => t.Id.Equals(topicId));
9791

9892
}
9993

10094
/// <summary>
101-
/// Loads a topic (and, optionally, all of its descendents) based on the specified key name.
95+
/// Loads a topic (and, optionally, all of its descendants) based on the specified key name.
10296
/// </summary>
10397
/// <param name="topicKey">The topic key.</param>
10498
/// <param name="isRecursive">Determines whether or not to recurse through and load a topic's children.</param>
10599
/// <returns>A topic object.</returns>
106100
public override Topic Load(string topicKey = null, bool isRecursive = true) {
107101

108-
/*------------------------------------------------------------------------------------------------------------------------
109-
| Ensure topics are loaded
110-
\-----------------------------------------------------------------------------------------------------------------------*/
111-
if (_cache == null) {
112-
_cache = _dataProvider.Load();
113-
}
114-
115102
/*------------------------------------------------------------------------------------------------------------------------
116103
| Lookup by TopicKey
117104
\-----------------------------------------------------------------------------------------------------------------------*/
@@ -142,45 +129,6 @@ public override Topic Load(string topicKey = null, bool isRecursive = true) {
142129
/*==========================================================================================================================
143130
| METHOD: GET TOPIC
144131
\-------------------------------------------------------------------------------------------------------------------------*/
145-
/// <summary>
146-
/// Retrieves a topic object based on the current topic scope and the specified integer identifier.
147-
/// </summary>
148-
/// <remarks>
149-
/// If the specified ID does not match the identifier for the current topic, its children will be searched.
150-
/// </remarks>
151-
/// <param name="sourceTopic">The root topic to search from.</param>
152-
/// <param name="topicId">The integer identifier for the topic.</param>
153-
/// <returns>The topic or null, if the topic is not found.</returns>
154-
/// <requires description="The topicId is expected to be a positive integer." exception="T:System.ArgumentException">
155-
/// topicId &lt;= 0
156-
/// </requires>
157-
private Topic GetTopic(Topic sourceTopic, int topicId) {
158-
159-
/*------------------------------------------------------------------------------------------------------------------------
160-
| Validate input
161-
\-----------------------------------------------------------------------------------------------------------------------*/
162-
Contract.Requires<ArgumentException>(topicId >= 0, "The topicId is expected to be a non-negative integer.");
163-
164-
/*------------------------------------------------------------------------------------------------------------------------
165-
| Return if current
166-
\-----------------------------------------------------------------------------------------------------------------------*/
167-
if (sourceTopic.Id == topicId) return sourceTopic;
168-
169-
/*------------------------------------------------------------------------------------------------------------------------
170-
| Iterate through children
171-
\-----------------------------------------------------------------------------------------------------------------------*/
172-
foreach (var childTopic in sourceTopic.Children) {
173-
var foundTopic = GetTopic(childTopic, topicId);
174-
if (foundTopic != null) return foundTopic;
175-
}
176-
177-
/*------------------------------------------------------------------------------------------------------------------------
178-
| Return null if not found
179-
\-----------------------------------------------------------------------------------------------------------------------*/
180-
return null;
181-
182-
}
183-
184132
/// <summary>
185133
/// Retrieves a topic object based on the specified partial or full (prefixed) topic key.
186134
/// </summary>
@@ -211,7 +159,7 @@ private Topic GetTopic(Topic sourceTopic, string uniqueKey) {
211159
| Provide implicit root
212160
>-------------------------------------------------------------------------------------------------------------------------
213161
| ###NOTE JJC080313: While a root topic is required by the data structure, it should be implicit from the perspective of
214-
| the calling application. A developer should be able to call GetTopic("Namepace:TopicPath") to get to a topic, without
162+
| the calling application. A developer should be able to call GetTopic("Namespace:TopicPath") to get to a topic, without
215163
| needing to be aware of the root.
216164
\-----------------------------------------------------------------------------------------------------------------------*/
217165
if (
@@ -261,8 +209,8 @@ private Topic GetTopic(Topic sourceTopic, string uniqueKey) {
261209
/// <param name="isDraft">Boolean indicator as to the topic's publishing status.</param>
262210
/// <returns>The integer return value from the execution of the <c>topics_UpdateTopic</c> stored procedure.</returns>
263211
/// <exception cref="Exception">
264-
/// The Content Type <c>topic.Attributes.GetValue(ContentType, Page)</c> referenced by <c>topic.Key</c> could not be found under
265-
/// Configuration:ContentTypes. There are <c>TopicRepository.ContentTypes.Count</c> ContentTypes in the Repository.
212+
/// The Content Type <c>topic.Attributes.GetValue(ContentType, Page)</c> referenced by <c>topic.Key</c> could not be found
213+
/// under Configuration:ContentTypes. There are <c>TopicRepository.ContentTypes.Count</c> ContentTypes in the Repository.
266214
/// </exception>
267215
/// <exception cref="Exception">
268216
/// Failed to save Topic <c>topic.Key</c> (<c>topic.Id</c>) via

Ignia.Topics.Data.Caching/Ignia.Topics.Data.Caching.csproj

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<AppDesignerFolder>Properties</AppDesignerFolder>
1111
<RootNamespace>Ignia.Topics.Data.Caching</RootNamespace>
1212
<AssemblyName>Ignia.Topics.Data.Caching</AssemblyName>
13-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
1414
<FileAlignment>512</FileAlignment>
1515
<NuGetPackageImportStamp>
1616
</NuGetPackageImportStamp>
@@ -45,6 +45,17 @@
4545
<CodeContractsBeingOptimisticOnExternal>True</CodeContractsBeingOptimisticOnExternal>
4646
<CodeContractsRuntimeCheckingLevel>Full</CodeContractsRuntimeCheckingLevel>
4747
<CodeContractsAnalysisWarningLevel>0</CodeContractsAnalysisWarningLevel>
48+
<TargetFrameworkProfile />
49+
<ShouldCreateLogs>True</ShouldCreateLogs>
50+
<AdvancedSettingsExpanded>False</AdvancedSettingsExpanded>
51+
<UpdateAssemblyVersion>True</UpdateAssemblyVersion>
52+
<UpdateAssemblyFileVersion>True</UpdateAssemblyFileVersion>
53+
<UpdateAssemblyInfoVersion>False</UpdateAssemblyInfoVersion>
54+
<AssemblyVersionSettings>None.None.Increment.None</AssemblyVersionSettings>
55+
<UpdatePackageVersion>False</UpdatePackageVersion>
56+
<AssemblyInfoVersionType>SettingsVersion</AssemblyInfoVersionType>
57+
<InheritWinAppVersionFrom>None</InheritWinAppVersionFrom>
58+
<AssemblyFileVersionSettings>None.None.Increment.None</AssemblyFileVersionSettings>
4859
</PropertyGroup>
4960
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
5061
<DebugSymbols>true</DebugSymbols>
@@ -66,6 +77,8 @@
6677
<CodeContractsNecessaryEnsures>False</CodeContractsNecessaryEnsures>
6778
<CodeContractsShowSquigglies>False</CodeContractsShowSquigglies>
6879
<CodeContractsReferenceAssembly>%28none%29</CodeContractsReferenceAssembly>
80+
<RunCodeAnalysis>true</RunCodeAnalysis>
81+
<LangVersion>latest</LangVersion>
6982
</PropertyGroup>
7083
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
7184
<DebugType>pdbonly</DebugType>
Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,29 @@
1-
using System.Reflection;
2-
using System.Runtime.CompilerServices;
1+
/*==============================================================================================================================
2+
| Author Ignia, LLC
3+
| Client Ignia, LLC
4+
| Project Topics Library
5+
\=============================================================================================================================*/
6+
using System;
7+
using System.Reflection;
38
using System.Runtime.InteropServices;
49

5-
// General Information about an assembly is controlled through the following
6-
// set of attributes. Change these attribute values to modify the information
7-
// associated with an assembly.
8-
[assembly: AssemblyTitle("Ignia.Topics.Data.Caching")]
9-
[assembly: AssemblyDescription("")]
10+
/*==============================================================================================================================
11+
| DEFINE ASSEMBLY ATTRIBUTES
12+
>===============================================================================================================================
13+
| Declare and define attributes used in the compiling of the finished assembly.
14+
\-----------------------------------------------------------------------------------------------------------------------------*/
15+
[assembly: AssemblyCompany("Ignia, LLC")]
16+
[assembly: AssemblyCopyright("Copyright © 2018 Ignia, LLC")]
17+
[assembly: AssemblyProduct("Ignia OnTopic Library")]
18+
[assembly: AssemblyTitle("OnTopic Cached Repository")]
19+
[assembly: AssemblyDescription("Provides a caching decorator for ITopicRepository implementations.")]
1020
[assembly: AssemblyConfiguration("")]
11-
[assembly: AssemblyCompany("")]
12-
[assembly: AssemblyProduct("Ignia.Topics.Data.Caching")]
13-
[assembly: AssemblyCopyright("Copyright © 2017")]
1421
[assembly: AssemblyTrademark("")]
1522
[assembly: AssemblyCulture("")]
16-
17-
// Setting ComVisible to false makes the types in this assembly not visible
18-
// to COM components. If you need to access a type in this assembly from
19-
// COM, set the ComVisible attribute to true on that type.
2023
[assembly: ComVisible(false)]
21-
22-
// The following GUID is for the ID of the typelib if this project is exposed to COM
24+
[assembly: AssemblyVersion("3.6.1762.0")]
25+
[assembly: AssemblyFileVersion("3.5.1794.0")]
26+
[assembly: CLSCompliant(true)]
2327
[assembly: Guid("206b7f91-ca25-4e9d-9576-60d2e54a2c0a")]
2428

25-
// Version information for an assembly consists of the following four values:
26-
//
27-
// Major Version
28-
// Minor Version
29-
// Build Number
30-
// Revision
31-
//
32-
// You can specify all the values or you can default the Build and Revision Numbers
33-
// by using the '*' as shown below:
34-
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("2.0.0.0")]
36-
[assembly: AssemblyFileVersion("2.0.0.0")]
29+

Ignia.Topics.Data.Sql.Database/Ignia.Topics.Data.Sql.Database.sqlproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<ModelCollation>1033,CI</ModelCollation>
1818
<DefaultFileStructure>BySchemaAndSchemaType</DefaultFileStructure>
1919
<DeployToDatabase>True</DeployToDatabase>
20-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
20+
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
2121
<TargetLanguage>CS</TargetLanguage>
2222
<AppDesignerFolder>Properties</AppDesignerFolder>
2323
<SqlServerVerification>False</SqlServerVerification>
@@ -27,6 +27,7 @@
2727
<DefaultFilegroup>PRIMARY</DefaultFilegroup>
2828
<GenerateCreateScript>False</GenerateCreateScript>
2929
<DacApplicationName>OnTopic</DacApplicationName>
30+
<TargetFrameworkProfile />
3031
</PropertyGroup>
3132
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
3233
<OutputPath>bin\Release\</OutputPath>

Ignia.Topics.Data.Sql.Database/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ The `Ignia.Topics.Data.Sql.Database` provides a default schema for supporting th
55
66
## Tables
77
The following is a summary of the most relevant tables.
8-
- **[`topics_Topics`](dbo/Tables/topics_Topics.sql)**: Represents the core hiearchy of topics, encoded in a nested set format.
8+
- **[`topics_Topics`](dbo/Tables/topics_Topics.sql)**: Represents the core hierarchy of topics, encoded in a nested set format.
99
- **[`topics_TopicAttributes`](dbo/Tables/topics_Topics.sql)**: Represents key/value pairs of topic attributes, including historical versions.
1010
- **[`topics_Blob`](dbo/Tables/topics_Blob.sql)**: Represents an XML-based blob of non-indexed attributes, which are too long for `topics_TopicAttributes`.
1111
- **[`topics_Relationships`](dbo/Tables/topics_Relationships.sql)**: Represents relationships between topics, segmented by namespace.
@@ -24,7 +24,7 @@ The following is a summary of the most relevant stored procedures.
2424
- **[`topics_CreateTopic`](dbo/Stored%20Procedures/topics_CreateTopic.sql)**: Creates a new topic based on a `@ParentId`, an array of `@Attributes`, and an XML `@Blob`. Returns a new `@@Identity`.
2525
- **[`topics_DeleteTopic`](dbo/Stored%20Procedures/topics_DeleteTopic.sql)**: Deletes an existing topic based on a `@Id`.
2626
- **[`topics_MoveTopic`](dbo/Stored%20Procedures/topics_MoveTopic.sql)**: Moves an existing topic based on an `@Id`, `@ParentId`, and `@SiblingId`.
27-
- **[`topics_UpdateTopic`](dbo/Stored%20Procedures/topics_UpdateTopic.sql)**: Updates an existing topic based on an `@Id`, an array of `@Attributes`, and a `@Blob`. Optionally deletes all relationships; these will need to be readded using `topics_PersistRelations`. Old attributes are persisted as previous versions.
27+
- **[`topics_UpdateTopic`](dbo/Stored%20Procedures/topics_UpdateTopic.sql)**: Updates an existing topic based on an `@Id`, an array of `@Attributes`, and a `@Blob`. Optionally deletes all relationships; these will need to be re-added using `topics_PersistRelations`. Old attributes are persisted as previous versions.
2828
- **[`topics_PersistRelations`](dbo/Stored%20Procedures/topics_PersistRelations.sql)**: Associates a relationship with a topic based on a `@Source_TopicId`, array of `@Target_TopicIds`, and `@RelationshipTypeID` (which can be any string label).
2929

3030
## Views

Ignia.Topics.Data.Sql.Database/dbo/Stored Procedures/topics_CreateTopic.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
--
44
-- Purpose Creates a new topic.
55
--
6-
-- History Casey Margell 04062009 Initial Creation baseaed on code from Celko's Sql For Smarties.
6+
-- History Casey Margell 04062009 Initial Creation based on code from Celko's SQL For Smarties.
77
-- Jeremy Caney 05282010 Reformatted code and refactored identifiers for improved readability.
88
-- Katherine Trunkey 08142014 Updated topic_TopicAttributes insertion script to use uncommon, multi-character delimiters
99
-- rather than a colon and semicolon in order to provide better escaping safety for @Attributes.

Ignia.Topics.Data.Sql.Database/dbo/Stored Procedures/topics_GetTopics.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- Purpose Gets the tree of current topics rooted FROM the provided TopicID. If no TopicID is provided then the sproc returns everything
55
-- under the topic with the lowest id.
66
--
7-
-- History Casey Margell 04062009 Initial Creation baseaed on code FROM Celko's Sql For Smarties.
7+
-- History Casey Margell 04062009 Initial Creation based on code FROM Celko's SQL For Smarties.
88
-- Jeremy Caney 07192009 Added support for AttributeID lookup.
99
-- Jeremy Caney 05282010 Reformatted code AND refactored identifiers for improved readability.
1010
-- Jeremy Caney 06072010 Added support for blob fields.

Ignia.Topics.Data.Sql.Database/dbo/Stored Procedures/topics_MoveTopic.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
-- Hedley Robertson 07062010 Added support for SiblingID (Ordering)
99
-- Hedley Robertson 08122010 Inline test cases, debugging statements and check for re-parenting;
1010
-- now avoids moving item to start of SET when sibling move requested
11-
-- and parentid has not changed
11+
-- and ParentId has not changed
1212
-- Hedley Robertson 08172010 Rebuilt with externalized MoveSubTree function
1313
-- Jeremy Caney 09222014 Updated logic for ParentID attribute to be based on Key, not ID
1414
-- Jeremy Caney 12092017 Refactored based on Celko's alternative formulation.
@@ -124,7 +124,7 @@ SET @Offset =
124124
-- MOVE SOURCE RANGE TO INSERTION POINT
125125
-----------------------------------------------------------------------------------------------------------------------------------------------
126126
-- The basic idea behind moving nodes is that we're going to a) shift the target subtree (@Parent) by the delta (@Offset) between its original
127-
-- position (@OriginalLeft, @OriginalRight) and the the target location (@InsertionPoint), while b) closing the gap left behind by shifting all
127+
-- position (@OriginalLeft, @OriginalRight) and the target location (@InsertionPoint), while b) closing the gap left behind by shifting all
128128
-- intermediate nodes by the width of the target subtree (@OriginalRange).
129129
-----------------------------------------------------------------------------------------------------------------------------------------------
130130
-- EXAMPLE: If we're moving a target subtree of width 12 down 26 nodes, then we'd a) subtract 26 (the @Offset) from all nodes between RangeLeft

0 commit comments

Comments
 (0)