Skip to content

Commit 0e4037a

Browse files
author
Alexander van Delft
committed
Refactor DiagramCanvas and ArchitectureDiagram
1 parent 1fd9ebc commit 0e4037a

16 files changed

+304
-96
lines changed

CDP4Common/AutoGenDto/ArchitectureDiagram.cs

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ public override IDictionary<string, IEnumerable<Guid>> GetReferenceProperties()
110110

111111
dictionary.Add("ExcludedPerson", this.ExcludedPerson);
112112

113+
if (this.LockedBy != null)
114+
{
115+
dictionary.Add("LockedBy", new [] { this.LockedBy });
116+
}
117+
113118
if (this.Owner != null)
114119
{
115120
dictionary.Add("Owner", new [] { this.Owner });
@@ -162,6 +167,14 @@ public override bool TryRemoveReferences(IEnumerable<Guid> ids, out List<string>
162167
this.ExcludedPerson.Remove(id);
163168
break;
164169

170+
case "LockedBy":
171+
if (addModelErrors)
172+
{
173+
errors.Add($"Removed reference '{id}' from LockedBy property results in inconsistent ArchitectureDiagram.");
174+
result = false;
175+
}
176+
break;
177+
165178
case "Owner":
166179
if (addModelErrors)
167180
{
@@ -224,6 +237,14 @@ public override bool TryRemoveReferencesNotIn(IEnumerable<Guid> ids, out List<st
224237
}
225238
break;
226239

240+
case "LockedBy":
241+
if (referencedProperty.Value.Except(ids).Any())
242+
{
243+
errors.Add($"Removed reference '{referencedProperty.Key}' from LockedBy property results in inconsistent ArchitectureDiagram.");
244+
result = false;
245+
}
246+
break;
247+
227248
case "Owner":
228249
if (referencedProperty.Value.Except(ids).Any())
229250
{
@@ -262,6 +283,13 @@ public override bool HasMandatoryReferenceToAny(IEnumerable<Guid> ids)
262283
{
263284
switch (kvp.Key)
264285
{
286+
case "LockedBy":
287+
if (ids.Intersect(kvp.Value).Any())
288+
{
289+
result = true;
290+
}
291+
break;
292+
265293
case "Owner":
266294
if (ids.Intersect(kvp.Value).Any())
267295
{
@@ -287,6 +315,13 @@ public override bool HasMandatoryReferenceNotIn(HashSet<Guid> ids)
287315
{
288316
switch (kvp.Key)
289317
{
318+
case "LockedBy":
319+
if (kvp.Value.Except(ids).Any())
320+
{
321+
result = true;
322+
}
323+
break;
324+
290325
case "Owner":
291326
if (kvp.Value.Except(ids).Any())
292327
{
@@ -361,15 +396,18 @@ public override void ResolveCopy(Thing originalThing, IReadOnlyDictionary<Thing,
361396
this.ExcludedPerson.Add(copy.Value == null ? guid : copy.Value.Iid);
362397
}
363398

399+
this.IsHidden = original.IsHidden;
400+
401+
var copyLockedBy = originalCopyMap.SingleOrDefault(kvp => kvp.Key.Iid == original.LockedBy);
402+
this.LockedBy = copyLockedBy.Value == null ? original.LockedBy : copyLockedBy.Value.Iid;
403+
364404
this.ModifiedOn = original.ModifiedOn;
365405

366406
this.Name = original.Name;
367407

368408
var copyOwner = originalCopyMap.SingleOrDefault(kvp => kvp.Key.Iid == original.Owner);
369409
this.Owner = copyOwner.Value == null ? original.Owner : copyOwner.Value.Iid;
370410

371-
this.PublicationState = original.PublicationState;
372-
373411
this.ThingPreference = original.ThingPreference;
374412

375413
var copyTopArchitectureElement = originalCopyMap.SingleOrDefault(kvp => kvp.Key.Iid == original.TopArchitectureElement);

CDP4Common/AutoGenDto/DiagramCanvas.cs

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,26 @@ public DiagramCanvas(Guid iid, int rev) : base(iid: iid, rev: rev)
8282
/// <summary>
8383
/// Gets or sets the Description.
8484
/// </summary>
85+
[CDPVersion("1.4.0")]
8586
[UmlInformation(aggregation: AggregationKind.None, isDerived: false, isOrdered: false, isNullable: false, isPersistent: true)]
8687
[DataMember]
8788
public virtual string Description { get; set; }
8889

8990
/// <summary>
90-
/// Gets or sets the PublicationState.
91+
/// Gets or sets a value indicating whether IsHidden.
9192
/// </summary>
93+
[CDPVersion("1.4.0")]
9294
[UmlInformation(aggregation: AggregationKind.None, isDerived: false, isOrdered: false, isNullable: false, isPersistent: true)]
9395
[DataMember]
94-
public virtual PublicationState PublicationState { get; set; }
96+
public virtual bool IsHidden { get; set; }
97+
98+
/// <summary>
99+
/// Gets or sets the unique identifier of the referenced LockedBy.
100+
/// </summary>
101+
[CDPVersion("1.4.0")]
102+
[UmlInformation(aggregation: AggregationKind.None, isDerived: false, isOrdered: false, isNullable: false, isPersistent: true)]
103+
[DataMember]
104+
public virtual Guid LockedBy { get; set; }
95105

96106
/// <summary>
97107
/// Gets the route for the current <see ref="DiagramCanvas"/>.
@@ -117,6 +127,11 @@ public override IDictionary<string, IEnumerable<Guid>> GetReferenceProperties()
117127

118128
dictionary.Add("ExcludedPerson", this.ExcludedPerson);
119129

130+
if (this.LockedBy != null)
131+
{
132+
dictionary.Add("LockedBy", new [] { this.LockedBy });
133+
}
134+
120135
return dictionary;
121136
}
122137

@@ -158,6 +173,14 @@ public override bool TryRemoveReferences(IEnumerable<Guid> ids, out List<string>
158173
case "ExcludedPerson":
159174
this.ExcludedPerson.Remove(id);
160175
break;
176+
177+
case "LockedBy":
178+
if (addModelErrors)
179+
{
180+
errors.Add($"Removed reference '{id}' from LockedBy property results in inconsistent DiagramCanvas.");
181+
result = false;
182+
}
183+
break;
161184
}
162185
}
163186
}
@@ -208,6 +231,14 @@ public override bool TryRemoveReferencesNotIn(IEnumerable<Guid> ids, out List<st
208231
this.ExcludedPerson.Remove(toBeRemoved);
209232
}
210233
break;
234+
235+
case "LockedBy":
236+
if (referencedProperty.Value.Except(ids).Any())
237+
{
238+
errors.Add($"Removed reference '{referencedProperty.Key}' from LockedBy property results in inconsistent DiagramCanvas.");
239+
result = false;
240+
}
241+
break;
211242
}
212243
}
213244

@@ -232,6 +263,12 @@ public override bool HasMandatoryReferenceToAny(IEnumerable<Guid> ids)
232263
{
233264
switch (kvp.Key)
234265
{
266+
case "LockedBy":
267+
if (ids.Intersect(kvp.Value).Any())
268+
{
269+
result = true;
270+
}
271+
break;
235272
}
236273
}
237274

@@ -251,6 +288,12 @@ public override bool HasMandatoryReferenceNotIn(HashSet<Guid> ids)
251288
{
252289
switch (kvp.Key)
253290
{
291+
case "LockedBy":
292+
if (kvp.Value.Except(ids).Any())
293+
{
294+
result = true;
295+
}
296+
break;
254297
}
255298
}
256299

@@ -319,12 +362,15 @@ public override void ResolveCopy(Thing originalThing, IReadOnlyDictionary<Thing,
319362
this.ExcludedPerson.Add(copy.Value == null ? guid : copy.Value.Iid);
320363
}
321364

365+
this.IsHidden = original.IsHidden;
366+
367+
var copyLockedBy = originalCopyMap.SingleOrDefault(kvp => kvp.Key.Iid == original.LockedBy);
368+
this.LockedBy = copyLockedBy.Value == null ? original.LockedBy : copyLockedBy.Value.Iid;
369+
322370
this.ModifiedOn = original.ModifiedOn;
323371

324372
this.Name = original.Name;
325373

326-
this.PublicationState = original.PublicationState;
327-
328374
this.ThingPreference = original.ThingPreference;
329375
}
330376

CDP4Common/AutoGenEquatable/ArchitectureDiagramEquatable.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@
4242
| 8 | createdOn | DateTime | 1..1 | 1.4.0 |
4343
| 9 | description | string | 1..1 | 1.4.0 |
4444
| 10 | diagramElement | Guid | 0..* | 1.4.0 |
45-
| 11 | name | string | 1..1 | 1.4.0 |
46-
| 12 | owner | Guid | 1..1 | 1.4.0 |
47-
| 13 | publicationState | PublicationState | 1..1 | 1.4.0 |
48-
| 14 | topArchitectureElement | Guid | 0..1 | 1.4.0 |
45+
| 11 | isHidden | bool | 1..1 | 1.4.0 |
46+
| 12 | lockedBy | Guid | 1..1 | 1.4.0 |
47+
| 13 | name | string | 1..1 | 1.4.0 |
48+
| 14 | owner | Guid | 1..1 | 1.4.0 |
49+
| 15 | topArchitectureElement | Guid | 0..1 | 1.4.0 |
4950
* -------------------------------------------- | ---------------------------- | ----------- | ------- */
5051

5152
namespace CDP4Common.DTO.Equatable
@@ -106,13 +107,15 @@ public static bool ArePropertiesEqual(this ArchitectureDiagram me, ArchitectureD
106107

107108
if (!me.DiagramElement.OrderBy(x => x).SequenceEqual(other.DiagramElement.OrderBy(x => x))) return false;
108109

110+
if (!me.IsHidden.Equals(other.IsHidden)) return false;
111+
112+
if (!me.LockedBy.Equals(other.LockedBy)) return false;
113+
109114
if (me.Name == null && other.Name != null) return false;
110115
if (me.Name != null && !me.Name.Equals(other.Name)) return false;
111116

112117
if (!me.Owner.Equals(other.Owner)) return false;
113118

114-
if (!me.PublicationState.Equals(other.PublicationState)) return false;
115-
116119
if (me.TopArchitectureElement.HasValue != other.TopArchitectureElement.HasValue) return false;
117120
if (!me.TopArchitectureElement.Equals(other.TopArchitectureElement)) return false;
118121

CDP4Common/AutoGenEquatable/DiagramCanvasEquatable.cs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,16 @@
3535
| -------------------------------------------- | ---------------------------- | ----------- | ------- |
3636
| 2 | bounds | Guid | 0..1 | 1.1.0 |
3737
| 3 | createdOn | DateTime | 1..1 | 1.1.0 |
38-
| 4 | description | string | 1..1 | 1.1.0 |
39-
| 5 | diagramElement | Guid | 0..* | 1.1.0 |
40-
| 6 | excludedDomain | Guid | 0..* | 1.1.0 |
41-
| 7 | excludedPerson | Guid | 0..* | 1.1.0 |
42-
| 8 | modifiedOn | DateTime | 1..1 | 1.1.0 |
43-
| 9 | name | string | 1..1 | 1.1.0 |
44-
| 10 | publicationState | PublicationState | 1..1 | 1.1.0 |
45-
| 11 | thingPreference | string | 0..1 | 1.2.0 |
46-
| 12 | actor | Guid | 0..1 | 1.3.0 |
38+
| 4 | diagramElement | Guid | 0..* | 1.1.0 |
39+
| 5 | excludedDomain | Guid | 0..* | 1.1.0 |
40+
| 6 | excludedPerson | Guid | 0..* | 1.1.0 |
41+
| 7 | modifiedOn | DateTime | 1..1 | 1.1.0 |
42+
| 8 | name | string | 1..1 | 1.1.0 |
43+
| 9 | thingPreference | string | 0..1 | 1.2.0 |
44+
| 10 | actor | Guid | 0..1 | 1.3.0 |
45+
| 11 | description | string | 1..1 | 1.4.0 |
46+
| 12 | isHidden | bool | 1..1 | 1.4.0 |
47+
| 13 | lockedBy | Guid | 1..1 | 1.4.0 |
4748
* -------------------------------------------- | ---------------------------- | ----------- | ------- */
4849

4950
namespace CDP4Common.DTO.Equatable
@@ -87,9 +88,6 @@ public static bool ArePropertiesEqual(this DiagramCanvas me, DiagramCanvas other
8788

8889
if (!me.CreatedOn.Equals(other.CreatedOn)) return false;
8990

90-
if (me.Description == null && other.Description != null) return false;
91-
if (me.Description != null && !me.Description.Equals(other.Description)) return false;
92-
9391
if (!me.DiagramElement.OrderBy(x => x).SequenceEqual(other.DiagramElement.OrderBy(x => x))) return false;
9492

9593
if (!me.ExcludedDomain.OrderBy(x => x).SequenceEqual(other.ExcludedDomain.OrderBy(x => x))) return false;
@@ -101,14 +99,19 @@ public static bool ArePropertiesEqual(this DiagramCanvas me, DiagramCanvas other
10199
if (me.Name == null && other.Name != null) return false;
102100
if (me.Name != null && !me.Name.Equals(other.Name)) return false;
103101

104-
if (!me.PublicationState.Equals(other.PublicationState)) return false;
105-
106102
if (me.ThingPreference == null && other.ThingPreference != null) return false;
107103
if (me.ThingPreference != null && !me.ThingPreference.Equals(other.ThingPreference)) return false;
108104

109105
if (me.Actor.HasValue != other.Actor.HasValue) return false;
110106
if (!me.Actor.Equals(other.Actor)) return false;
111107

108+
if (me.Description == null && other.Description != null) return false;
109+
if (me.Description != null && !me.Description.Equals(other.Description)) return false;
110+
111+
if (!me.IsHidden.Equals(other.IsHidden)) return false;
112+
113+
if (!me.LockedBy.Equals(other.LockedBy)) return false;
114+
112115
return true;
113116
}
114117
}

CDP4Common/AutoGenMetaInfo/ArchitectureDiagramMetaInfo.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,11 @@ public IEnumerable<OrderedItem> GetOrderedContainmentIds(CDP4Common.DTO.Thing ar
197197
private readonly Dictionary<string, string> cdpVersionedProperties = new Dictionary<string, string>
198198
{
199199
{ "Actor", "1.3.0" },
200+
{ "Description", "1.4.0" },
200201
{ "ExcludedDomain", "1.1.0" },
201202
{ "ExcludedPerson", "1.1.0" },
203+
{ "IsHidden", "1.4.0" },
204+
{ "LockedBy", "1.4.0" },
202205
{ "ModifiedOn", "1.1.0" },
203206
{ "ThingPreference", "1.2.0" },
204207
};
@@ -245,10 +248,11 @@ public IEnumerable<PropertyMetaInfo> Properties
245248
{ "ExcludedDomain", thing => thing.ExcludedDomain },
246249
{ "ExcludedPerson", thing => thing.ExcludedPerson },
247250
{ "Iid", thing => thing.Iid },
251+
{ "IsHidden", thing => thing.IsHidden },
252+
{ "LockedBy", thing => thing.LockedBy },
248253
{ "ModifiedOn", thing => thing.ModifiedOn },
249254
{ "Name", thing => thing.Name },
250255
{ "Owner", thing => thing.Owner },
251-
{ "PublicationState", thing => thing.PublicationState },
252256
{ "RevisionNumber", thing => thing.RevisionNumber },
253257
{ "ThingPreference", thing => thing.ThingPreference },
254258
{ "TopArchitectureElement", thing => thing.TopArchitectureElement },
@@ -269,10 +273,11 @@ public IEnumerable<PropertyMetaInfo> Properties
269273
{ "ExcludedDomain", new PropertyMetaInfo("ExcludedDomain", "DomainOfExpertise", PropertyKind.List, AggregationKind.None, false, false, true, 0, "*", true) },
270274
{ "ExcludedPerson", new PropertyMetaInfo("ExcludedPerson", "Person", PropertyKind.List, AggregationKind.None, false, false, true, 0, "*", true) },
271275
{ "Iid", new PropertyMetaInfo("Iid", "Guid", PropertyKind.Scalar, AggregationKind.None, false, false, true, 1, "1", true) },
276+
{ "IsHidden", new PropertyMetaInfo("IsHidden", "bool", PropertyKind.Scalar, AggregationKind.None, false, false, true, 1, "1", true) },
277+
{ "LockedBy", new PropertyMetaInfo("LockedBy", "Person", PropertyKind.Scalar, AggregationKind.None, false, false, true, 1, "1", true) },
272278
{ "ModifiedOn", new PropertyMetaInfo("ModifiedOn", "DateTime", PropertyKind.Scalar, AggregationKind.None, false, false, true, 1, "1", true) },
273279
{ "Name", new PropertyMetaInfo("Name", "string", PropertyKind.Scalar, AggregationKind.None, false, false, true, 1, "1", true) },
274280
{ "Owner", new PropertyMetaInfo("Owner", "DomainOfExpertise", PropertyKind.Scalar, AggregationKind.None, false, false, true, 1, "1", true) },
275-
{ "PublicationState", new PropertyMetaInfo("PublicationState", "CDP4Common.DiagramData.PublicationState", PropertyKind.Scalar, AggregationKind.None, false, false, true, 1, "1", true) },
276281
{ "RevisionNumber", new PropertyMetaInfo("RevisionNumber", "int", PropertyKind.Scalar, AggregationKind.None, false, false, true, 1, "1", true) },
277282
{ "ThingPreference", new PropertyMetaInfo("ThingPreference", "string", PropertyKind.Scalar, AggregationKind.None, false, false, true, 0, "1", true) },
278283
{ "TopArchitectureElement", new PropertyMetaInfo("TopArchitectureElement", "ArchitectureElement", PropertyKind.Scalar, AggregationKind.None, false, false, true, 0, "1", true) },
@@ -298,10 +303,11 @@ public IEnumerable<PropertyMetaInfo> Properties
298303
{ "CreatedOn", (architectureDiagram, value) => architectureDiagram.CreatedOn = (DateTime)value },
299304
{ "Description", (architectureDiagram, value) => architectureDiagram.Description = value.ToString() },
300305
{ "Iid", (architectureDiagram, value) => architectureDiagram.Iid = (Guid)value },
306+
{ "IsHidden", (architectureDiagram, value) => architectureDiagram.IsHidden = (bool)value },
307+
{ "LockedBy", (architectureDiagram, value) => architectureDiagram.LockedBy = (Guid)value },
301308
{ "ModifiedOn", (architectureDiagram, value) => architectureDiagram.ModifiedOn = (DateTime)value },
302309
{ "Name", (architectureDiagram, value) => architectureDiagram.Name = value.ToString() },
303310
{ "Owner", (architectureDiagram, value) => architectureDiagram.Owner = (Guid)value },
304-
{ "PublicationState", (architectureDiagram, value) => architectureDiagram.PublicationState = (PublicationState)value },
305311
{ "ThingPreference", (architectureDiagram, value) => architectureDiagram.ThingPreference = value == null ? (string)null : value.ToString() },
306312
{ "TopArchitectureElement", (architectureDiagram, value) => architectureDiagram.TopArchitectureElement = value == null ? (Guid?)null : (Guid)value },
307313
};

0 commit comments

Comments
 (0)