-
Notifications
You must be signed in to change notification settings - Fork 2
/
ITopicRepository.cs
236 lines (210 loc) · 12.9 KB
/
ITopicRepository.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/*==============================================================================================================================
| Author Ignia, LLC
| Client Ignia, LLC
| Project Topics Library
\=============================================================================================================================*/
using OnTopic.Metadata;
namespace OnTopic.Repositories {
/*============================================================================================================================
| INTERFACE: TOPIC REPOSITORY
\---------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Defines the interface for reading and writing topics from a data storage repository.
/// </summary>
public interface ITopicRepository {
/*==========================================================================================================================
| EVENT HANDLERS
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Raised after a <see cref="Topic"/> is loaded from the <see cref="ITopicRepository"/> as part of a <see cref="
/// ITopicRepository.Load(String?, Topic?, Boolean)"/> operation, or one of its overloads.
/// </summary>
/// <remarks>
/// The <see cref="TopicLoaded"/> event should only be raised when a new <see cref="Topic"/> is loaded from the underlying
/// persistence store. It should not be loaded, for example, if a value is loaded from the cache, or a <c>topicId</c> is
/// queried from the database. Given this, this event will need to be raised in actual implementations, since it is
/// specific to the business logic of each <see cref="ITopicRepository"/>.
/// </remarks>
event EventHandler<TopicLoadEventArgs> TopicLoaded;
/// <summary>
/// Raised after a <see cref="Topic"/> is saved in the <see cref="ITopicRepository"/> as part of a <see cref="
/// ITopicRepository.Save(Topic, Boolean)"/> operation.
/// </summary>
event EventHandler<TopicSaveEventArgs> TopicSaved;
/// <summary>
/// Raised after a <see cref="Topic"/> is deleted from the <see cref="ITopicRepository"/> as part of a <see cref="
/// ITopicRepository.Delete(Topic, Boolean)"/> operation.
/// </summary>
event EventHandler<TopicEventArgs> TopicDeleted;
/// <summary>
/// Raised after a <see cref="Topic"/> is moved within the <see cref="ITopicRepository"/> as part of a <see cref="
/// ITopicRepository.Move(Topic, Topic, Topic?)"/> operation.
/// </summary>
event EventHandler<TopicMoveEventArgs> TopicMoved;
/// <summary>
/// Raised after a <see cref="Topic"/> is renamed as ppart of a <see cref="ITopicRepository.Save(Topic, Boolean)"/>
/// operation.
/// </summary>
event EventHandler<TopicRenameEventArgs> TopicRenamed;
/// <inheritdoc cref="TopicDeleted"/>
[ExcludeFromCodeCoverage]
[Obsolete($"The {nameof(DeleteEvent)} has been renamed to {nameof(TopicDeleted)}")]
event EventHandler<DeleteEventArgs> DeleteEvent;
/// <inheritdoc cref="TopicMoved"/>
[ExcludeFromCodeCoverage]
[Obsolete($"The {nameof(MoveEvent)} has been renamed to {nameof(TopicMoved)}")]
event EventHandler<DeleteEventArgs> MoveEvent;
/// <inheritdoc cref="TopicRenamed"/>
[ExcludeFromCodeCoverage]
[Obsolete($"The {nameof(RenameEvent)} has been renamed to {nameof(TopicRenamed)}")]
event EventHandler<RenameEventArgs> RenameEvent;
/*==========================================================================================================================
| GET CONTENT TYPE DESCRIPTORS
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Retrieves a collection of Content Type Descriptor objects from the configuration section of the data provider.
/// </summary>
ContentTypeDescriptorCollection GetContentTypeDescriptors();
/*==========================================================================================================================
| METHOD: LOAD
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Loads the entire root topic graph, including all descendants.
/// </summary>
/// <returns>A topic object.</returns>
public Topic? Load() => Load(-1);
/// <summary>
/// Loads a <see cref="Topic"/> (and, optionally, all of its descendants) based on the specified <paramref name="topicId"
/// />.
/// </summary>
/// <param name="topicId">The topic identifier.</param>
/// <param name="referenceTopic">
/// When loading a single topic or branch, offers a reference topic graph that can be used to ensure that topic
/// associations—such as references, relationships, and <see cref="Topic.Parent"/>—are integrated with existing entities.
/// </param>
/// <param name="isRecursive">Determines whether or not to recurse through and load a topic's children.</param>
/// <returns>A topic object.</returns>
Topic? Load(int topicId, Topic? referenceTopic = null, bool isRecursive = true);
/// <summary>
/// Loads a <see cref="Topic"/> (and, optionally, all of its descendants) based on the specified <paramref name="uniqueKey
/// "/>.
/// </summary>
/// <param name="uniqueKey">The fully-qualified unique topic key.</param>
/// <param name="referenceTopic">
/// When loading a single topic or branch, offers a reference topic graph that can be used to ensure that topic
/// associations—such as references, relationships, and <see cref="Topic.Parent"/>—are integrated with existing entities.
/// </param>
/// <param name="isRecursive">Determines whether or not to recurse through and load a topic's children.</param>
/// <returns>A topic object.</returns>
Topic? Load(string uniqueKey, Topic? referenceTopic = null, bool isRecursive = true);
/// <inheritdoc cref="Load(Int32, Topic?, Boolean)"/>
[ExcludeFromCodeCoverage]
[Obsolete("This overload has been removed in preference for Load(string, Topic, Boolean).")]
Topic? Load(string? uniqueKey, bool isRecursive);
/// <summary>
/// Loads a specific version of a <see cref="Topic"/> based on its <paramref name="topicId"/> and <paramref name="version
/// "/>.
/// </summary>
/// <remarks>
/// This overload does not accept an argument for recursion; it will only load a single instance of a version. Further,
/// it will only load versions for which the unique identifier is known.
/// </remarks>
/// <param name="topicId">The topic identifier.</param>
/// <param name="version">The version.</param>
/// <param name="referenceTopic">
/// When loading a single topic or branch, offers a reference topic graph that can be used to ensure that topic
/// associations—such as references, relationships, and <see cref="Topic.Parent"/>—are integrated with existing entities.
/// </param>
/// <returns>A topic object.</returns>
Topic? Load(int topicId, DateTime version, Topic? referenceTopic = null);
/// <inheritdoc cref="Load(Int32, DateTime, Topic)"/>
Topic? Load(Topic topic, DateTime version);
/*==========================================================================================================================
| METHOD: ROLLBACK
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Rolls back the supplied <paramref name="topic"/> to a particular point in its version history by reloading legacy
/// attributes and then saving the new version.
/// </summary>
/// <param name="topic">The current version of the <see cref="Topic"/> to rollback.</param>
/// <param name="version">The selected Date/Time for the version to which to roll back.</param>
/// <requires
/// description="The version requested for rollback does not exist in the version history."
/// exception="T:System.ArgumentNullException">
/// !VersionHistory.Contains(version)
/// </requires>
void Rollback(Topic topic, DateTime version);
/*==========================================================================================================================
| METHOD: REFRESH
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Updates the topic graph represented by the <paramref name="referenceTopic"/> by loading any changes <paramref name="
/// since"/> the specified <see cref="DateTime"/>.
/// </summary>
/// <remarks>
/// The <see cref="Refresh(Topic, DateTime)"/> method is intended to provide basic synchronization of core attributes,
/// indexed attributes, extended attributes, relationships, and topic references. It is not expected to handle deletes
/// or reordering of topics.
/// </remarks>
void Refresh(Topic referenceTopic, DateTime since);
/*==========================================================================================================================
| METHOD: SAVE
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Saves the <paramref name="topic"/> (and, optionally, its descendants) to the persistence store.
/// </summary>
/// <param name="topic">The <see cref="Topic"/> object.</param>
/// <param name="isRecursive">
/// Boolean indicator nothing whether to recurse through the topic's descendants and save them as well.
/// </param>
/// <requires description="The topic to save must be specified." exception="T:System.ArgumentNullException">
/// topic is not null
/// </requires>
/// <exception cref="ArgumentNullException">topic</exception>
void Save(Topic topic, bool isRecursive = false);
/// <inheritdoc cref="Save(Topic, Boolean)"/>
[ExcludeFromCodeCoverage]
[Obsolete("The 'isDraft' argument of the Save() method has been removed.")]
int Save(Topic topic, bool isRecursive, bool isDraft);
/*==========================================================================================================================
| METHOD: MOVE
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Moves the <paramref name="topic"/> from its existing parent to a <paramref name="target"/> parent, optionally placing
/// it after a supplied <paramref name="sibling"/> topic.
/// </summary>
/// <remarks>
/// May optionally specify a <paramref name="sibling"/> topic. If specified, it is expected that the <see cref="Topic"/>
/// will be placed immediately after the <paramref name="sibling"/>.
/// </remarks>
/// <param name="topic">The <see cref="Topic"/> object to be moved.</param>
/// <param name="target">The target <see cref="Topic"/> object under which to move the source <see cref="Topic"/>.</param>
/// <param name="sibling">
/// An optional <see cref="Topic"/> object representing a sibling adjacent to which the source <see cref="Topic"/> should
/// be moved.
/// </param>
/// <returns>Boolean value representing whether the operation completed successfully.</returns>
/// <requires
/// description="The target under which to move the topic must be provided."
/// exception="T:System.ArgumentNullException">
/// topic is not null
/// </requires>
void Move(Topic topic, Topic target, Topic? sibling = null);
/*==========================================================================================================================
| METHOD: DELETE
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Deletes the provided <paramref name="topic"/> from the topic tree.
/// </summary>
/// <param name="topic">The <see cref="Topic"/> object to delete.</param>
/// <param name="isRecursive">
/// Boolean indicator nothing whether to recurse through the <see cref="Topic"/>'s descendants and delete them as well. If set to false
/// and the topic has children, including any nested topics, an exception will be thrown. The default is false.
/// </param>
/// <requires description="The topic to delete must be provided." exception="T:System.ArgumentNullException">
/// topic is not null
/// </requires>
/// <exception cref="ArgumentNullException">topic</exception>
void Delete(Topic topic, bool isRecursive = false);
} //Interface
} //Namespace